@willbooster/tree-sitter-java 3.1.0 → 3.1.2
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 +132 -26
- package/package.json +1 -1
- package/src/node-types.json +12 -0
- package/tree-sitter-java.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -80,7 +80,6 @@ module.exports = grammar({
|
|
|
80
80
|
[$.modifiers, $.annotated_type, $.module_declaration, $.package_declaration],
|
|
81
81
|
[$._unannotated_type, $.primary_expression, $.inferred_parameters],
|
|
82
82
|
[$._unannotated_type, $.primary_expression],
|
|
83
|
-
[$._unannotated_type, $.primary_expression, $.scoped_type_identifier],
|
|
84
83
|
[$._unannotated_type, $.scoped_type_identifier],
|
|
85
84
|
[$._unannotated_type, $.generic_type],
|
|
86
85
|
[$.generic_type, $.primary_expression],
|
|
@@ -90,8 +89,70 @@ module.exports = grammar({
|
|
|
90
89
|
[$.inferred_parameters, $.primary_expression],
|
|
91
90
|
[$.argument_list, $.record_pattern_body],
|
|
92
91
|
[$.yield_statement, $._reserved_identifier],
|
|
92
|
+
[$.scoped_identifier, $.scoped_type_identifier],
|
|
93
|
+
[$.primary_expression, $.method_reference, $.scoped_identifier],
|
|
94
|
+
[$.primary_expression, $.method_reference, $.scoped_identifier, $._unannotated_type, $.scoped_type_identifier],
|
|
93
95
|
],
|
|
94
96
|
|
|
97
|
+
reserved: {
|
|
98
|
+
global: $ => [
|
|
99
|
+
'abstract',
|
|
100
|
+
'assert',
|
|
101
|
+
'boolean',
|
|
102
|
+
'break',
|
|
103
|
+
'byte',
|
|
104
|
+
'case',
|
|
105
|
+
'catch',
|
|
106
|
+
'char',
|
|
107
|
+
'class',
|
|
108
|
+
$._const,
|
|
109
|
+
'continue',
|
|
110
|
+
'default',
|
|
111
|
+
'do',
|
|
112
|
+
'double',
|
|
113
|
+
'else',
|
|
114
|
+
'enum',
|
|
115
|
+
'extends',
|
|
116
|
+
'final',
|
|
117
|
+
'finally',
|
|
118
|
+
'float',
|
|
119
|
+
'for',
|
|
120
|
+
$._goto,
|
|
121
|
+
'if',
|
|
122
|
+
'implements',
|
|
123
|
+
'import',
|
|
124
|
+
'instanceof',
|
|
125
|
+
'int',
|
|
126
|
+
'interface',
|
|
127
|
+
'long',
|
|
128
|
+
'native',
|
|
129
|
+
'new',
|
|
130
|
+
'package',
|
|
131
|
+
'private',
|
|
132
|
+
'protected',
|
|
133
|
+
'public',
|
|
134
|
+
'return',
|
|
135
|
+
'short',
|
|
136
|
+
'static',
|
|
137
|
+
'strictfp',
|
|
138
|
+
$.super,
|
|
139
|
+
'switch',
|
|
140
|
+
'synchronized',
|
|
141
|
+
$.this,
|
|
142
|
+
'throw',
|
|
143
|
+
'throws',
|
|
144
|
+
'transient',
|
|
145
|
+
'try',
|
|
146
|
+
'void',
|
|
147
|
+
'volatile',
|
|
148
|
+
'while',
|
|
149
|
+
$.underscore_pattern,
|
|
150
|
+
$.true,
|
|
151
|
+
$.false,
|
|
152
|
+
$.null_literal,
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
|
|
95
156
|
word: $ => $.identifier,
|
|
96
157
|
|
|
97
158
|
rules: {
|
|
@@ -164,15 +225,41 @@ module.exports = grammar({
|
|
|
164
225
|
|
|
165
226
|
false: _ => 'false',
|
|
166
227
|
|
|
167
|
-
character_literal: _ =>
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
228
|
+
character_literal: _ => {
|
|
229
|
+
const incompleteUnicode = /\\u+[0-9a-fA-F]{0,3}/;
|
|
230
|
+
const malformedUnicode = /\\u+([0-9a-fA-F]{1,3}[^0-9a-fA-F\\'\n]|[^0-9a-fA-Fu\\'\n])/;
|
|
231
|
+
const encodedBackslash = /\\u+005[cC]/;
|
|
232
|
+
const unicodeCharacter = /\\u+([1-9a-fA-F][0-9a-fA-F]{3}|0[1-9a-fA-F][0-9a-fA-F]{2}|00[0-46-9a-fA-F][0-9a-fA-F]|005[0-9abd-fABD-F])/;
|
|
233
|
+
const plainCharacter = /[^\\'\n]/;
|
|
234
|
+
const rawEscape = /\\[^u]/;
|
|
235
|
+
const boundedEscape = choice(
|
|
236
|
+
malformedUnicode,
|
|
237
|
+
rawEscape,
|
|
238
|
+
unicodeCharacter,
|
|
239
|
+
seq(encodedBackslash, choice(encodedBackslash, /[^'\n]/, /\n/)),
|
|
240
|
+
);
|
|
241
|
+
const boundedTail = seq(
|
|
242
|
+
repeat(choice(
|
|
243
|
+
plainCharacter,
|
|
244
|
+
seq(repeat(incompleteUnicode), boundedEscape),
|
|
245
|
+
)),
|
|
246
|
+
repeat(incompleteUnicode),
|
|
247
|
+
optional(encodedBackslash),
|
|
248
|
+
);
|
|
249
|
+
const character = choice(
|
|
250
|
+
plainCharacter,
|
|
251
|
+
rawEscape,
|
|
252
|
+
unicodeCharacter,
|
|
253
|
+
seq(encodedBackslash, choice(encodedBackslash, /./, /\n/)),
|
|
254
|
+
);
|
|
255
|
+
return token(seq('\'', choice(
|
|
256
|
+
repeat1(character),
|
|
257
|
+
seq(repeat(character), repeat1(incompleteUnicode)),
|
|
258
|
+
seq(repeat(character), malformedUnicode, boundedTail),
|
|
259
|
+
seq(repeat(character), repeat1(incompleteUnicode), boundedEscape, boundedTail),
|
|
260
|
+
seq(repeat(character), repeat1(incompleteUnicode), encodedBackslash),
|
|
261
|
+
), '\''));
|
|
262
|
+
},
|
|
176
263
|
|
|
177
264
|
string_literal: $ => choice($._string_literal, $._multiline_string_literal),
|
|
178
265
|
_string_literal: $ => seq(
|
|
@@ -213,15 +300,23 @@ module.exports = grammar({
|
|
|
213
300
|
prec(2, token.immediate(seq('\\', /[^bfnrts'\"\\]/))),
|
|
214
301
|
prec(1, $.escape_sequence),
|
|
215
302
|
),
|
|
216
|
-
escape_sequence: _ => token.immediate(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
/[
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
303
|
+
escape_sequence: _ => token.immediate(choice(
|
|
304
|
+
seq(/\\u+005[cC]/, choice(
|
|
305
|
+
/(?:[0-3]|\\u+003[0-3])(?:[0-7]|\\u+003[0-7]){0,2}/,
|
|
306
|
+
/(?:[4-7]|\\u+003[4-7])(?:[0-7]|\\u+003[0-7])?/,
|
|
307
|
+
/\\u+[0-9a-fA-F]{4}/,
|
|
308
|
+
)),
|
|
309
|
+
seq(
|
|
310
|
+
choice('\\', /\\u+005[cC]/),
|
|
311
|
+
choice(
|
|
312
|
+
/[^xu0-7]/,
|
|
313
|
+
/(?:[0-3][0-7]{0,2}|[4-7][0-7]?)/,
|
|
314
|
+
/x[0-9a-fA-F]{2}/,
|
|
315
|
+
/u+[0-9a-fA-F]{4}/,
|
|
316
|
+
/u\{[0-9a-fA-F]+\}/,
|
|
317
|
+
),
|
|
318
|
+
),
|
|
319
|
+
)),
|
|
225
320
|
|
|
226
321
|
null_literal: _ => 'null',
|
|
227
322
|
|
|
@@ -309,7 +404,7 @@ module.exports = grammar({
|
|
|
309
404
|
|
|
310
405
|
lambda_expression: $ => seq(
|
|
311
406
|
field('parameters', choice(
|
|
312
|
-
$.identifier, $.formal_parameters, $.inferred_parameters, $._reserved_identifier,
|
|
407
|
+
$.identifier, $.formal_parameters, $.inferred_parameters, $._reserved_identifier, $.underscore_pattern,
|
|
313
408
|
)),
|
|
314
409
|
'->',
|
|
315
410
|
field('body', choice($.expression, $.block)),
|
|
@@ -317,7 +412,7 @@ module.exports = grammar({
|
|
|
317
412
|
|
|
318
413
|
inferred_parameters: $ => seq(
|
|
319
414
|
'(',
|
|
320
|
-
commaSep1(choice($.identifier, $._reserved_identifier)),
|
|
415
|
+
commaSep1(choice($.identifier, $._reserved_identifier, $.underscore_pattern)),
|
|
321
416
|
')',
|
|
322
417
|
),
|
|
323
418
|
|
|
@@ -450,11 +545,19 @@ module.exports = grammar({
|
|
|
450
545
|
|
|
451
546
|
argument_list: $ => seq('(', commaSep($.expression), ')'),
|
|
452
547
|
|
|
453
|
-
method_reference: $ =>
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
548
|
+
method_reference: $ => choice(
|
|
549
|
+
seq(
|
|
550
|
+
choice($._type, $.primary_expression, $.super),
|
|
551
|
+
'::',
|
|
552
|
+
optional($.type_arguments),
|
|
553
|
+
choice('new', $.identifier),
|
|
554
|
+
),
|
|
555
|
+
seq(
|
|
556
|
+
$._name, '.', $.super,
|
|
557
|
+
'::',
|
|
558
|
+
optional($.type_arguments),
|
|
559
|
+
$.identifier,
|
|
560
|
+
),
|
|
458
561
|
),
|
|
459
562
|
|
|
460
563
|
type_arguments: $ => seq(
|
|
@@ -1279,6 +1382,9 @@ module.exports = grammar({
|
|
|
1279
1382
|
alias('yield', $.identifier),
|
|
1280
1383
|
),
|
|
1281
1384
|
|
|
1385
|
+
_const: _ => /const/,
|
|
1386
|
+
_goto: _ => /goto/,
|
|
1387
|
+
|
|
1282
1388
|
this: _ => 'this',
|
|
1283
1389
|
|
|
1284
1390
|
super: _ => 'super',
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
|
@@ -2249,6 +2249,10 @@
|
|
|
2249
2249
|
{
|
|
2250
2250
|
"type": "identifier",
|
|
2251
2251
|
"named": true
|
|
2252
|
+
},
|
|
2253
|
+
{
|
|
2254
|
+
"type": "underscore_pattern",
|
|
2255
|
+
"named": true
|
|
2252
2256
|
}
|
|
2253
2257
|
]
|
|
2254
2258
|
}
|
|
@@ -2459,6 +2463,10 @@
|
|
|
2459
2463
|
{
|
|
2460
2464
|
"type": "inferred_parameters",
|
|
2461
2465
|
"named": true
|
|
2466
|
+
},
|
|
2467
|
+
{
|
|
2468
|
+
"type": "underscore_pattern",
|
|
2469
|
+
"named": true
|
|
2462
2470
|
}
|
|
2463
2471
|
]
|
|
2464
2472
|
}
|
|
@@ -2684,6 +2692,10 @@
|
|
|
2684
2692
|
"type": "primary_expression",
|
|
2685
2693
|
"named": true
|
|
2686
2694
|
},
|
|
2695
|
+
{
|
|
2696
|
+
"type": "scoped_identifier",
|
|
2697
|
+
"named": true
|
|
2698
|
+
},
|
|
2687
2699
|
{
|
|
2688
2700
|
"type": "super",
|
|
2689
2701
|
"named": true
|
package/tree-sitter-java.wasm
CHANGED
|
Binary file
|