Skip to content

Commit f80854c

Browse files
ribru17clason
authored andcommitted
fix: align escape sequences to the query.c logic
Tree-sitter queries do not employ javascript-style escaping, they simply escape the next UTF-8 codepoint after a backslash.
1 parent e8c9cb3 commit f80854c

File tree

3 files changed

+362
-434
lines changed

3 files changed

+362
-434
lines changed

grammar.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,8 @@ module.exports = grammar({
5151
immediate_child($._named_node_expression),
5252
),
5353

54-
// Taken from https://github.com/tree-sitter/tree-sitter-javascript/blob/3f8b62f9befd3cb3b4cb0de22f6595a0aadf76ca/grammar.js#L827
55-
escape_sequence: _ => token.immediate(seq(
56-
'\\',
57-
choice(
58-
/[^xu0-7]/,
59-
/[0-7]{1,3}/,
60-
/x[0-9a-fA-F]{2}/,
61-
/u[0-9a-fA-F]{4}/,
62-
/u\{[0-9a-fA-F]+\}/
63-
)
64-
)),
54+
// Taken from https://github.com/tree-sitter/tree-sitter/blob/4339b0fe05b264082bd159a77b21fc5d586c3a29/lib/src/query.c#L2056
55+
escape_sequence: _ => token.immediate(seq('\\', /./)),
6556

6657
quantifier: _ => choice("*", "+", "?"),
6758

src/grammar.json

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

0 commit comments

Comments
 (0)