Skip to content

Commit 1f964c3

Browse files
committed
fix: Adjust regex for escaped unicode character literals
1 parent 261b202 commit 1f964c3

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

grammar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ module.exports = grammar({
15611561
seq('\\', choice(
15621562
/[^xu]/,
15631563
/u[0-9a-fA-F]{4}/,
1564-
/u\{[0-9a-fA-F]+\}/,
1564+
/u\{[0-9a-fA-F_]+\}/,
15651565
/x[0-9a-fA-F]{2}/,
15661566
)),
15671567
/[^\\']/,
@@ -1574,7 +1574,7 @@ module.exports = grammar({
15741574
choice(
15751575
/[^xu]/,
15761576
/u[0-9a-fA-F]{4}/,
1577-
/u\{[0-9a-fA-F]+\}/,
1577+
/u\{[0-9a-fA-F_]+\}/,
15781578
/x[0-9a-fA-F]{2}/,
15791579
),
15801580
)),

test/corpus/literals.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ b"foo\nbar";
8181
"/* foo bar */ foo bar";
8282
"foo\x42\x43bar";
8383
"foo \x42 \x43 bar";
84+
"\u{10__FFFF}";
8485

8586
--------------------------------------------------------------------------------
8687

@@ -123,7 +124,10 @@ b"foo\nbar";
123124
(escape_sequence)
124125
(string_content)
125126
(escape_sequence)
126-
(string_content))))
127+
(string_content)))
128+
(expression_statement
129+
(string_literal
130+
(escape_sequence))))
127131

128132
================================================================================
129133
Raw string literals
@@ -198,6 +202,7 @@ b'x';
198202
'\t';
199203
'\xff';
200204
'\\';
205+
'\u{10__FFFF}';
201206

202207
--------------------------------------------------------------------------------
203208

@@ -214,6 +219,8 @@ b'x';
214219
(char_literal))
215220
(expression_statement
216221
(char_literal))
222+
(expression_statement
223+
(char_literal))
217224
(expression_statement
218225
(char_literal)))
219226

0 commit comments

Comments
 (0)