diff --git a/corpus/strings.txt b/corpus/strings.txt index 68d2e98..dc13b0d 100644 --- a/corpus/strings.txt +++ b/corpus/strings.txt @@ -57,9 +57,7 @@ ENV KEY "expansions: $FOO ${BAR}" (env_instruction (env_pair (unquoted_string) - (double_quoted_string - (double_quoted_escape_sequence) - (double_quoted_escape_sequence)))) + (double_quoted_string))) (env_instruction (env_pair (unquoted_string) @@ -106,9 +104,7 @@ ENV KEY 'not escape sequences: \a \n' (env_instruction (env_pair (unquoted_string) - (single_quoted_string - (single_quoted_escape_sequence) - (single_quoted_escape_sequence))))) + (single_quoted_string)))) ========================== Unquoted strings diff --git a/grammar.js b/grammar.js index 77ef352..d59f61c 100644 --- a/grammar.js +++ b/grammar.js @@ -391,6 +391,7 @@ module.exports = grammar({ choice( token.immediate(/[^"\n\\\$]+/), $.double_quoted_escape_sequence, + "\\", $._immediate_expansion ) ), @@ -404,7 +405,8 @@ module.exports = grammar({ repeat( choice( token.immediate(/[^'\n\\]+/), - $.single_quoted_escape_sequence + $.single_quoted_escape_sequence, + "\\", ) ), "'" @@ -422,16 +424,14 @@ module.exports = grammar({ double_quoted_escape_sequence: ($) => token.immediate( choice( "\\\\", - "\\\"", - "\\" + "\\\"" ) ), single_quoted_escape_sequence: ($) => token.immediate( choice( "\\\\", - "\\'", - "\\" + "\\'" ) ),