Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pattern variables use `underscore_pattern` nodes. Binding annotations are direct
annotations inside the `right` field's `annotated_type` node.

Annotation interface declarations expose separate `@` and `interface` tokens.
Postfix updates appear inside surrounding cast or unary nodes. An `update_expression` has a primary expression as its operand.

The parser ships as compact tables under the [WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter)
fork's ABI (`0x57420007`). This package is tested with runtime 9.0.0. Runtimes with a different ABI, including
Expand Down Expand Up @@ -86,7 +87,7 @@ fuzzed with:
```toml
[dependencies]
tree-sitter = { package = "willbooster-tree-sitter", version = "9.0.0" }
tree-sitter-java = { package = "willbooster-tree-sitter-java", version = "8" }
tree-sitter-java = { package = "willbooster-tree-sitter-java", version = "9" }
```

```rust
Expand Down
19 changes: 13 additions & 6 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ module.exports = grammar({
$.switch_expression,
),

cast_expression: $ => prec(PREC.CAST, choice(
cast_expression: $ => prec.right(PREC.CAST, choice(
seq(
'(',
field('type', $._type),
Expand All @@ -339,6 +339,7 @@ module.exports = grammar({
')',
field('value', choice(
$.primary_expression,
alias($._postfix_update_expression, $.update_expression),
alias($._unary_complement_expression, $.unary_expression),
$.cast_expression,
$.switch_expression,
Expand Down Expand Up @@ -438,11 +439,17 @@ module.exports = grammar({
field('operand', $.expression),
)),

update_expression: $ => prec.left(PREC.UNARY, choice(
seq($.expression, '++'),
seq($.expression, '--'),
seq('++', $.expression),
seq('--', $.expression),
update_expression: $ => choice(
$._postfix_update_expression,
prec.right(PREC.UNARY, choice(
seq('++', $.primary_expression),
seq('--', $.primary_expression),
)),
),

_postfix_update_expression: $ => prec.right(PREC.UNARY, choice(
seq($.primary_expression, '++'),
seq($.primary_expression, '--'),
)),

primary_expression: $ => choice(
Expand Down
87 changes: 57 additions & 30 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading