@willbooster/tree-sitter-javascript 14.0.1 → 15.0.1
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 +55 -39
- package/package.json +1 -1
- package/tree-sitter-javascript.wasm +0 -0
- package/tree-sitter-javascript_script.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -147,6 +147,8 @@ module.exports = grammar({
|
|
|
147
147
|
$._unary_operand,
|
|
148
148
|
$.primary_expression,
|
|
149
149
|
$.pattern,
|
|
150
|
+
$._non_rest_pattern,
|
|
151
|
+
$._rest_pattern,
|
|
150
152
|
$._constructor,
|
|
151
153
|
$._constructor_chain_base,
|
|
152
154
|
$._assignment_call_callee,
|
|
@@ -214,23 +216,23 @@ module.exports = grammar({
|
|
|
214
216
|
|
|
215
217
|
conflicts: ($) => [
|
|
216
218
|
[$._primary_atom, $._simple_target_primary],
|
|
217
|
-
[$._simple_target_primary, $.
|
|
218
|
-
[$._primary_atom, $._simple_target_primary, $.
|
|
219
|
+
[$._simple_target_primary, $._non_rest_pattern],
|
|
220
|
+
[$._primary_atom, $._simple_target_primary, $._non_rest_pattern],
|
|
219
221
|
[$._call_callee, $.call_expression],
|
|
220
222
|
[$.for_in_clause, $._primary_atom],
|
|
221
223
|
[$._primary_atom, $.rest_pattern],
|
|
222
|
-
[$._primary_atom, $.
|
|
224
|
+
[$._primary_atom, $._non_rest_pattern],
|
|
223
225
|
[$.arrow_function, $._primary_atom],
|
|
224
226
|
[$._primary_atom, $.await_expression],
|
|
225
227
|
[$.call_expression, $._constructor_import],
|
|
226
228
|
[$.primary_expression, $._assignment_call_primary],
|
|
227
229
|
[$._local_export_specifier, $._module_export_name],
|
|
228
230
|
[$.primary_expression, $.rest_pattern],
|
|
229
|
-
[$.primary_expression, $.
|
|
231
|
+
[$.primary_expression, $._non_rest_pattern],
|
|
230
232
|
[$.primary_expression, $.for_in_clause],
|
|
231
233
|
[$.array, $.array_pattern],
|
|
232
234
|
[$.object, $.object_pattern],
|
|
233
|
-
[$.assignment_expression, $.
|
|
235
|
+
[$.assignment_expression, $._non_rest_pattern],
|
|
234
236
|
],
|
|
235
237
|
|
|
236
238
|
word: ($) => $.identifier,
|
|
@@ -700,29 +702,23 @@ module.exports = grammar({
|
|
|
700
702
|
)
|
|
701
703
|
),
|
|
702
704
|
|
|
703
|
-
object_pattern: ($) =>
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
choice(
|
|
711
|
-
$.pair_pattern,
|
|
712
|
-
$.rest_pattern,
|
|
713
|
-
$.object_assignment_pattern,
|
|
714
|
-
aliasWithAsyncKeyword(
|
|
715
|
-
choice($.identifier, $._reserved_identifier),
|
|
716
|
-
sym('shorthand_property_identifier_pattern')
|
|
717
|
-
)
|
|
718
|
-
)
|
|
719
|
-
)
|
|
720
|
-
),
|
|
721
|
-
'}'
|
|
705
|
+
object_pattern: ($) => {
|
|
706
|
+
const property = choice(
|
|
707
|
+
$.pair_pattern,
|
|
708
|
+
$.object_assignment_pattern,
|
|
709
|
+
aliasWithAsyncKeyword(
|
|
710
|
+
choice($.identifier, $._reserved_identifier),
|
|
711
|
+
sym('shorthand_property_identifier_pattern')
|
|
722
712
|
)
|
|
723
|
-
)
|
|
713
|
+
);
|
|
714
|
+
return prec(
|
|
715
|
+
'object',
|
|
716
|
+
seq('{', repeat(seq(optional(property), ',')), optional(choice(property, $.rest_pattern)), '}')
|
|
717
|
+
);
|
|
718
|
+
},
|
|
724
719
|
|
|
725
|
-
assignment_pattern: ($) =>
|
|
720
|
+
assignment_pattern: ($) =>
|
|
721
|
+
seq(field('left', alias($._non_rest_pattern, $.pattern)), '=', field('right', $.expression)),
|
|
726
722
|
|
|
727
723
|
object_assignment_pattern: ($) =>
|
|
728
724
|
seq(
|
|
@@ -742,7 +738,13 @@ module.exports = grammar({
|
|
|
742
738
|
|
|
743
739
|
array: ($) => seq('[', commaSep(optional(choice($.expression, $.spread_element))), ']'),
|
|
744
740
|
|
|
745
|
-
array_pattern: ($) =>
|
|
741
|
+
array_pattern: ($) =>
|
|
742
|
+
seq(
|
|
743
|
+
'[',
|
|
744
|
+
repeat(seq(optional(choice(alias($._non_rest_pattern, $.pattern), $.assignment_pattern)), ',')),
|
|
745
|
+
optional(choice($.pattern, $.assignment_pattern)),
|
|
746
|
+
']'
|
|
747
|
+
),
|
|
746
748
|
|
|
747
749
|
_jsx_element: ($) => choice($.jsx_element, $.jsx_self_closing_element),
|
|
748
750
|
|
|
@@ -972,9 +974,10 @@ module.exports = grammar({
|
|
|
972
974
|
)
|
|
973
975
|
),
|
|
974
976
|
|
|
975
|
-
// Override
|
|
976
977
|
_call_signature: ($) => field('parameters', $.formal_parameters),
|
|
977
|
-
|
|
978
|
+
|
|
979
|
+
/** Ordinary, comma-permitted parameters. Overrides must exclude rest forms. */
|
|
980
|
+
_formal_parameter: ($) => choice(alias($._non_rest_pattern, $.pattern), $.assignment_pattern),
|
|
978
981
|
|
|
979
982
|
_call_callee: ($) => $.primary_expression,
|
|
980
983
|
|
|
@@ -1655,18 +1658,27 @@ module.exports = grammar({
|
|
|
1655
1658
|
_field_initializer: ($) =>
|
|
1656
1659
|
seq('=', sym('_sync_function_start'), field('value', $.expression), sym('_arrow_context_end')),
|
|
1657
1660
|
|
|
1658
|
-
formal_parameters: ($) =>
|
|
1661
|
+
formal_parameters: ($) =>
|
|
1662
|
+
seq(
|
|
1663
|
+
'(',
|
|
1664
|
+
repeat(seq($._formal_parameter, ',')),
|
|
1665
|
+
optional(choice($._formal_parameter, alias($._rest_pattern, $.pattern))),
|
|
1666
|
+
')'
|
|
1667
|
+
),
|
|
1659
1668
|
|
|
1660
1669
|
class_static_block: ($) => seq('static', field('body', alias($._class_member_body, $.statement_block))),
|
|
1661
1670
|
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1671
|
+
/**
|
|
1672
|
+
* Canonical pattern supertype. Extend `_non_rest_pattern` for non-rest forms and
|
|
1673
|
+
* `rest_pattern` for rest syntax; overriding only `pattern` does not extend ordinary slots.
|
|
1674
|
+
*/
|
|
1675
|
+
pattern: ($) => choice(alias($._non_rest_pattern, $.pattern), alias($._rest_pattern, $.pattern)),
|
|
1676
|
+
|
|
1677
|
+
// Prefer expression forms over both pattern routes during ambiguous error recovery.
|
|
1678
|
+
_non_rest_pattern: ($) =>
|
|
1679
|
+
prec.dynamic(-1, choice($._lhs_expression, alias($._parenthesized_simple_target, $.parenthesized_expression))),
|
|
1680
|
+
|
|
1681
|
+
_rest_pattern: ($) => prec.dynamic(-1, $.rest_pattern),
|
|
1670
1682
|
|
|
1671
1683
|
rest_pattern: ($) =>
|
|
1672
1684
|
prec.right(
|
|
@@ -1714,7 +1726,11 @@ module.exports = grammar({
|
|
|
1714
1726
|
pair: ($) => seq(field('key', $._property_name), ':', field('value', $.expression)),
|
|
1715
1727
|
|
|
1716
1728
|
pair_pattern: ($) =>
|
|
1717
|
-
seq(
|
|
1729
|
+
seq(
|
|
1730
|
+
field('key', $._property_name),
|
|
1731
|
+
':',
|
|
1732
|
+
field('value', choice(alias($._non_rest_pattern, $.pattern), $.assignment_pattern))
|
|
1733
|
+
),
|
|
1718
1734
|
|
|
1719
1735
|
_field_name: ($) =>
|
|
1720
1736
|
reserved(
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|