tree-sitter-java-orchard 0.5.4 → 0.5.6
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 +34 -29
- package/package.json +1 -1
- package/src/grammar.json +204 -333
- package/src/node-types.json +27 -1
- package/src/parser.c +47234 -46742
- package/tree-sitter-java_orchard.wasm +0 -0
- package/tree-sitter.json +1 -1
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(
|
|
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
|
|
|
@@ -73,6 +73,7 @@ module.exports = grammar({
|
|
|
73
73
|
],
|
|
74
74
|
|
|
75
75
|
conflicts: $ => [
|
|
76
|
+
[$.modifiers],
|
|
76
77
|
[$.modifiers, $.annotated_type, $.receiver_parameter],
|
|
77
78
|
[$.modifiers, $.annotated_type, $.module_declaration, $.package_declaration],
|
|
78
79
|
[$._unannotated_type, $.primary_expression, $.inferred_parameters],
|
|
@@ -129,21 +130,22 @@ module.exports = grammar({
|
|
|
129
130
|
|
|
130
131
|
octal_integer_literal: _ => token(seq(
|
|
131
132
|
choice('0o', '0O', '0'),
|
|
132
|
-
|
|
133
|
+
optional(/_+/),
|
|
134
|
+
sep1(/[0-7]+/, /_+/),
|
|
133
135
|
optional(choice('l', 'L')),
|
|
134
136
|
)),
|
|
135
137
|
|
|
136
138
|
binary_integer_literal: _ => token(seq(
|
|
137
139
|
choice('0b', '0B'),
|
|
138
|
-
sep1(/[01]+/,
|
|
140
|
+
sep1(/[01]+/, /_+/),
|
|
139
141
|
optional(choice('l', 'L')),
|
|
140
142
|
)),
|
|
141
143
|
|
|
142
144
|
decimal_floating_point_literal: _ => token(choice(
|
|
143
145
|
seq(DECIMAL_DIGITS, '.', optional(DECIMAL_DIGITS), optional(seq((/[eE]/), optional(choice('-', '+')), DECIMAL_DIGITS)), optional(/[fFdD]/)),
|
|
144
146
|
seq('.', DECIMAL_DIGITS, optional(seq((/[eE]/), optional(choice('-', '+')), DECIMAL_DIGITS)), optional(/[fFdD]/)),
|
|
145
|
-
seq(
|
|
146
|
-
seq(
|
|
147
|
+
seq(DECIMAL_DIGITS, /[eE]/, optional(choice('-', '+')), DECIMAL_DIGITS, optional(/[fFdD]/)),
|
|
148
|
+
seq(DECIMAL_DIGITS, optional(seq((/[eE]/), optional(choice('-', '+')), DECIMAL_DIGITS)), (/[fFdD]/)),
|
|
147
149
|
)),
|
|
148
150
|
|
|
149
151
|
hex_floating_point_literal: _ => token(seq(
|
|
@@ -155,7 +157,7 @@ module.exports = grammar({
|
|
|
155
157
|
optional(seq(
|
|
156
158
|
/[pP]/,
|
|
157
159
|
optional(choice('-', '+')),
|
|
158
|
-
|
|
160
|
+
DECIMAL_DIGITS,
|
|
159
161
|
optional(/[fFdD]/),
|
|
160
162
|
)),
|
|
161
163
|
)),
|
|
@@ -192,7 +194,7 @@ module.exports = grammar({
|
|
|
192
194
|
'"""',
|
|
193
195
|
repeat(choice(
|
|
194
196
|
alias($._multiline_string_fragment, $.multiline_string_fragment),
|
|
195
|
-
$.
|
|
197
|
+
$.escape_sequence,
|
|
196
198
|
$.string_interpolation,
|
|
197
199
|
)),
|
|
198
200
|
'"""',
|
|
@@ -213,10 +215,6 @@ module.exports = grammar({
|
|
|
213
215
|
'}',
|
|
214
216
|
),
|
|
215
217
|
|
|
216
|
-
_escape_sequence: $ => choice(
|
|
217
|
-
prec(2, token.immediate(seq('\\', /[^bfnrts'\"\\]/))),
|
|
218
|
-
prec(1, $.escape_sequence),
|
|
219
|
-
),
|
|
220
218
|
escape_sequence: _ => token.immediate(seq(
|
|
221
219
|
choice('\\', /\\u+005[cC]/),
|
|
222
220
|
choice(
|
|
@@ -255,7 +253,13 @@ module.exports = grammar({
|
|
|
255
253
|
'(',
|
|
256
254
|
sep1(field('type', $._type), '&'),
|
|
257
255
|
')',
|
|
258
|
-
field('value', choice(
|
|
256
|
+
field('value', choice(
|
|
257
|
+
$.primary_expression,
|
|
258
|
+
alias($._unary_complement_expression, $.unary_expression),
|
|
259
|
+
$.cast_expression,
|
|
260
|
+
$.switch_expression,
|
|
261
|
+
$.lambda_expression,
|
|
262
|
+
)),
|
|
259
263
|
),
|
|
260
264
|
)),
|
|
261
265
|
|
|
@@ -303,10 +307,10 @@ module.exports = grammar({
|
|
|
303
307
|
instanceof_expression: $ => prec(PREC.REL, seq(
|
|
304
308
|
field('left', $.expression),
|
|
305
309
|
'instanceof',
|
|
306
|
-
optional(
|
|
310
|
+
optional($.modifiers),
|
|
307
311
|
choice(
|
|
308
312
|
seq(
|
|
309
|
-
field('right', $.
|
|
313
|
+
field('right', $._unannotated_type),
|
|
310
314
|
optional(field('name', choice($.identifier, $._reserved_identifier))),
|
|
311
315
|
),
|
|
312
316
|
field('pattern', $.record_pattern),
|
|
@@ -335,17 +339,17 @@ module.exports = grammar({
|
|
|
335
339
|
field('alternative', $.expression),
|
|
336
340
|
)),
|
|
337
341
|
|
|
338
|
-
unary_expression: $ => choice(
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
['~', PREC.UNARY],
|
|
343
|
-
].map(([operator, precedence]) =>
|
|
344
|
-
prec.left(precedence, seq(
|
|
345
|
-
// @ts-ignore
|
|
346
|
-
field('operator', operator),
|
|
342
|
+
unary_expression: $ => choice(
|
|
343
|
+
$._unary_complement_expression,
|
|
344
|
+
prec.right(PREC.UNARY, seq(
|
|
345
|
+
field('operator', choice('+', '-')),
|
|
347
346
|
field('operand', $.expression),
|
|
348
347
|
)),
|
|
348
|
+
),
|
|
349
|
+
|
|
350
|
+
_unary_complement_expression: $ => prec.right(PREC.UNARY, seq(
|
|
351
|
+
field('operator', choice('~', '!')),
|
|
352
|
+
field('operand', $.expression),
|
|
349
353
|
)),
|
|
350
354
|
|
|
351
355
|
update_expression: $ => prec.left(PREC.UNARY, choice(
|
|
@@ -525,12 +529,13 @@ module.exports = grammar({
|
|
|
525
529
|
$.type_pattern,
|
|
526
530
|
$.record_pattern,
|
|
527
531
|
),
|
|
528
|
-
type_pattern: $ => seq($._unannotated_type, choice($.identifier, $._reserved_identifier)),
|
|
529
|
-
record_pattern: $ => seq(choice($.identifier, $._reserved_identifier, $.generic_type), $.record_pattern_body),
|
|
532
|
+
type_pattern: $ => seq(optional($.modifiers), $._unannotated_type, choice($.identifier, $._reserved_identifier)),
|
|
533
|
+
record_pattern: $ => seq(choice($.identifier, $._reserved_identifier, $.generic_type, $.scoped_type_identifier), $.record_pattern_body),
|
|
530
534
|
record_pattern_body: $ => seq('(', commaSep(choice($.record_pattern_component, $.record_pattern)), ')'),
|
|
531
535
|
record_pattern_component: $ => choice(
|
|
532
536
|
$.underscore_pattern,
|
|
533
537
|
seq(
|
|
538
|
+
optional($.modifiers),
|
|
534
539
|
$._unannotated_type,
|
|
535
540
|
choice($.identifier, $._reserved_identifier),
|
|
536
541
|
),
|
|
@@ -1002,8 +1007,7 @@ module.exports = grammar({
|
|
|
1002
1007
|
|
|
1003
1008
|
constructor_body: $ => seq(
|
|
1004
1009
|
'{',
|
|
1005
|
-
|
|
1006
|
-
repeat($.statement),
|
|
1010
|
+
repeat(choice($.explicit_constructor_invocation, $.statement)),
|
|
1007
1011
|
'}',
|
|
1008
1012
|
),
|
|
1009
1013
|
|
|
@@ -1068,6 +1072,7 @@ module.exports = grammar({
|
|
|
1068
1072
|
$.class_declaration,
|
|
1069
1073
|
$.interface_declaration,
|
|
1070
1074
|
$.enum_declaration,
|
|
1075
|
+
$.record_declaration,
|
|
1071
1076
|
$.annotation_type_declaration,
|
|
1072
1077
|
';',
|
|
1073
1078
|
)),
|