@willbooster/tree-sitter-javascript 13.0.0 → 14.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 CHANGED
@@ -152,6 +152,10 @@ module.exports = grammar({
152
152
  $._assignment_call_callee,
153
153
  $._call_callee,
154
154
  $._assignment_call_primary,
155
+ $._simple_target_expression,
156
+ $._simple_target_primary,
157
+ $._call_target_expression,
158
+ $._call_target_primary,
155
159
  ],
156
160
 
157
161
  inline: ($) => [
@@ -209,15 +213,13 @@ module.exports = grammar({
209
213
  ],
210
214
 
211
215
  conflicts: ($) => [
216
+ [$._primary_atom, $._simple_target_primary],
217
+ [$._simple_target_primary, $.pattern],
218
+ [$._primary_atom, $._simple_target_primary, $.pattern],
212
219
  [$._call_callee, $.call_expression],
213
220
  [$.for_in_clause, $._primary_atom],
214
221
  [$._primary_atom, $.rest_pattern],
215
222
  [$._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
223
  [$.arrow_function, $._primary_atom],
222
224
  [$._primary_atom, $.await_expression],
223
225
  [$.call_expression, $._constructor_import],
@@ -229,8 +231,6 @@ module.exports = grammar({
229
231
  [$.array, $.array_pattern],
230
232
  [$.object, $.object_pattern],
231
233
  [$.assignment_expression, $.pattern],
232
- [$.assignment_expression, $.object_assignment_pattern],
233
- [$.computed_property_name, $.array],
234
234
  ],
235
235
 
236
236
  word: ($) => $.identifier,
@@ -442,7 +442,7 @@ module.exports = grammar({
442
442
  optional($._initializer)
443
443
  ),
444
444
 
445
- statement_block: ($) => prec.right(seq('{', repeat($._statement), '}')),
445
+ statement_block: ($) => prec.right(seq(token(prec(1, '{')), repeat($._statement), '}')),
446
446
 
447
447
  else_clause: ($) => seq('else', $._single_statement),
448
448
 
@@ -516,7 +516,14 @@ module.exports = grammar({
516
516
  choice(
517
517
  seq(
518
518
  choice(
519
- field('left', choice($._lhs_expression, $.parenthesized_expression)),
519
+ field(
520
+ 'left',
521
+ choice(
522
+ $._lhs_expression,
523
+ alias($._parenthesized_simple_target, $.parenthesized_expression),
524
+ alias($._parenthesized_call_target, $.parenthesized_expression)
525
+ )
526
+ ),
520
527
  seq(
521
528
  field('kind', 'var'),
522
529
  field('left', choice($.identifier, alias('of', $.identifier), $._destructuring_pattern)),
@@ -1239,13 +1246,43 @@ module.exports = grammar({
1239
1246
  $._destructuring_pattern
1240
1247
  ),
1241
1248
 
1249
+ _simple_target_expression: ($) => alias($._simple_target_primary, $.primary_expression),
1250
+
1251
+ _simple_target_primary: ($) =>
1252
+ choice(
1253
+ $._identifier,
1254
+ alias(sym('_await_yield_identifier'), $.identifier),
1255
+ aliasWithAsyncKeyword($._reserved_identifier, $.identifier),
1256
+ alias($._assignment_member, $.member_expression),
1257
+ alias($._assignment_subscript, $.subscript_expression),
1258
+ alias($._parenthesized_simple_target, $.parenthesized_expression)
1259
+ ),
1260
+
1261
+ _parenthesized_simple_target: ($) => seq('(', alias($._simple_target_expression, $.expression), ')'),
1262
+
1263
+ _call_target_expression: ($) => alias($._call_target_primary, $.primary_expression),
1264
+
1265
+ _call_target_primary: ($) => $._classic_call_target,
1266
+
1267
+ _parenthesized_call_target: ($) => seq('(', alias($._call_target_expression, $.expression), ')'),
1268
+
1269
+ _classic_call_target: ($) =>
1270
+ choice(
1271
+ alias($._assignment_call, $.call_expression),
1272
+ alias($._parenthesized_call_target, $.parenthesized_expression)
1273
+ ),
1274
+
1242
1275
  assignment_expression: ($) =>
1243
1276
  prec.right(
1244
1277
  'assign',
1245
1278
  seq(
1246
1279
  field(
1247
1280
  'left',
1248
- choice($.parenthesized_expression, $._lhs_expression, alias($._assignment_call, $.call_expression))
1281
+ choice(
1282
+ alias($._parenthesized_simple_target, $.parenthesized_expression),
1283
+ $._lhs_expression,
1284
+ $._classic_call_target
1285
+ )
1249
1286
  ),
1250
1287
  '=',
1251
1288
  field('right', $.expression)
@@ -1258,7 +1295,7 @@ module.exports = grammar({
1258
1295
  $.subscript_expression,
1259
1296
  aliasWithAsyncKeyword($._reserved_identifier, $.identifier),
1260
1297
  $._identifier,
1261
- $.parenthesized_expression
1298
+ alias($._parenthesized_simple_target, $.parenthesized_expression)
1262
1299
  ),
1263
1300
 
1264
1301
  augmented_assignment_expression: ($) =>
@@ -1270,10 +1307,7 @@ module.exports = grammar({
1270
1307
  field('left', $._augmented_assignment_lhs),
1271
1308
  field('operator', choice(...CLASSIC_ASSIGNMENT_OPERATORS, '&&=', '||=', '??='))
1272
1309
  ),
1273
- seq(
1274
- field('left', alias($._assignment_call, $.call_expression)),
1275
- field('operator', choice(...CLASSIC_ASSIGNMENT_OPERATORS))
1276
- )
1310
+ seq(field('left', $._classic_call_target), field('operator', choice(...CLASSIC_ASSIGNMENT_OPERATORS)))
1277
1311
  ),
1278
1312
  field('right', $.expression)
1279
1313
  )
@@ -1628,9 +1662,16 @@ module.exports = grammar({
1628
1662
  // This negative dynamic precedence ensures that during error recovery,
1629
1663
  // unfinished constructs are generally treated as literal expressions,
1630
1664
  // not patterns.
1631
- pattern: ($) => prec.dynamic(-1, choice($._lhs_expression, $.parenthesized_expression, $.rest_pattern)),
1665
+ pattern: ($) =>
1666
+ prec.dynamic(
1667
+ -1,
1668
+ choice($._lhs_expression, alias($._parenthesized_simple_target, $.parenthesized_expression), $.rest_pattern)
1669
+ ),
1632
1670
 
1633
- rest_pattern: ($) => prec.right(seq('...', choice($._lhs_expression, $.parenthesized_expression))),
1671
+ rest_pattern: ($) =>
1672
+ prec.right(
1673
+ seq('...', choice($._lhs_expression, alias($._parenthesized_simple_target, $.parenthesized_expression)))
1674
+ ),
1634
1675
 
1635
1676
  method_definition: ($) =>
1636
1677
  functionContext((async) =>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-javascript",
3
- "version": "13.0.0",
3
+ "version": "14.0.1",
4
4
  "description": "JavaScript grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
Binary file
Binary file
package/tree-sitter.json CHANGED
@@ -48,7 +48,7 @@
48
48
  }
49
49
  ],
50
50
  "metadata": {
51
- "version": "13.0.0",
51
+ "version": "14.0.1",
52
52
  "license": "MIT",
53
53
  "description": "JavaScript grammar for tree-sitter",
54
54
  "authors": [