Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit 3274a9e

Browse files
committed
fix: double-backslash escapes
1 parent d8d2bb7 commit 3274a9e

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

grammar.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ module.exports = grammar({
182182

183183
string_fragment: _ => token.immediate(prec(1, /[^"\\]+/)),
184184
_multiline_string_fragment: _ => choice(
185-
/[^"]+/,
186-
seq(/"([^"]|\\")*/),
185+
/[^"\\]+/,
186+
seq(/"([^"\\]|\\")*/),
187187
),
188188

189189
string_interpolation: $ => seq(

test/corpus/expressions.txt

+20-1
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,11 @@ string interpolation
16401640
STR."Hello There";
16411641
STR."Hello \{x + y}";
16421642
STR."We can have \{many(of)} \{them.in} a \{row}";
1643+
compPass("""
1644+
StringTemplate result = RAW.\"""
1645+
\\{}
1646+
\""";
1647+
""");
16431648

16441649
--------------------------------------------------------------------------------
16451650

@@ -1675,7 +1680,21 @@ STR."We can have \{many(of)} \{them.in} a \{row}";
16751680
(identifier)))
16761681
(string_fragment)
16771682
(string_interpolation
1678-
(identifier))))))
1683+
(identifier)))))
1684+
(expression_statement
1685+
(method_invocation
1686+
(identifier)
1687+
(argument_list
1688+
(string_literal
1689+
(multiline_string_fragment)
1690+
(escape_sequence)
1691+
(multiline_string_fragment)
1692+
(multiline_string_fragment)
1693+
(escape_sequence)
1694+
(multiline_string_fragment)
1695+
(escape_sequence)
1696+
(multiline_string_fragment)
1697+
(multiline_string_fragment))))))
16791698

16801699
================================================================================
16811700
switch with qualified enum constant

test/corpus/literals.txt

+2
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ string="has a quote with an escaped end quote\"""";
234234
(multiline_string_fragment)))
235235
(expression_statement
236236
(string_literal
237+
(multiline_string_fragment)
238+
(escape_sequence)
237239
(multiline_string_fragment)))
238240
(expression_statement
239241
(string_literal

0 commit comments

Comments
 (0)