tree-sitter-java-orchard 0.5.4 → 0.5.5

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
@@ -9,9 +9,9 @@
9
9
  /// <reference types="tree-sitter-cli/dsl" />
10
10
  // @ts-check
11
11
 
12
- const DIGITS = token(choice('0', seq(/[1-9]/, optional(seq(optional('_'), sep1(/[0-9]+/, /_+/))))));
13
- const DECIMAL_DIGITS = token(sep1(/[0-9]+/, '_'));
14
- const HEX_DIGITS = token(sep1(/[A-Fa-f0-9]+/, '_'));
12
+ const DIGITS = token(choice('0', seq(/[1-9]/, optional(seq(optional(/_+/), sep1(/[0-9]+/, /_+/))))));
13
+ const DECIMAL_DIGITS = token(sep1(/[0-9]+/, /_+/));
14
+ const HEX_DIGITS = token(sep1(/[A-Fa-f0-9]+/, /_+/));
15
15
 
16
16
  /* eslint-disable no-multi-spaces */
17
17
 
@@ -129,21 +129,22 @@ module.exports = grammar({
129
129
 
130
130
  octal_integer_literal: _ => token(seq(
131
131
  choice('0o', '0O', '0'),
132
- sep1(/[0-7]+/, '_'),
132
+ optional(/_+/),
133
+ sep1(/[0-7]+/, /_+/),
133
134
  optional(choice('l', 'L')),
134
135
  )),
135
136
 
136
137
  binary_integer_literal: _ => token(seq(
137
138
  choice('0b', '0B'),
138
- sep1(/[01]+/, '_'),
139
+ sep1(/[01]+/, /_+/),
139
140
  optional(choice('l', 'L')),
140
141
  )),
141
142
 
142
143
  decimal_floating_point_literal: _ => token(choice(
143
144
  seq(DECIMAL_DIGITS, '.', optional(DECIMAL_DIGITS), optional(seq((/[eE]/), optional(choice('-', '+')), DECIMAL_DIGITS)), optional(/[fFdD]/)),
144
145
  seq('.', DECIMAL_DIGITS, optional(seq((/[eE]/), optional(choice('-', '+')), DECIMAL_DIGITS)), optional(/[fFdD]/)),
145
- seq(DIGITS, /[eE]/, optional(choice('-', '+')), DECIMAL_DIGITS, optional(/[fFdD]/)),
146
- seq(DIGITS, optional(seq((/[eE]/), optional(choice('-', '+')), DECIMAL_DIGITS)), (/[fFdD]/)),
146
+ seq(DECIMAL_DIGITS, /[eE]/, optional(choice('-', '+')), DECIMAL_DIGITS, optional(/[fFdD]/)),
147
+ seq(DECIMAL_DIGITS, optional(seq((/[eE]/), optional(choice('-', '+')), DECIMAL_DIGITS)), (/[fFdD]/)),
147
148
  )),
148
149
 
149
150
  hex_floating_point_literal: _ => token(seq(
@@ -155,7 +156,7 @@ module.exports = grammar({
155
156
  optional(seq(
156
157
  /[pP]/,
157
158
  optional(choice('-', '+')),
158
- DIGITS,
159
+ DECIMAL_DIGITS,
159
160
  optional(/[fFdD]/),
160
161
  )),
161
162
  )),
@@ -192,7 +193,7 @@ module.exports = grammar({
192
193
  '"""',
193
194
  repeat(choice(
194
195
  alias($._multiline_string_fragment, $.multiline_string_fragment),
195
- $._escape_sequence,
196
+ $.escape_sequence,
196
197
  $.string_interpolation,
197
198
  )),
198
199
  '"""',
@@ -213,10 +214,6 @@ module.exports = grammar({
213
214
  '}',
214
215
  ),
215
216
 
216
- _escape_sequence: $ => choice(
217
- prec(2, token.immediate(seq('\\', /[^bfnrts'\"\\]/))),
218
- prec(1, $.escape_sequence),
219
- ),
220
217
  escape_sequence: _ => token.immediate(seq(
221
218
  choice('\\', /\\u+005[cC]/),
222
219
  choice(
@@ -255,7 +252,13 @@ module.exports = grammar({
255
252
  '(',
256
253
  sep1(field('type', $._type), '&'),
257
254
  ')',
258
- field('value', choice($.primary_expression, $.lambda_expression)),
255
+ field('value', choice(
256
+ $.primary_expression,
257
+ alias($._unary_complement_expression, $.unary_expression),
258
+ $.cast_expression,
259
+ $.switch_expression,
260
+ $.lambda_expression,
261
+ )),
259
262
  ),
260
263
  )),
261
264
 
@@ -335,17 +338,17 @@ module.exports = grammar({
335
338
  field('alternative', $.expression),
336
339
  )),
337
340
 
338
- unary_expression: $ => choice(...[
339
- ['+', PREC.UNARY],
340
- ['-', PREC.UNARY],
341
- ['!', PREC.UNARY],
342
- ['~', PREC.UNARY],
343
- ].map(([operator, precedence]) =>
344
- prec.left(precedence, seq(
345
- // @ts-ignore
346
- field('operator', operator),
341
+ unary_expression: $ => choice(
342
+ $._unary_complement_expression,
343
+ prec.right(PREC.UNARY, seq(
344
+ field('operator', choice('+', '-')),
347
345
  field('operand', $.expression),
348
346
  )),
347
+ ),
348
+
349
+ _unary_complement_expression: $ => prec.right(PREC.UNARY, seq(
350
+ field('operator', choice('~', '!')),
351
+ field('operand', $.expression),
349
352
  )),
350
353
 
351
354
  update_expression: $ => prec.left(PREC.UNARY, choice(
@@ -526,11 +529,12 @@ module.exports = grammar({
526
529
  $.record_pattern,
527
530
  ),
528
531
  type_pattern: $ => seq($._unannotated_type, choice($.identifier, $._reserved_identifier)),
529
- record_pattern: $ => seq(choice($.identifier, $._reserved_identifier, $.generic_type), $.record_pattern_body),
532
+ record_pattern: $ => seq(choice($.identifier, $._reserved_identifier, $.generic_type, $.scoped_type_identifier), $.record_pattern_body),
530
533
  record_pattern_body: $ => seq('(', commaSep(choice($.record_pattern_component, $.record_pattern)), ')'),
531
534
  record_pattern_component: $ => choice(
532
535
  $.underscore_pattern,
533
536
  seq(
537
+ optional($.modifiers),
534
538
  $._unannotated_type,
535
539
  choice($.identifier, $._reserved_identifier),
536
540
  ),
@@ -1002,8 +1006,7 @@ module.exports = grammar({
1002
1006
 
1003
1007
  constructor_body: $ => seq(
1004
1008
  '{',
1005
- optional($.explicit_constructor_invocation),
1006
- repeat($.statement),
1009
+ repeat(choice($.explicit_constructor_invocation, $.statement)),
1007
1010
  '}',
1008
1011
  ),
1009
1012
 
@@ -1068,6 +1071,7 @@ module.exports = grammar({
1068
1071
  $.class_declaration,
1069
1072
  $.interface_declaration,
1070
1073
  $.enum_declaration,
1074
+ $.record_declaration,
1071
1075
  $.annotation_type_declaration,
1072
1076
  ';',
1073
1077
  )),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tree-sitter-java-orchard",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "Java grammar for tree-sitter",
5
5
  "repository": "https://codeberg.org/grammar-orchard/tree-sitter-java-orchard",
6
6
  "license": "MIT",