@willbooster/tree-sitter-java 3.1.1 → 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 +52 -18
- package/package.json +1 -1
- package/tree-sitter-java.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -225,15 +225,41 @@ module.exports = grammar({
|
|
|
225
225
|
|
|
226
226
|
false: _ => 'false',
|
|
227
227
|
|
|
228
|
-
character_literal: _ =>
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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
|
+
},
|
|
237
263
|
|
|
238
264
|
string_literal: $ => choice($._string_literal, $._multiline_string_literal),
|
|
239
265
|
_string_literal: $ => seq(
|
|
@@ -274,15 +300,23 @@ module.exports = grammar({
|
|
|
274
300
|
prec(2, token.immediate(seq('\\', /[^bfnrts'\"\\]/))),
|
|
275
301
|
prec(1, $.escape_sequence),
|
|
276
302
|
),
|
|
277
|
-
escape_sequence: _ => token.immediate(
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
/[
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
+
)),
|
|
286
320
|
|
|
287
321
|
null_literal: _ => 'null',
|
|
288
322
|
|
package/package.json
CHANGED
package/tree-sitter-java.wasm
CHANGED
|
Binary file
|