@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 CHANGED
@@ -225,15 +225,41 @@ module.exports = grammar({
225
225
 
226
226
  false: _ => 'false',
227
227
 
228
- character_literal: _ => token(seq(
229
- '\'',
230
- repeat1(choice(
231
- /[^\\'\n]/,
232
- /\\./,
233
- /\\\n/,
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(seq(
278
- '\\',
279
- choice(
280
- /[^xu0-7]/,
281
- /[0-7]{1,3}/,
282
- /x[0-9a-fA-F]{2}/,
283
- /u[0-9a-fA-F]{4}/,
284
- /u\{[0-9a-fA-F]+\}/,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-java",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
4
4
  "description": "Java grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
Binary file
package/tree-sitter.json CHANGED
@@ -14,7 +14,7 @@
14
14
  }
15
15
  ],
16
16
  "metadata": {
17
- "version": "3.1.1",
17
+ "version": "3.1.2",
18
18
  "license": "MIT",
19
19
  "description": "Java grammar for tree-sitter",
20
20
  "authors": [