Skip to content

Commit 202fb9a

Browse files
committed
Fix TreeSitter error handling
1 parent e6de320 commit 202fb9a

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

src/tree-sitter/tree-sitter-json/grammar.js

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,7 @@ module.exports = grammar({
1616

1717
rules: {
1818
json: $ => seq(
19-
optional(
20-
seq(
21-
fieldAlias($,
22-
'regex',
23-
token.immediate(
24-
seq(
25-
repeat(' '),
26-
choice(
27-
/[^\x00-\x1F\\"{\[]+/,
28-
/\\[^\x00-\x1F]/,
29-
),
30-
repeat(
31-
choice(
32-
/[^\x00-\x1F\\"]+/,
33-
/\\[^\x00-\x1F]/,
34-
),
35-
),
36-
37-
),
38-
),
39-
),
40-
/\r?\n|\x00/, // '\0' is treated as EOF
41-
),
42-
),
19+
optional($.regex),
4320
repeat(
4421
choice(
4522
$._whitespace,
@@ -87,6 +64,28 @@ module.exports = grammar({
8764
),
8865
),
8966

67+
regex: $ => seq(
68+
fieldAlias($,
69+
'regex',
70+
token.immediate(
71+
seq(
72+
repeat(' '),
73+
choice(
74+
/[^\x00-\x1F\\"{\[]+/,
75+
/\\[^\x00-\x1F]/,
76+
),
77+
repeat(
78+
choice(
79+
/[^\x00-\x1F\\"]+/,
80+
/\\[^\x00-\x1F]/,
81+
),
82+
),
83+
),
84+
),
85+
),
86+
/\r?\n|\x00/, // '\0' is treated as EOF
87+
),
88+
9089
repository: $ => pair($,
9190
"repository",
9291
object($, $.repo),

0 commit comments

Comments
 (0)