File tree 2 files changed +17
-3
lines changed
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -115,8 +115,20 @@ static bool scan_string_content(TSLexer *lexer, Stack *stack) {
115
115
advance (lexer );
116
116
// this dollar sign is escaped, so it must be content.
117
117
// we consume it here so we don't enter the dollar sign case above,
118
- // which leaves the possibility that it is an interpolation
119
- if (lexer -> lookahead == '$' ) advance (lexer );
118
+ // which leaves the possibility that it is an interpolation
119
+ if (lexer -> lookahead == '$' ) {
120
+ advance (lexer );
121
+ // however this leaves an edgecase where an escaped dollar sign could
122
+ // appear at the end of a string (e.g "aa\$") which isn't handled
123
+ // correctly; if we were at the end of the string, terminate properly
124
+ if (lexer -> lookahead == end_char ) {
125
+ stack_pop (stack );
126
+ advance (lexer );
127
+ lexer -> mark_end (lexer );
128
+ lexer -> result_symbol = STRING_END ;
129
+ return true;
130
+ }
131
+ }
120
132
} else if (lexer -> lookahead == end_char ) {
121
133
if (is_triple ) {
122
134
lexer -> mark_end (lexer );
Original file line number Diff line number Diff line change @@ -114,6 +114,7 @@ More string interpolation
114
114
"$1"
115
115
"$ $ $"
116
116
"\$foo"
117
+ "\$"
117
118
118
119
--------------------------------------------------------------------------------
119
120
@@ -130,7 +131,8 @@ More string interpolation
130
131
(string_content)
131
132
(string_content))
132
133
(string_literal
133
- (string_content)))
134
+ (string_content))
135
+ (string_literal))
134
136
135
137
================================================================================
136
138
Integer literals
You can’t perform that action at this time.
0 commit comments