@willbooster/tree-sitter-java 8.0.3 → 9.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/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
@@ -14,6 +14,7 @@ const DIGITS = token(choice('0', seq(/[1-9]/, optional(seq(optional(/_+/), DECIM
14
14
  const HEX_DIGITS = token(sep1(/[A-Fa-f0-9]+/, /_+/));
15
15
 
16
16
  const PREC = {
17
+ LAMBDA: -1,
17
18
  // https://introcs.cs.princeton.edu/java/11precedence/
18
19
  COMMENT: 0,
19
20
  ASSIGN: 1,
@@ -82,7 +83,6 @@ module.exports = grammar({
82
83
  [$._unannotated_type, $.generic_type],
83
84
  [$.generic_type, $.primary_expression],
84
85
  [$.expression, $.statement],
85
- [$.lambda_expression, $.primary_expression],
86
86
  [$.inferred_parameters, $.primary_expression],
87
87
  [$.argument_list, $.record_pattern_body],
88
88
  [$.yield_statement, $._reserved_identifier],
@@ -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),
@@ -339,6 +339,7 @@ module.exports = grammar({
339
339
  ')',
340
340
  field('value', choice(
341
341
  $.primary_expression,
342
+ alias($._postfix_update_expression, $.update_expression),
342
343
  alias($._unary_complement_expression, $.unary_expression),
343
344
  $.cast_expression,
344
345
  $.switch_expression,
@@ -403,13 +404,13 @@ module.exports = grammar({
403
404
  ),
404
405
  )),
405
406
 
406
- lambda_expression: $ => seq(
407
+ lambda_expression: $ => prec(PREC.LAMBDA, seq(
407
408
  field('parameters', choice(
408
409
  $.identifier, $.formal_parameters, $.inferred_parameters, $._reserved_identifier, $.underscore_pattern,
409
410
  )),
410
411
  '->',
411
412
  field('body', choice($.expression, $.block)),
412
- ),
413
+ )),
413
414
 
414
415
  inferred_parameters: $ => seq(
415
416
  '(',
@@ -438,11 +439,17 @@ module.exports = grammar({
438
439
  field('operand', $.expression),
439
440
  )),
440
441
 
441
- update_expression: $ => prec.left(PREC.UNARY, choice(
442
- seq($.expression, '++'),
443
- seq($.expression, '--'),
444
- seq('++', $.expression),
445
- 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, '--'),
446
453
  )),
447
454
 
448
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.3",
3
+ "version": "9.0.1",
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.3",
17
+ "version": "9.0.1",
18
18
  "license": "MIT",
19
19
  "description": "Java grammar for tree-sitter",
20
20
  "authors": [