@willbooster/tree-sitter-java 8.0.2 → 9.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 CHANGED
@@ -19,6 +19,7 @@ pattern variables use `underscore_pattern` nodes. Binding annotations are direct
19
19
  annotations inside the `right` field's `annotated_type` node.
20
20
 
21
21
  Annotation interface declarations expose separate `@` and `interface` tokens.
22
+ Postfix updates appear inside surrounding cast or unary nodes. An `update_expression` has a primary expression as its operand.
22
23
 
23
24
  The parser ships as compact tables under the [WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter)
24
25
  fork's ABI (`0x57420007`). This package is tested with runtime 9.0.0. Runtimes with a different ABI, including
@@ -86,7 +87,7 @@ fuzzed with:
86
87
  ```toml
87
88
  [dependencies]
88
89
  tree-sitter = { package = "willbooster-tree-sitter", version = "9.0.0" }
89
- tree-sitter-java = { package = "willbooster-tree-sitter-java", version = "8" }
90
+ tree-sitter-java = { package = "willbooster-tree-sitter-java", version = "9" }
90
91
  ```
91
92
 
92
93
  ```rust
package/grammar.js CHANGED
@@ -326,7 +326,7 @@ module.exports = grammar({
326
326
  $.switch_expression,
327
327
  ),
328
328
 
329
- cast_expression: $ => prec(PREC.CAST, choice(
329
+ cast_expression: $ => prec.right(PREC.CAST, choice(
330
330
  seq(
331
331
  '(',
332
332
  field('type', $._type),
@@ -337,7 +337,14 @@ module.exports = grammar({
337
337
  '(',
338
338
  sep1(field('type', $._type), '&'),
339
339
  ')',
340
- field('value', choice($.primary_expression, $.lambda_expression)),
340
+ field('value', choice(
341
+ $.primary_expression,
342
+ alias($._postfix_update_expression, $.update_expression),
343
+ alias($._unary_complement_expression, $.unary_expression),
344
+ $.cast_expression,
345
+ $.switch_expression,
346
+ $.lambda_expression,
347
+ )),
341
348
  ),
342
349
  )),
343
350
 
@@ -419,24 +426,30 @@ module.exports = grammar({
419
426
  field('alternative', $.expression),
420
427
  )),
421
428
 
422
- unary_expression: $ => choice(...[
423
- ['+', PREC.UNARY],
424
- ['-', PREC.UNARY],
425
- ['!', PREC.UNARY],
426
- ['~', PREC.UNARY],
427
- ].map(([operator, precedence]) =>
428
- prec.left(precedence, seq(
429
- // @ts-ignore
430
- field('operator', operator),
429
+ unary_expression: $ => choice(
430
+ $._unary_complement_expression,
431
+ prec.left(PREC.UNARY, seq(
432
+ field('operator', choice('+', '-')),
431
433
  field('operand', $.expression),
432
434
  )),
435
+ ),
436
+
437
+ _unary_complement_expression: $ => prec.left(PREC.UNARY, seq(
438
+ field('operator', choice('~', '!')),
439
+ field('operand', $.expression),
433
440
  )),
434
441
 
435
- update_expression: $ => prec.left(PREC.UNARY, choice(
436
- seq($.expression, '++'),
437
- seq($.expression, '--'),
438
- seq('++', $.expression),
439
- seq('--', $.expression),
442
+ update_expression: $ => choice(
443
+ $._postfix_update_expression,
444
+ prec.right(PREC.UNARY, choice(
445
+ seq('++', $.primary_expression),
446
+ seq('--', $.primary_expression),
447
+ )),
448
+ ),
449
+
450
+ _postfix_update_expression: $ => prec.right(PREC.UNARY, choice(
451
+ seq($.primary_expression, '++'),
452
+ seq($.primary_expression, '--'),
440
453
  )),
441
454
 
442
455
  primary_expression: $ => choice(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-java",
3
- "version": "8.0.2",
3
+ "version": "9.0.0",
4
4
  "description": "Java grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -4046,7 +4046,7 @@
4046
4046
  "required": true,
4047
4047
  "types": [
4048
4048
  {
4049
- "type": "expression",
4049
+ "type": "primary_expression",
4050
4050
  "named": true
4051
4051
  }
4052
4052
  ]
Binary file
package/tree-sitter.json CHANGED
@@ -14,7 +14,7 @@
14
14
  }
15
15
  ],
16
16
  "metadata": {
17
- "version": "8.0.2",
17
+ "version": "9.0.0",
18
18
  "license": "MIT",
19
19
  "description": "Java grammar for tree-sitter",
20
20
  "authors": [