@willbooster/tree-sitter-javascript 1.0.19 → 1.0.21
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/grammar.js +19 -22
- package/package.json +1 -1
- package/src/node-types.json +4 -8
- package/tree-sitter-javascript.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -137,6 +137,9 @@ module.exports = grammar({
|
|
|
137
137
|
['member', 'template_call', 'new', 'call', $.expression],
|
|
138
138
|
['declaration', 'literal'],
|
|
139
139
|
[$.primary_expression, $.statement_block, 'object'],
|
|
140
|
+
// A `{` that may begin both a block and an object starts a statement or an arrow function's body, where ECMAScript
|
|
141
|
+
// reads it as a block, so `{a: 1}` there is a labeled statement in a block.
|
|
142
|
+
[$.labeled_statement, $._property_name],
|
|
140
143
|
[$.meta_property, $.import],
|
|
141
144
|
[$.import_statement, $.import],
|
|
142
145
|
[$.export_statement, $.primary_expression],
|
|
@@ -159,7 +162,6 @@ module.exports = grammar({
|
|
|
159
162
|
[$.object, $.object_pattern],
|
|
160
163
|
[$.assignment_expression, $.pattern],
|
|
161
164
|
[$.assignment_expression, $.object_assignment_pattern],
|
|
162
|
-
[$.labeled_statement, $._property_name],
|
|
163
165
|
[$.computed_property_name, $.array],
|
|
164
166
|
[$.binary_expression, $._initializer],
|
|
165
167
|
],
|
|
@@ -454,13 +456,10 @@ module.exports = grammar({
|
|
|
454
456
|
empty_statement: () => ';',
|
|
455
457
|
|
|
456
458
|
labeled_statement: ($) =>
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
':',
|
|
462
|
-
field('body', $.statement)
|
|
463
|
-
)
|
|
459
|
+
seq(
|
|
460
|
+
field('label', alias(choice($.identifier, $._reserved_identifier), $.statement_identifier)),
|
|
461
|
+
':',
|
|
462
|
+
field('body', $.statement)
|
|
464
463
|
),
|
|
465
464
|
|
|
466
465
|
//
|
|
@@ -500,7 +499,6 @@ module.exports = grammar({
|
|
|
500
499
|
$.binary_expression,
|
|
501
500
|
$.ternary_expression,
|
|
502
501
|
$.update_expression,
|
|
503
|
-
$.new_expression,
|
|
504
502
|
$.yield_expression
|
|
505
503
|
),
|
|
506
504
|
|
|
@@ -527,7 +525,9 @@ module.exports = grammar({
|
|
|
527
525
|
$.generator_function,
|
|
528
526
|
$.class,
|
|
529
527
|
$.meta_property,
|
|
530
|
-
$.call_expression
|
|
528
|
+
$.call_expression,
|
|
529
|
+
$.new_expression,
|
|
530
|
+
alias($._argumentless_new_expression, $.new_expression)
|
|
531
531
|
),
|
|
532
532
|
|
|
533
533
|
yield_expression: ($) =>
|
|
@@ -789,10 +789,7 @@ module.exports = grammar({
|
|
|
789
789
|
call_expression: ($) =>
|
|
790
790
|
choice(
|
|
791
791
|
prec('call', seq(field('function', choice($.expression, $.import)), field('arguments', $.arguments))),
|
|
792
|
-
prec(
|
|
793
|
-
'template_call',
|
|
794
|
-
seq(field('function', choice($.primary_expression, $.new_expression)), field('arguments', $.template_string))
|
|
795
|
-
),
|
|
792
|
+
prec('template_call', seq(field('function', $.primary_expression), field('arguments', $.template_string))),
|
|
796
793
|
prec(
|
|
797
794
|
'member',
|
|
798
795
|
seq(
|
|
@@ -803,15 +800,15 @@ module.exports = grammar({
|
|
|
803
800
|
)
|
|
804
801
|
),
|
|
805
802
|
|
|
803
|
+
// As in ECMAScript, a member access or index extends the nearest `new` with arguments, while an argument list fills
|
|
804
|
+
// the nearest `new` that still lacks one: `new new A().b` constructs `new A().b`, `new new A().b(2)` constructs
|
|
805
|
+
// `new A().b` with `2`, and `new new A()(2)` constructs `new A()`. The 'member' and 'new' precedences make the parser
|
|
806
|
+
// shift a `.`, `[`, or argument list after a constructor rather than end a `new` without arguments, so that form
|
|
807
|
+
// never takes one. Both forms are primary expressions, so a nested `new` matches the constructor field's type.
|
|
806
808
|
new_expression: ($) =>
|
|
807
|
-
prec
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
'new',
|
|
811
|
-
field('constructor', choice($.primary_expression, $.new_expression)),
|
|
812
|
-
field('arguments', optional(prec.dynamic(1, $.arguments)))
|
|
813
|
-
)
|
|
814
|
-
),
|
|
809
|
+
prec('new', seq('new', field('constructor', $.primary_expression), field('arguments', $.arguments))),
|
|
810
|
+
|
|
811
|
+
_argumentless_new_expression: ($) => prec.right('new', seq('new', field('constructor', $.primary_expression))),
|
|
815
812
|
|
|
816
813
|
await_expression: ($) => prec.dynamic(2, prec('unary_void', seq('await', $.expression))),
|
|
817
814
|
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
|
@@ -57,10 +57,6 @@
|
|
|
57
57
|
"type": "jsx_self_closing_element",
|
|
58
58
|
"named": true
|
|
59
59
|
},
|
|
60
|
-
{
|
|
61
|
-
"type": "new_expression",
|
|
62
|
-
"named": true
|
|
63
|
-
},
|
|
64
60
|
{
|
|
65
61
|
"type": "primary_expression",
|
|
66
62
|
"named": true
|
|
@@ -165,6 +161,10 @@
|
|
|
165
161
|
"type": "meta_property",
|
|
166
162
|
"named": true
|
|
167
163
|
},
|
|
164
|
+
{
|
|
165
|
+
"type": "new_expression",
|
|
166
|
+
"named": true
|
|
167
|
+
},
|
|
168
168
|
{
|
|
169
169
|
"type": "null",
|
|
170
170
|
"named": true
|
|
@@ -2236,10 +2236,6 @@
|
|
|
2236
2236
|
"multiple": false,
|
|
2237
2237
|
"required": true,
|
|
2238
2238
|
"types": [
|
|
2239
|
-
{
|
|
2240
|
-
"type": "new_expression",
|
|
2241
|
-
"named": true
|
|
2242
|
-
},
|
|
2243
2239
|
{
|
|
2244
2240
|
"type": "primary_expression",
|
|
2245
2241
|
"named": true
|
|
Binary file
|