@willbooster/tree-sitter-javascript 1.0.25 → 1.0.26
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 +16 -9
- package/package.json +1 -1
- package/tree-sitter-javascript.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -99,6 +99,8 @@ module.exports = grammar({
|
|
|
99
99
|
// Emitted zero-width after a postfix update; carries the pending statement boundary across reuse.
|
|
100
100
|
$._postfix_update_end,
|
|
101
101
|
$._await_keyword,
|
|
102
|
+
$._let,
|
|
103
|
+
$._single_statement_context,
|
|
102
104
|
],
|
|
103
105
|
|
|
104
106
|
extras: ($) => [$.comment, $.html_comment, /[\s\p{Zs}\uFEFF\u2028\u2029\u2060\u200B]/u],
|
|
@@ -190,6 +192,8 @@ module.exports = grammar({
|
|
|
190
192
|
|
|
191
193
|
_statement: ($) => prec.right(seq($.statement, optional($._statement_boundary))),
|
|
192
194
|
|
|
195
|
+
_single_statement: ($) => seq(optional($._single_statement_context), $._statement),
|
|
196
|
+
|
|
193
197
|
hash_bang_line: () => /#![^\n\r\u2028\u2029]*/,
|
|
194
198
|
|
|
195
199
|
//
|
|
@@ -323,8 +327,10 @@ module.exports = grammar({
|
|
|
323
327
|
|
|
324
328
|
variable_declaration: ($) => seq('var', commaSep1($.variable_declarator), $._semicolon),
|
|
325
329
|
|
|
330
|
+
_let: () => token(prec(-1, /let/)),
|
|
331
|
+
|
|
326
332
|
lexical_declaration: ($) =>
|
|
327
|
-
seq(field('kind', choice('let', 'const')), commaSep1($.variable_declarator), $._semicolon),
|
|
333
|
+
seq(field('kind', choice('let', alias($._let, 'let'), 'const')), commaSep1($.variable_declarator), $._semicolon),
|
|
328
334
|
|
|
329
335
|
using_declaration: ($) =>
|
|
330
336
|
seq(
|
|
@@ -344,14 +350,14 @@ module.exports = grammar({
|
|
|
344
350
|
|
|
345
351
|
statement_block: ($) => prec.right(seq('{', repeat($._statement), '}')),
|
|
346
352
|
|
|
347
|
-
else_clause: ($) => seq('else', $.
|
|
353
|
+
else_clause: ($) => seq('else', $._single_statement),
|
|
348
354
|
|
|
349
355
|
if_statement: ($) =>
|
|
350
356
|
prec.right(
|
|
351
357
|
seq(
|
|
352
358
|
'if',
|
|
353
359
|
field('condition', $.parenthesized_expression),
|
|
354
|
-
field('consequence', $.
|
|
360
|
+
field('consequence', $._single_statement),
|
|
355
361
|
optional(field('alternative', $.else_clause))
|
|
356
362
|
)
|
|
357
363
|
),
|
|
@@ -366,7 +372,7 @@ module.exports = grammar({
|
|
|
366
372
|
$._for_condition,
|
|
367
373
|
field('increment', optional($._expressions)),
|
|
368
374
|
')',
|
|
369
|
-
field('body', $.
|
|
375
|
+
field('body', $._single_statement)
|
|
370
376
|
),
|
|
371
377
|
|
|
372
378
|
// Extracted into rules because tree-sitter expands a `choice` written inline in the `seq` above into one production
|
|
@@ -403,7 +409,7 @@ module.exports = grammar({
|
|
|
403
409
|
),
|
|
404
410
|
|
|
405
411
|
for_in_statement: ($) =>
|
|
406
|
-
seq('for', optional(alias($._await_keyword, 'await')), $._for_header, field('body', $.
|
|
412
|
+
seq('for', optional(alias($._await_keyword, 'await')), $._for_header, field('body', $._single_statement)),
|
|
407
413
|
|
|
408
414
|
_for_header: ($) =>
|
|
409
415
|
seq(
|
|
@@ -429,13 +435,14 @@ module.exports = grammar({
|
|
|
429
435
|
')'
|
|
430
436
|
),
|
|
431
437
|
|
|
432
|
-
while_statement: ($) =>
|
|
438
|
+
while_statement: ($) =>
|
|
439
|
+
seq('while', field('condition', $.parenthesized_expression), field('body', $._single_statement)),
|
|
433
440
|
|
|
434
441
|
do_statement: ($) =>
|
|
435
442
|
prec.right(
|
|
436
443
|
seq(
|
|
437
444
|
'do',
|
|
438
|
-
field('body', $.
|
|
445
|
+
field('body', $._single_statement),
|
|
439
446
|
'while',
|
|
440
447
|
field('condition', $.parenthesized_expression),
|
|
441
448
|
optional($._semicolon)
|
|
@@ -450,7 +457,7 @@ module.exports = grammar({
|
|
|
450
457
|
optional(field('finalizer', $.finally_clause))
|
|
451
458
|
),
|
|
452
459
|
|
|
453
|
-
with_statement: ($) => seq('with', field('object', $.parenthesized_expression), field('body', $.
|
|
460
|
+
with_statement: ($) => seq('with', field('object', $.parenthesized_expression), field('body', $._single_statement)),
|
|
454
461
|
|
|
455
462
|
break_statement: ($) =>
|
|
456
463
|
seq(
|
|
@@ -479,7 +486,7 @@ module.exports = grammar({
|
|
|
479
486
|
seq(
|
|
480
487
|
field('label', alias(choice($.identifier, $._reserved_identifier), $.statement_identifier)),
|
|
481
488
|
':',
|
|
482
|
-
field('body', $.
|
|
489
|
+
field('body', $._single_statement)
|
|
483
490
|
),
|
|
484
491
|
|
|
485
492
|
//
|
package/package.json
CHANGED
|
Binary file
|