@willbooster/tree-sitter-javascript 11.0.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/grammar.js +177 -65
- package/grammars/script/src/node-types.json +8 -0
- package/package.json +17 -20
- package/src/node-types.json +8 -0
- package/tree-sitter-javascript.wasm +0 -0
- package/tree-sitter-javascript_script.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test.yml)
|
|
6
6
|
[](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test-rust.yml)
|
|
7
7
|
[](https://github.com/semantic-release/semantic-release)
|
|
8
|
-
[](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
|
|
9
9
|
[](https://crates.io/crates/willbooster-tree-sitter-javascript)
|
|
10
10
|
|
|
11
11
|
JavaScript and JSX grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
|
|
@@ -30,6 +30,7 @@ For the native CLI, select Script with `tree-sitter parse --grammar-path grammar
|
|
|
30
30
|
|
|
31
31
|
```js
|
|
32
32
|
import { fileURLToPath } from 'node:url';
|
|
33
|
+
|
|
33
34
|
import { Language, Parser } from '@willbooster/web-tree-sitter';
|
|
34
35
|
|
|
35
36
|
await Parser.init();
|
|
@@ -44,9 +45,9 @@ For the Script goal, replace the language import below with
|
|
|
44
45
|
`@willbooster/tree-sitter-javascript/tree-sitter-javascript_script.wasm?url`:
|
|
45
46
|
|
|
46
47
|
```js
|
|
48
|
+
import javascriptUrl from '@willbooster/tree-sitter-javascript/tree-sitter-javascript.wasm?url';
|
|
47
49
|
import { Language, Parser } from '@willbooster/web-tree-sitter';
|
|
48
50
|
import runtimeUrl from '@willbooster/web-tree-sitter/web-tree-sitter.wasm?url'; // Vite
|
|
49
|
-
import javascriptUrl from '@willbooster/tree-sitter-javascript/tree-sitter-javascript.wasm?url';
|
|
50
51
|
|
|
51
52
|
await Parser.init({ locateFile: () => runtimeUrl });
|
|
52
53
|
const parser = new Parser();
|
|
@@ -58,9 +59,9 @@ In Cloudflare Workers, which do not allow compiling Wasm at run time, import the
|
|
|
58
59
|
below with `@willbooster/tree-sitter-javascript/tree-sitter-javascript_script.wasm`:
|
|
59
60
|
|
|
60
61
|
```js
|
|
62
|
+
import javascript from '@willbooster/tree-sitter-javascript/tree-sitter-javascript.wasm';
|
|
61
63
|
import { Language, Parser } from '@willbooster/web-tree-sitter';
|
|
62
64
|
import runtime from '@willbooster/web-tree-sitter/web-tree-sitter.wasm';
|
|
63
|
-
import javascript from '@willbooster/tree-sitter-javascript/tree-sitter-javascript.wasm';
|
|
64
65
|
|
|
65
66
|
await Parser.init({ wasmModule: runtime });
|
|
66
67
|
const parser = new Parser();
|
package/grammar.js
CHANGED
|
@@ -54,6 +54,7 @@ const NAMED_RESERVED_WORDS = new Set(['this', 'super', 'true', 'false', 'null'])
|
|
|
54
54
|
// Words that are keywords only in some positions and identifiers elsewhere.
|
|
55
55
|
const MEMBER_MODIFIERS = ['get', 'set', 'static'];
|
|
56
56
|
const CONTEXTUAL_KEYWORDS = ['async', 'await', 'let', 'of', 'using'];
|
|
57
|
+
const CLASSIC_ASSIGNMENT_OPERATORS = ['+=', '-=', '*=', '/=', '%=', '^=', '&=', '|=', '>>=', '>>>=', '<<=', '**='];
|
|
57
58
|
|
|
58
59
|
// oxlint-disable-next-line unicorn/prefer-module -- This package is CommonJS, so tree-sitter loads grammar.js as CommonJS.
|
|
59
60
|
module.exports = grammar({
|
|
@@ -76,8 +77,8 @@ module.exports = grammar({
|
|
|
76
77
|
// _arrow_function_block_continuation, since the arrow function may be, e.g., an argument.
|
|
77
78
|
sym('_arrow_function_block_end'),
|
|
78
79
|
sym('_arrow_function_block_continuation'),
|
|
79
|
-
//
|
|
80
|
-
// leading optional flags duplicate parse states.
|
|
80
|
+
// Bindings emit a boundary to preserve reuse; the other flags only select a scanner line-break rule.
|
|
81
|
+
// Keep those flags alternatives to what follows: leading optional flags duplicate parse states.
|
|
81
82
|
sym('_line_break_ends_statement'),
|
|
82
83
|
sym('_line_break_after_binding'),
|
|
83
84
|
sym('_line_break_after_field'),
|
|
@@ -126,6 +127,7 @@ module.exports = grammar({
|
|
|
126
127
|
sym('_async_function_signature_start'),
|
|
127
128
|
sym('_call_arguments_context'),
|
|
128
129
|
sym('_async_keyword'),
|
|
130
|
+
sym('_line_break_before_from'),
|
|
129
131
|
],
|
|
130
132
|
|
|
131
133
|
extras: ($) => [$.comment, sym('html_comment'), /[\s\p{Zs}\uFEFF\u2028\u2029\u2060\u200B]/u],
|
|
@@ -141,10 +143,15 @@ module.exports = grammar({
|
|
|
141
143
|
$.declaration,
|
|
142
144
|
$._decorated_export_declaration,
|
|
143
145
|
$.expression,
|
|
146
|
+
$._binary_operand,
|
|
147
|
+
$._unary_operand,
|
|
144
148
|
$.primary_expression,
|
|
145
149
|
$.pattern,
|
|
146
150
|
$._constructor,
|
|
147
151
|
$._constructor_chain_base,
|
|
152
|
+
$._assignment_call_callee,
|
|
153
|
+
$._call_callee,
|
|
154
|
+
$._assignment_call_primary,
|
|
148
155
|
],
|
|
149
156
|
|
|
150
157
|
inline: ($) => [
|
|
@@ -188,7 +195,7 @@ module.exports = grammar({
|
|
|
188
195
|
$.arrow_function,
|
|
189
196
|
],
|
|
190
197
|
['assign', $.primary_expression],
|
|
191
|
-
['member', 'template_call', 'new', 'call', $.expression],
|
|
198
|
+
['member', 'template_call', 'new', 'call', $.expression, $._binary_operand, $._unary_operand],
|
|
192
199
|
['declaration', 'literal'],
|
|
193
200
|
[$.primary_expression, $.statement_block, 'object'],
|
|
194
201
|
// A `{` that may begin both a block and an object starts a statement or an arrow function's body, where ECMAScript
|
|
@@ -197,18 +204,25 @@ module.exports = grammar({
|
|
|
197
204
|
[$.meta_property, $.import],
|
|
198
205
|
[$.import_statement, $.import],
|
|
199
206
|
[$.export_statement, $.primary_expression],
|
|
200
|
-
[$.lexical_declaration, $.
|
|
201
|
-
[$.for_lexical_declaration, $.
|
|
207
|
+
[$.lexical_declaration, $._primary_atom],
|
|
208
|
+
[$.for_lexical_declaration, $._primary_atom],
|
|
202
209
|
],
|
|
203
210
|
|
|
204
211
|
conflicts: ($) => [
|
|
212
|
+
[$._call_callee, $.call_expression],
|
|
213
|
+
[$.for_in_clause, $._primary_atom],
|
|
214
|
+
[$._primary_atom, $.rest_pattern],
|
|
215
|
+
[$._primary_atom, $.pattern],
|
|
216
|
+
[$.arrow_function, $._primary_atom, $._property_name],
|
|
217
|
+
[$._primary_atom, $.method_definition],
|
|
218
|
+
[$._primary_atom, $._property_name],
|
|
219
|
+
[$._primary_atom, $.await_expression, $._property_name],
|
|
220
|
+
[$.object, $.object_pattern, $._primary_atom],
|
|
221
|
+
[$.arrow_function, $._primary_atom],
|
|
222
|
+
[$._primary_atom, $.await_expression],
|
|
223
|
+
[$.call_expression, $._constructor_import],
|
|
224
|
+
[$.primary_expression, $._assignment_call_primary],
|
|
205
225
|
[$._local_export_specifier, $._module_export_name],
|
|
206
|
-
[$.primary_expression, $._property_name],
|
|
207
|
-
[$.primary_expression, $.await_expression],
|
|
208
|
-
[$.primary_expression, $.await_expression, $._property_name],
|
|
209
|
-
[$.primary_expression, $.arrow_function],
|
|
210
|
-
[$.primary_expression, $.arrow_function, $._property_name],
|
|
211
|
-
[$.primary_expression, $.method_definition],
|
|
212
226
|
[$.primary_expression, $.rest_pattern],
|
|
213
227
|
[$.primary_expression, $.pattern],
|
|
214
228
|
[$.primary_expression, $.for_in_clause],
|
|
@@ -217,7 +231,6 @@ module.exports = grammar({
|
|
|
217
231
|
[$.assignment_expression, $.pattern],
|
|
218
232
|
[$.assignment_expression, $.object_assignment_pattern],
|
|
219
233
|
[$.computed_property_name, $.array],
|
|
220
|
-
[$.binary_expression, $._initializer],
|
|
221
234
|
],
|
|
222
235
|
|
|
223
236
|
word: ($) => $.identifier,
|
|
@@ -241,14 +254,9 @@ module.exports = grammar({
|
|
|
241
254
|
seq(
|
|
242
255
|
'export',
|
|
243
256
|
choice(
|
|
244
|
-
seq(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
optional(choice($.import_attribute, sym('_line_break_before_attributes')))
|
|
248
|
-
),
|
|
249
|
-
alias($._local_export_clause, $.export_clause)
|
|
250
|
-
),
|
|
251
|
-
$._semicolon
|
|
257
|
+
seq(choice('*', $.namespace_export, $.export_clause), $._from_clause, $._module_statement_end),
|
|
258
|
+
seq(alias($._local_export_clause, $.export_clause), optional(sym('_line_break_before_from')), $._semicolon)
|
|
259
|
+
)
|
|
252
260
|
),
|
|
253
261
|
seq(
|
|
254
262
|
'export',
|
|
@@ -321,12 +329,7 @@ module.exports = grammar({
|
|
|
321
329
|
import: () => token('import'),
|
|
322
330
|
|
|
323
331
|
import_statement: ($) =>
|
|
324
|
-
seq(
|
|
325
|
-
'import',
|
|
326
|
-
choice(seq($.import_clause, $._from_clause), field('source', $.string)),
|
|
327
|
-
optional(choice($.import_attribute, sym('_line_break_before_attributes'))),
|
|
328
|
-
$._semicolon
|
|
329
|
-
),
|
|
332
|
+
seq('import', choice(seq($.import_clause, $._from_clause), field('source', $.string)), $._module_statement_end),
|
|
330
333
|
|
|
331
334
|
import_clause: ($) =>
|
|
332
335
|
choice(
|
|
@@ -347,6 +350,12 @@ module.exports = grammar({
|
|
|
347
350
|
seq(field('name', $._module_export_name), 'as', field('alias', $.identifier))
|
|
348
351
|
),
|
|
349
352
|
|
|
353
|
+
_module_statement_end: ($) =>
|
|
354
|
+
choice(
|
|
355
|
+
seq($.import_attribute, choice($._semicolon, sym('_line_break_ends_statement'))),
|
|
356
|
+
seq(optional(sym('_line_break_before_attributes')), $._semicolon)
|
|
357
|
+
),
|
|
358
|
+
|
|
350
359
|
import_attribute: ($) => seq('with', $.object),
|
|
351
360
|
|
|
352
361
|
//
|
|
@@ -412,13 +421,25 @@ module.exports = grammar({
|
|
|
412
421
|
variable_declarator: ($) =>
|
|
413
422
|
seq(
|
|
414
423
|
field('name', choice($.identifier, alias('of', $.identifier), $._destructuring_pattern)),
|
|
415
|
-
|
|
424
|
+
choice($._initializer, sym('_line_break_after_binding'))
|
|
416
425
|
),
|
|
417
426
|
|
|
418
427
|
_lexical_variable_declarator: ($) =>
|
|
419
428
|
seq(
|
|
420
429
|
field('name', choice(reserved('lexical', $.identifier), alias('of', $.identifier), $._destructuring_pattern)),
|
|
421
|
-
|
|
430
|
+
choice($._initializer, sym('_line_break_after_binding'))
|
|
431
|
+
),
|
|
432
|
+
|
|
433
|
+
_for_variable_declarator: ($) =>
|
|
434
|
+
seq(
|
|
435
|
+
field('name', choice($.identifier, alias('of', $.identifier), $._destructuring_pattern)),
|
|
436
|
+
optional($._initializer)
|
|
437
|
+
),
|
|
438
|
+
|
|
439
|
+
_for_lexical_variable_declarator: ($) =>
|
|
440
|
+
seq(
|
|
441
|
+
field('name', choice(reserved('lexical', $.identifier), alias('of', $.identifier), $._destructuring_pattern)),
|
|
442
|
+
optional($._initializer)
|
|
422
443
|
),
|
|
423
444
|
|
|
424
445
|
statement_block: ($) => prec.right(seq('{', repeat($._statement), '}')),
|
|
@@ -465,11 +486,12 @@ module.exports = grammar({
|
|
|
465
486
|
for_lexical_declaration: ($) =>
|
|
466
487
|
seq(
|
|
467
488
|
field('kind', choice('let', 'const')),
|
|
468
|
-
commaSep1(alias($.
|
|
489
|
+
commaSep1(alias($._for_lexical_variable_declarator, $.variable_declarator)),
|
|
469
490
|
';'
|
|
470
491
|
),
|
|
471
492
|
|
|
472
|
-
for_variable_declaration: ($) =>
|
|
493
|
+
for_variable_declaration: ($) =>
|
|
494
|
+
seq('var', commaSep1(alias($._for_variable_declarator, $.variable_declarator)), ';'),
|
|
473
495
|
|
|
474
496
|
_for_using_declaration: ($) =>
|
|
475
497
|
seq(
|
|
@@ -625,28 +647,14 @@ module.exports = grammar({
|
|
|
625
647
|
$.yield_expression
|
|
626
648
|
),
|
|
627
649
|
|
|
650
|
+
_binary_operand: ($) =>
|
|
651
|
+
choice($.primary_expression, $.await_expression, $.unary_expression, $.update_expression, $.binary_expression),
|
|
652
|
+
|
|
653
|
+
_unary_operand: ($) => choice($.primary_expression, $.await_expression, $.unary_expression, $.update_expression),
|
|
654
|
+
|
|
628
655
|
primary_expression: ($) =>
|
|
629
656
|
choice(
|
|
630
|
-
$.
|
|
631
|
-
$.parenthesized_expression,
|
|
632
|
-
$._identifier,
|
|
633
|
-
alias(sym('_await_yield_identifier'), $.identifier),
|
|
634
|
-
aliasWithAsyncKeyword($._reserved_identifier, $.identifier),
|
|
635
|
-
$.this,
|
|
636
|
-
$.super,
|
|
637
|
-
$.number,
|
|
638
|
-
$.string,
|
|
639
|
-
$.template_string,
|
|
640
|
-
$.regex,
|
|
641
|
-
$.true,
|
|
642
|
-
$.false,
|
|
643
|
-
$.null,
|
|
644
|
-
$.object,
|
|
645
|
-
$.array,
|
|
646
|
-
$.function_expression,
|
|
647
|
-
$.generator_function,
|
|
648
|
-
$.class,
|
|
649
|
-
$.meta_property,
|
|
657
|
+
$._primary_atom,
|
|
650
658
|
$.subscript_expression,
|
|
651
659
|
$.member_expression,
|
|
652
660
|
$.call_expression,
|
|
@@ -961,11 +969,16 @@ module.exports = grammar({
|
|
|
961
969
|
_call_signature: ($) => field('parameters', $.formal_parameters),
|
|
962
970
|
_formal_parameter: ($) => choice($.pattern, $.assignment_pattern),
|
|
963
971
|
|
|
972
|
+
_call_callee: ($) => $.primary_expression,
|
|
973
|
+
|
|
964
974
|
optional_chain: () => '?.',
|
|
965
975
|
|
|
966
976
|
call_expression: ($) =>
|
|
967
977
|
choice(
|
|
968
|
-
prec(
|
|
978
|
+
prec(
|
|
979
|
+
'call',
|
|
980
|
+
seq(field('function', choice(alias($._call_callee, $.expression), $.import)), field('arguments', $.arguments))
|
|
981
|
+
),
|
|
969
982
|
prec('template_call', seq(field('function', $.primary_expression), field('arguments', $.template_string))),
|
|
970
983
|
prec(
|
|
971
984
|
'member',
|
|
@@ -977,6 +990,81 @@ module.exports = grammar({
|
|
|
977
990
|
)
|
|
978
991
|
),
|
|
979
992
|
|
|
993
|
+
_primary_atom: ($) =>
|
|
994
|
+
choice(
|
|
995
|
+
$._jsx_element,
|
|
996
|
+
$.parenthesized_expression,
|
|
997
|
+
$._identifier,
|
|
998
|
+
alias(sym('_await_yield_identifier'), $.identifier),
|
|
999
|
+
aliasWithAsyncKeyword($._reserved_identifier, $.identifier),
|
|
1000
|
+
$.this,
|
|
1001
|
+
$.super,
|
|
1002
|
+
$.number,
|
|
1003
|
+
$.string,
|
|
1004
|
+
$.template_string,
|
|
1005
|
+
$.regex,
|
|
1006
|
+
$.true,
|
|
1007
|
+
$.false,
|
|
1008
|
+
$.null,
|
|
1009
|
+
$.object,
|
|
1010
|
+
$.array,
|
|
1011
|
+
$.function_expression,
|
|
1012
|
+
$.generator_function,
|
|
1013
|
+
$.class,
|
|
1014
|
+
$.meta_property
|
|
1015
|
+
),
|
|
1016
|
+
|
|
1017
|
+
_assignment_call: ($) =>
|
|
1018
|
+
prec(
|
|
1019
|
+
'call',
|
|
1020
|
+
seq(field('function', alias($._assignment_call_callee, $.expression)), field('arguments', $.arguments))
|
|
1021
|
+
),
|
|
1022
|
+
|
|
1023
|
+
_assignment_call_callee: ($) => alias($._assignment_call_primary, $.primary_expression),
|
|
1024
|
+
|
|
1025
|
+
_assignment_call_primary: ($) =>
|
|
1026
|
+
choice(
|
|
1027
|
+
$._primary_atom,
|
|
1028
|
+
$.new_expression,
|
|
1029
|
+
alias($._argumentless_new_expression, $.new_expression),
|
|
1030
|
+
alias($._assignment_call, $.call_expression),
|
|
1031
|
+
alias($._assignment_member, $.member_expression),
|
|
1032
|
+
alias($._assignment_subscript, $.subscript_expression),
|
|
1033
|
+
alias($._assignment_tag, $.call_expression),
|
|
1034
|
+
alias($._constructor_import, $.call_expression)
|
|
1035
|
+
),
|
|
1036
|
+
|
|
1037
|
+
_assignment_member: ($) =>
|
|
1038
|
+
prec(
|
|
1039
|
+
'member',
|
|
1040
|
+
seq(
|
|
1041
|
+
field('object', alias($._assignment_call_callee, $.expression)),
|
|
1042
|
+
'.',
|
|
1043
|
+
field(
|
|
1044
|
+
'property',
|
|
1045
|
+
choice(
|
|
1046
|
+
$.private_property_identifier,
|
|
1047
|
+
reserved('properties', alias($.identifier, sym('property_identifier')))
|
|
1048
|
+
)
|
|
1049
|
+
)
|
|
1050
|
+
)
|
|
1051
|
+
),
|
|
1052
|
+
|
|
1053
|
+
_assignment_subscript: ($) =>
|
|
1054
|
+
prec.right(
|
|
1055
|
+
'member',
|
|
1056
|
+
seq(field('object', alias($._assignment_call_callee, $.expression)), '[', field('index', $._expressions), ']')
|
|
1057
|
+
),
|
|
1058
|
+
|
|
1059
|
+
_assignment_tag: ($) =>
|
|
1060
|
+
prec(
|
|
1061
|
+
'template_call',
|
|
1062
|
+
seq(
|
|
1063
|
+
field('function', alias($._assignment_call_primary, $.primary_expression)),
|
|
1064
|
+
field('arguments', $.template_string)
|
|
1065
|
+
)
|
|
1066
|
+
),
|
|
1067
|
+
|
|
980
1068
|
new_expression: ($) =>
|
|
981
1069
|
prec(
|
|
982
1070
|
'new',
|
|
@@ -1108,7 +1196,7 @@ module.exports = grammar({
|
|
|
1108
1196
|
sym('_line_break_after_await')
|
|
1109
1197
|
)
|
|
1110
1198
|
),
|
|
1111
|
-
$.expression,
|
|
1199
|
+
alias($._unary_operand, $.expression),
|
|
1112
1200
|
sym('_await_operand_end')
|
|
1113
1201
|
)
|
|
1114
1202
|
)
|
|
@@ -1118,7 +1206,7 @@ module.exports = grammar({
|
|
|
1118
1206
|
prec(
|
|
1119
1207
|
'member',
|
|
1120
1208
|
seq(
|
|
1121
|
-
field('object', choice($.
|
|
1209
|
+
field('object', choice(alias($._call_callee, $.expression), $.import)),
|
|
1122
1210
|
choice('.', field('optional_chain', $.optional_chain)),
|
|
1123
1211
|
field(
|
|
1124
1212
|
'property',
|
|
@@ -1134,7 +1222,7 @@ module.exports = grammar({
|
|
|
1134
1222
|
prec.right(
|
|
1135
1223
|
'member',
|
|
1136
1224
|
seq(
|
|
1137
|
-
field('object',
|
|
1225
|
+
field('object', alias($._call_callee, $.expression)),
|
|
1138
1226
|
optional(field('optional_chain', $.optional_chain)),
|
|
1139
1227
|
'[',
|
|
1140
1228
|
field('index', $._expressions),
|
|
@@ -1154,7 +1242,14 @@ module.exports = grammar({
|
|
|
1154
1242
|
assignment_expression: ($) =>
|
|
1155
1243
|
prec.right(
|
|
1156
1244
|
'assign',
|
|
1157
|
-
seq(
|
|
1245
|
+
seq(
|
|
1246
|
+
field(
|
|
1247
|
+
'left',
|
|
1248
|
+
choice($.parenthesized_expression, $._lhs_expression, alias($._assignment_call, $.call_expression))
|
|
1249
|
+
),
|
|
1250
|
+
'=',
|
|
1251
|
+
field('right', $.expression)
|
|
1252
|
+
)
|
|
1158
1253
|
),
|
|
1159
1254
|
|
|
1160
1255
|
_augmented_assignment_lhs: ($) =>
|
|
@@ -1170,10 +1265,15 @@ module.exports = grammar({
|
|
|
1170
1265
|
prec.right(
|
|
1171
1266
|
'assign',
|
|
1172
1267
|
seq(
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1268
|
+
choice(
|
|
1269
|
+
seq(
|
|
1270
|
+
field('left', $._augmented_assignment_lhs),
|
|
1271
|
+
field('operator', choice(...CLASSIC_ASSIGNMENT_OPERATORS, '&&=', '||=', '??='))
|
|
1272
|
+
),
|
|
1273
|
+
seq(
|
|
1274
|
+
field('left', alias($._assignment_call, $.call_expression)),
|
|
1275
|
+
field('operator', choice(...CLASSIC_ASSIGNMENT_OPERATORS))
|
|
1276
|
+
)
|
|
1177
1277
|
),
|
|
1178
1278
|
field('right', $.expression)
|
|
1179
1279
|
)
|
|
@@ -1189,7 +1289,7 @@ module.exports = grammar({
|
|
|
1189
1289
|
prec.right(
|
|
1190
1290
|
'ternary',
|
|
1191
1291
|
seq(
|
|
1192
|
-
field('condition', $.expression),
|
|
1292
|
+
field('condition', alias($._binary_operand, $.expression)),
|
|
1193
1293
|
alias(sym('_ternary_qmark'), '?'),
|
|
1194
1294
|
field('consequence', $.expression),
|
|
1195
1295
|
':',
|
|
@@ -1230,9 +1330,14 @@ module.exports = grammar({
|
|
|
1230
1330
|
(associativity === 'right' ? prec.right : prec.left)(
|
|
1231
1331
|
precedence,
|
|
1232
1332
|
seq(
|
|
1233
|
-
field(
|
|
1333
|
+
field(
|
|
1334
|
+
'left',
|
|
1335
|
+
operator === 'in'
|
|
1336
|
+
? choice(alias($._binary_operand, $.expression), $.private_property_identifier)
|
|
1337
|
+
: alias($._binary_operand, $.expression)
|
|
1338
|
+
),
|
|
1234
1339
|
field('operator', operator),
|
|
1235
|
-
field('right', $.expression)
|
|
1340
|
+
field('right', alias($._binary_operand, $.expression))
|
|
1236
1341
|
)
|
|
1237
1342
|
)
|
|
1238
1343
|
)
|
|
@@ -1241,14 +1346,21 @@ module.exports = grammar({
|
|
|
1241
1346
|
unary_expression: ($) =>
|
|
1242
1347
|
prec.left(
|
|
1243
1348
|
'unary_void',
|
|
1244
|
-
seq(
|
|
1349
|
+
seq(
|
|
1350
|
+
field('operator', choice('!', '~', '-', '+', 'typeof', 'void', 'delete')),
|
|
1351
|
+
field('argument', alias($._unary_operand, $.expression))
|
|
1352
|
+
)
|
|
1245
1353
|
),
|
|
1246
1354
|
|
|
1247
1355
|
update_expression: ($) =>
|
|
1248
1356
|
prec.left(
|
|
1249
1357
|
choice(
|
|
1250
|
-
seq(
|
|
1251
|
-
|
|
1358
|
+
seq(
|
|
1359
|
+
field('argument', alias($._unary_operand, $.expression)),
|
|
1360
|
+
field('operator', choice('++', '--')),
|
|
1361
|
+
sym('_postfix_update_end')
|
|
1362
|
+
),
|
|
1363
|
+
seq(field('operator', choice('++', '--')), field('argument', alias($._unary_operand, $.expression)))
|
|
1252
1364
|
)
|
|
1253
1365
|
),
|
|
1254
1366
|
|
|
@@ -410,6 +410,10 @@
|
|
|
410
410
|
"type": "array_pattern",
|
|
411
411
|
"named": true
|
|
412
412
|
},
|
|
413
|
+
{
|
|
414
|
+
"type": "call_expression",
|
|
415
|
+
"named": true
|
|
416
|
+
},
|
|
413
417
|
{
|
|
414
418
|
"type": "identifier",
|
|
415
419
|
"named": true
|
|
@@ -482,6 +486,10 @@
|
|
|
482
486
|
"multiple": false,
|
|
483
487
|
"required": true,
|
|
484
488
|
"types": [
|
|
489
|
+
{
|
|
490
|
+
"type": "call_expression",
|
|
491
|
+
"named": true
|
|
492
|
+
},
|
|
485
493
|
{
|
|
486
494
|
"type": "identifier",
|
|
487
495
|
"named": true
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-javascript",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"description": "JavaScript grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
7
|
+
"javascript",
|
|
7
8
|
"parsing",
|
|
8
|
-
"tree-sitter"
|
|
9
|
-
"javascript"
|
|
9
|
+
"tree-sitter"
|
|
10
10
|
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"author": "WillBooster Inc.",
|
|
11
13
|
"repository": {
|
|
12
14
|
"type": "git",
|
|
13
15
|
"url": "git+https://github.com/WillBooster/tree-sitter-javascript.git"
|
|
14
16
|
},
|
|
15
|
-
"license": "MIT",
|
|
16
|
-
"author": "WillBooster Inc.",
|
|
17
17
|
"files": [
|
|
18
18
|
"grammar.js",
|
|
19
19
|
"grammars/script/grammar.js",
|
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
"src/node-types.json",
|
|
24
24
|
"*.wasm"
|
|
25
25
|
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public",
|
|
28
|
+
"registry": "https://registry.npmjs.org/"
|
|
29
|
+
},
|
|
26
30
|
"scripts": {
|
|
27
31
|
"build-wasm": "script/generate --build-wasm",
|
|
28
32
|
"build/ci": "bun run build-wasm",
|
|
@@ -43,27 +47,24 @@
|
|
|
43
47
|
"verify-full": "bun wb verify --full"
|
|
44
48
|
},
|
|
45
49
|
"devDependencies": {
|
|
46
|
-
"@babel/parser": "
|
|
50
|
+
"@babel/parser": "8.0.7",
|
|
47
51
|
"@tsconfig/bun": "1.0.11",
|
|
48
52
|
"@types/bun": "1.4.3",
|
|
49
|
-
"@vitest/browser-playwright": "5.0.
|
|
50
|
-
"@willbooster/
|
|
51
|
-
"@willbooster/
|
|
52
|
-
"@willbooster/wb": "22.26.2",
|
|
53
|
+
"@vitest/browser-playwright": "5.0.5",
|
|
54
|
+
"@willbooster/oxlint-config": "1.4.9",
|
|
55
|
+
"@willbooster/wb": "22.29.3",
|
|
53
56
|
"@willbooster/web-tree-sitter": "13.0.0",
|
|
54
|
-
"acorn": "8.
|
|
57
|
+
"acorn": "8.19.0",
|
|
55
58
|
"acorn-jsx": "5.3.2",
|
|
56
59
|
"conventional-changelog-conventionalcommits": "10.4.1",
|
|
57
60
|
"lefthook": "2.2.2",
|
|
58
|
-
"oxfmt": "0.73.0",
|
|
59
61
|
"oxlint": "1.88.0",
|
|
60
62
|
"oxlint-tsgolint": "7.0.2004",
|
|
61
|
-
"playwright": "1.64.
|
|
63
|
+
"playwright": "1.64.1",
|
|
62
64
|
"semantic-release": "25.0.9",
|
|
63
|
-
"sort-package-json": "4.0.0",
|
|
64
65
|
"vite": "8.3.4",
|
|
65
|
-
"vitest": "5.0.
|
|
66
|
-
"wrangler": "4.
|
|
66
|
+
"vitest": "5.0.5",
|
|
67
|
+
"wrangler": "4.151.1"
|
|
67
68
|
},
|
|
68
69
|
"peerDependencies": {
|
|
69
70
|
"@willbooster/web-tree-sitter": "^13.0.0"
|
|
@@ -72,9 +73,5 @@
|
|
|
72
73
|
"@willbooster/web-tree-sitter": {
|
|
73
74
|
"optional": true
|
|
74
75
|
}
|
|
75
|
-
},
|
|
76
|
-
"publishConfig": {
|
|
77
|
-
"access": "public",
|
|
78
|
-
"registry": "https://registry.npmjs.org/"
|
|
79
76
|
}
|
|
80
77
|
}
|
package/src/node-types.json
CHANGED
|
@@ -410,6 +410,10 @@
|
|
|
410
410
|
"type": "array_pattern",
|
|
411
411
|
"named": true
|
|
412
412
|
},
|
|
413
|
+
{
|
|
414
|
+
"type": "call_expression",
|
|
415
|
+
"named": true
|
|
416
|
+
},
|
|
413
417
|
{
|
|
414
418
|
"type": "identifier",
|
|
415
419
|
"named": true
|
|
@@ -482,6 +486,10 @@
|
|
|
482
486
|
"multiple": false,
|
|
483
487
|
"required": true,
|
|
484
488
|
"types": [
|
|
489
|
+
{
|
|
490
|
+
"type": "call_expression",
|
|
491
|
+
"named": true
|
|
492
|
+
},
|
|
485
493
|
{
|
|
486
494
|
"type": "identifier",
|
|
487
495
|
"named": true
|
|
Binary file
|
|
Binary file
|