@willbooster/tree-sitter-javascript 8.0.0 → 8.0.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 +60 -27
- package/package.json +1 -1
- package/tree-sitter-javascript.wasm +0 -0
- package/tree-sitter-javascript_script.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -53,7 +53,7 @@ const NAMED_RESERVED_WORDS = new Set(['this', 'super', 'true', 'false', 'null'])
|
|
|
53
53
|
|
|
54
54
|
// Words that are keywords only in some positions and identifiers elsewhere.
|
|
55
55
|
const MEMBER_MODIFIERS = ['get', 'set', 'static'];
|
|
56
|
-
const CONTEXTUAL_KEYWORDS = ['async', 'await', 'let', 'using'];
|
|
56
|
+
const CONTEXTUAL_KEYWORDS = ['async', 'await', 'let', 'of', 'using'];
|
|
57
57
|
|
|
58
58
|
// oxlint-disable-next-line unicorn/prefer-module -- This package is CommonJS, so tree-sitter loads grammar.js as CommonJS.
|
|
59
59
|
module.exports = grammar({
|
|
@@ -125,6 +125,7 @@ module.exports = grammar({
|
|
|
125
125
|
sym('_function_signature_start'),
|
|
126
126
|
sym('_async_function_signature_start'),
|
|
127
127
|
sym('_call_arguments_context'),
|
|
128
|
+
sym('_async_keyword'),
|
|
128
129
|
],
|
|
129
130
|
|
|
130
131
|
extras: ($) => [$.comment, sym('html_comment'), /[\s\p{Zs}\uFEFF\u2028\u2029\u2060\u200B]/u],
|
|
@@ -499,11 +500,14 @@ module.exports = grammar({
|
|
|
499
500
|
field('left', choice($.identifier, alias('of', $.identifier), $._destructuring_pattern)),
|
|
500
501
|
optional($._initializer)
|
|
501
502
|
),
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
'
|
|
506
|
-
|
|
503
|
+
prec.dynamic(
|
|
504
|
+
1,
|
|
505
|
+
seq(
|
|
506
|
+
field('kind', choice('let', 'const')),
|
|
507
|
+
field(
|
|
508
|
+
'left',
|
|
509
|
+
choice(reserved('lexical', $.identifier), alias('of', $.identifier), $._destructuring_pattern)
|
|
510
|
+
)
|
|
507
511
|
)
|
|
508
512
|
)
|
|
509
513
|
),
|
|
@@ -574,7 +578,10 @@ module.exports = grammar({
|
|
|
574
578
|
|
|
575
579
|
labeled_statement: ($) =>
|
|
576
580
|
seq(
|
|
577
|
-
field(
|
|
581
|
+
field(
|
|
582
|
+
'label',
|
|
583
|
+
aliasWithAsyncKeyword(choice($.identifier, $.undefined, $._reserved_identifier), sym('statement_identifier'))
|
|
584
|
+
),
|
|
578
585
|
':',
|
|
579
586
|
field('body', $._single_statement)
|
|
580
587
|
),
|
|
@@ -624,7 +631,7 @@ module.exports = grammar({
|
|
|
624
631
|
$.parenthesized_expression,
|
|
625
632
|
$._identifier,
|
|
626
633
|
alias(sym('_await_yield_identifier'), $.identifier),
|
|
627
|
-
|
|
634
|
+
aliasWithAsyncKeyword($._reserved_identifier, $.identifier),
|
|
628
635
|
$.this,
|
|
629
636
|
$.super,
|
|
630
637
|
$.number,
|
|
@@ -667,7 +674,10 @@ module.exports = grammar({
|
|
|
667
674
|
$.pair,
|
|
668
675
|
$.spread_element,
|
|
669
676
|
$.method_definition,
|
|
670
|
-
|
|
677
|
+
aliasWithAsyncKeyword(
|
|
678
|
+
choice($.identifier, $._reserved_identifier),
|
|
679
|
+
sym('shorthand_property_identifier')
|
|
680
|
+
)
|
|
671
681
|
)
|
|
672
682
|
)
|
|
673
683
|
),
|
|
@@ -686,7 +696,10 @@ module.exports = grammar({
|
|
|
686
696
|
$.pair_pattern,
|
|
687
697
|
$.rest_pattern,
|
|
688
698
|
$.object_assignment_pattern,
|
|
689
|
-
|
|
699
|
+
aliasWithAsyncKeyword(
|
|
700
|
+
choice($.identifier, $._reserved_identifier),
|
|
701
|
+
sym('shorthand_property_identifier_pattern')
|
|
702
|
+
)
|
|
690
703
|
)
|
|
691
704
|
)
|
|
692
705
|
),
|
|
@@ -701,7 +714,10 @@ module.exports = grammar({
|
|
|
701
714
|
field(
|
|
702
715
|
'left',
|
|
703
716
|
choice(
|
|
704
|
-
|
|
717
|
+
aliasWithAsyncKeyword(
|
|
718
|
+
choice($._reserved_identifier, $.identifier),
|
|
719
|
+
sym('shorthand_property_identifier_pattern')
|
|
720
|
+
),
|
|
705
721
|
$._destructuring_pattern
|
|
706
722
|
)
|
|
707
723
|
),
|
|
@@ -844,7 +860,7 @@ module.exports = grammar({
|
|
|
844
860
|
'literal',
|
|
845
861
|
functionContext((async) =>
|
|
846
862
|
seq(
|
|
847
|
-
...(async ? ['async'] : []),
|
|
863
|
+
...(async ? [alias(sym('_async_keyword'), 'async')] : []),
|
|
848
864
|
'function',
|
|
849
865
|
field('name', optional($.identifier)),
|
|
850
866
|
functionScope(async, seq($._call_signature, field('body', $.statement_block)))
|
|
@@ -860,11 +876,11 @@ module.exports = grammar({
|
|
|
860
876
|
choice(
|
|
861
877
|
seq(
|
|
862
878
|
sym('_default_declaration_start'),
|
|
863
|
-
...(async ? ['async'] : []),
|
|
879
|
+
...(async ? [alias(sym('_async_keyword'), 'async')] : []),
|
|
864
880
|
'function',
|
|
865
881
|
field('name', optional($.identifier))
|
|
866
882
|
),
|
|
867
|
-
seq(...(async ? ['async'] : []), 'function', field('name', $.identifier))
|
|
883
|
+
seq(...(async ? [alias(sym('_async_keyword'), 'async')] : []), 'function', field('name', $.identifier))
|
|
868
884
|
),
|
|
869
885
|
functionScope(async, seq($._call_signature, field('body', $.statement_block)))
|
|
870
886
|
)
|
|
@@ -876,7 +892,7 @@ module.exports = grammar({
|
|
|
876
892
|
'literal',
|
|
877
893
|
functionContext((async) =>
|
|
878
894
|
seq(
|
|
879
|
-
...(async ? ['async'] : []),
|
|
895
|
+
...(async ? [alias(sym('_async_keyword'), 'async')] : []),
|
|
880
896
|
'function',
|
|
881
897
|
'*',
|
|
882
898
|
field('name', optional($.identifier)),
|
|
@@ -893,12 +909,17 @@ module.exports = grammar({
|
|
|
893
909
|
choice(
|
|
894
910
|
seq(
|
|
895
911
|
sym('_default_declaration_start'),
|
|
896
|
-
...(async ? ['async'] : []),
|
|
912
|
+
...(async ? [alias(sym('_async_keyword'), 'async')] : []),
|
|
897
913
|
'function',
|
|
898
914
|
'*',
|
|
899
915
|
field('name', optional($.identifier))
|
|
900
916
|
),
|
|
901
|
-
seq(
|
|
917
|
+
seq(
|
|
918
|
+
...(async ? [alias(sym('_async_keyword'), 'async')] : []),
|
|
919
|
+
'function',
|
|
920
|
+
'*',
|
|
921
|
+
field('name', $.identifier)
|
|
922
|
+
)
|
|
902
923
|
),
|
|
903
924
|
functionScope(async, seq($._call_signature, field('body', $.statement_block)), 'generator_function')
|
|
904
925
|
)
|
|
@@ -909,11 +930,15 @@ module.exports = grammar({
|
|
|
909
930
|
prec.right(
|
|
910
931
|
functionContext((async) =>
|
|
911
932
|
seq(
|
|
912
|
-
...(async ? ['async'] : []),
|
|
933
|
+
...(async ? [alias(sym('_async_keyword'), 'async')] : []),
|
|
913
934
|
choice(
|
|
914
935
|
field(
|
|
915
936
|
'parameter',
|
|
916
|
-
choice(
|
|
937
|
+
choice(
|
|
938
|
+
aliasWithAsyncKeyword($._reserved_identifier, $.identifier),
|
|
939
|
+
alias($.undefined, $.identifier),
|
|
940
|
+
$.identifier
|
|
941
|
+
)
|
|
917
942
|
),
|
|
918
943
|
$._call_signature
|
|
919
944
|
),
|
|
@@ -964,7 +989,7 @@ module.exports = grammar({
|
|
|
964
989
|
functionContext((async) =>
|
|
965
990
|
seq(
|
|
966
991
|
optional(sym('_constructor_async_function_start')),
|
|
967
|
-
...(async ? ['async'] : []),
|
|
992
|
+
...(async ? [alias(sym('_async_keyword'), 'async')] : []),
|
|
968
993
|
'function',
|
|
969
994
|
field('name', optional($.identifier)),
|
|
970
995
|
functionScope(async, seq($._call_signature, field('body', $.statement_block)))
|
|
@@ -978,7 +1003,7 @@ module.exports = grammar({
|
|
|
978
1003
|
functionContext((async) =>
|
|
979
1004
|
seq(
|
|
980
1005
|
optional(sym('_constructor_async_function_start')),
|
|
981
|
-
...(async ? ['async'] : []),
|
|
1006
|
+
...(async ? [alias(sym('_async_keyword'), 'async')] : []),
|
|
982
1007
|
'function',
|
|
983
1008
|
'*',
|
|
984
1009
|
field('name', optional($.identifier)),
|
|
@@ -993,7 +1018,7 @@ module.exports = grammar({
|
|
|
993
1018
|
$.parenthesized_expression,
|
|
994
1019
|
$._identifier,
|
|
995
1020
|
alias(sym('_await_yield_identifier'), $.identifier),
|
|
996
|
-
|
|
1021
|
+
aliasWithAsyncKeyword($._reserved_identifier, $.identifier),
|
|
997
1022
|
$.this,
|
|
998
1023
|
$.super,
|
|
999
1024
|
$.number,
|
|
@@ -1122,7 +1147,7 @@ module.exports = grammar({
|
|
|
1122
1147
|
$.member_expression,
|
|
1123
1148
|
$.subscript_expression,
|
|
1124
1149
|
$._identifier,
|
|
1125
|
-
|
|
1150
|
+
aliasWithAsyncKeyword($._reserved_identifier, $.identifier),
|
|
1126
1151
|
$._destructuring_pattern
|
|
1127
1152
|
),
|
|
1128
1153
|
|
|
@@ -1136,7 +1161,7 @@ module.exports = grammar({
|
|
|
1136
1161
|
choice(
|
|
1137
1162
|
$.member_expression,
|
|
1138
1163
|
$.subscript_expression,
|
|
1139
|
-
|
|
1164
|
+
aliasWithAsyncKeyword($._reserved_identifier, $.identifier),
|
|
1140
1165
|
$._identifier,
|
|
1141
1166
|
$.parenthesized_expression
|
|
1142
1167
|
),
|
|
@@ -1502,7 +1527,7 @@ module.exports = grammar({
|
|
|
1502
1527
|
seq(
|
|
1503
1528
|
repeat(field('decorator', $.decorator)),
|
|
1504
1529
|
optional('static'),
|
|
1505
|
-
...(async ? ['async'] : []),
|
|
1530
|
+
...(async ? [alias(sym('_async_keyword'), 'async')] : []),
|
|
1506
1531
|
...(generator ? ['*'] : [optional(choice('get', 'set'))]),
|
|
1507
1532
|
field('name', $._property_name),
|
|
1508
1533
|
choice(
|
|
@@ -1542,7 +1567,7 @@ module.exports = grammar({
|
|
|
1542
1567
|
reserved(
|
|
1543
1568
|
'properties',
|
|
1544
1569
|
choice(
|
|
1545
|
-
|
|
1570
|
+
aliasWithAsyncKeyword(
|
|
1546
1571
|
choice(
|
|
1547
1572
|
$.identifier,
|
|
1548
1573
|
sym('_yield_identifier'),
|
|
@@ -1564,7 +1589,7 @@ module.exports = grammar({
|
|
|
1564
1589
|
reserved(
|
|
1565
1590
|
'properties',
|
|
1566
1591
|
choice(
|
|
1567
|
-
|
|
1592
|
+
aliasWithAsyncKeyword(choice($.identifier, $._reserved_identifier), sym('property_identifier')),
|
|
1568
1593
|
$.private_property_identifier,
|
|
1569
1594
|
$.string,
|
|
1570
1595
|
$.number,
|
|
@@ -1594,6 +1619,14 @@ module.exports = grammar({
|
|
|
1594
1619
|
},
|
|
1595
1620
|
});
|
|
1596
1621
|
|
|
1622
|
+
/**
|
|
1623
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} rule
|
|
1624
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').SymbolRule<string>} symbol
|
|
1625
|
+
*/
|
|
1626
|
+
function aliasWithAsyncKeyword(rule, symbol) {
|
|
1627
|
+
return choice(alias(rule, symbol), alias(sym('_async_keyword'), symbol));
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1597
1630
|
/**
|
|
1598
1631
|
* Creates a rule to match one or more of the rules separated by a comma
|
|
1599
1632
|
*
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|