Skip to content

Commit d91adf1

Browse files
ekorchmaramaanq
authored andcommitted
feat: add unicode character escapes
An assumption is made that pattern like \u{DEDBEF} always represents intent to escape a unicode character.
1 parent d52498d commit d91adf1

File tree

5 files changed

+1263
-887
lines changed

5 files changed

+1263
-887
lines changed

grammar.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ module.exports = grammar({
160160
character_class_escape: $ => choice(
161161
/\\[dDsSwW]/,
162162
seq(/\\[pP]/, '{', $.unicode_property_value_expression, '}'),
163+
$.unicode_character_escape,
164+
),
165+
166+
unicode_character_escape: _ => choice(
167+
/\\u[0-9a-fA-F]{4}/,
168+
// NOTE: The following is a valid syntax only if the "u" flag is set.
169+
// However, this is unlikely that "u" would be encountered
170+
/\\u\{[0-9a-fA-F]{1,6}\}/,
163171
),
164172

165173
unicode_property_value_expression: $ => seq(

src/grammar.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)