Skip to content

Commit c64f8cb

Browse files
committed
fix: Adjust regex for escaped unicode character literals
1 parent 3691201 commit c64f8cb

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
@@ -1560,7 +1560,7 @@ module.exports = grammar({
15601560
seq('\\', choice(
15611561
/[^xu]/,
15621562
/u[0-9a-fA-F]{4}/,
1563-
/u\{[0-9a-fA-F]+\}/,
1563+
/u\{[0-9a-fA-F_]+\}/,
15641564
/x[0-9a-fA-F]{2}/,
15651565
)),
15661566
/[^\\']/,
@@ -1573,7 +1573,7 @@ module.exports = grammar({
15731573
choice(
15741574
/[^xu]/,
15751575
/u[0-9a-fA-F]{4}/,
1576-
/u\{[0-9a-fA-F]+\}/,
1576+
/u\{[0-9a-fA-F_]+\}/,
15771577
/x[0-9a-fA-F]{2}/,
15781578
),
15791579
)),

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)