Don't mark lone backslashes as escape sequences

This commit is contained in:
Martin Jambon 2023-06-23 13:12:10 -07:00
parent 98fdcad2a0
commit 71fe2fd68b
2 changed files with 7 additions and 11 deletions

View file

@ -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

View file

@ -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(
"\\\\",
"\\'",
"\\"
"\\'"
)
),