@willbooster/tree-sitter-javascript 8.0.0 → 8.0.1

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
@@ -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],
@@ -574,7 +575,10 @@ module.exports = grammar({
574
575
 
575
576
  labeled_statement: ($) =>
576
577
  seq(
577
- field('label', alias(choice($.identifier, $.undefined, $._reserved_identifier), sym('statement_identifier'))),
578
+ field(
579
+ 'label',
580
+ aliasWithAsyncKeyword(choice($.identifier, $.undefined, $._reserved_identifier), sym('statement_identifier'))
581
+ ),
578
582
  ':',
579
583
  field('body', $._single_statement)
580
584
  ),
@@ -624,7 +628,7 @@ module.exports = grammar({
624
628
  $.parenthesized_expression,
625
629
  $._identifier,
626
630
  alias(sym('_await_yield_identifier'), $.identifier),
627
- alias($._reserved_identifier, $.identifier),
631
+ aliasWithAsyncKeyword($._reserved_identifier, $.identifier),
628
632
  $.this,
629
633
  $.super,
630
634
  $.number,
@@ -667,7 +671,10 @@ module.exports = grammar({
667
671
  $.pair,
668
672
  $.spread_element,
669
673
  $.method_definition,
670
- alias(choice($.identifier, $._reserved_identifier), sym('shorthand_property_identifier'))
674
+ aliasWithAsyncKeyword(
675
+ choice($.identifier, $._reserved_identifier),
676
+ sym('shorthand_property_identifier')
677
+ )
671
678
  )
672
679
  )
673
680
  ),
@@ -686,7 +693,10 @@ module.exports = grammar({
686
693
  $.pair_pattern,
687
694
  $.rest_pattern,
688
695
  $.object_assignment_pattern,
689
- alias(choice($.identifier, $._reserved_identifier), sym('shorthand_property_identifier_pattern'))
696
+ aliasWithAsyncKeyword(
697
+ choice($.identifier, $._reserved_identifier),
698
+ sym('shorthand_property_identifier_pattern')
699
+ )
690
700
  )
691
701
  )
692
702
  ),
@@ -701,7 +711,10 @@ module.exports = grammar({
701
711
  field(
702
712
  'left',
703
713
  choice(
704
- alias(choice($._reserved_identifier, $.identifier), sym('shorthand_property_identifier_pattern')),
714
+ aliasWithAsyncKeyword(
715
+ choice($._reserved_identifier, $.identifier),
716
+ sym('shorthand_property_identifier_pattern')
717
+ ),
705
718
  $._destructuring_pattern
706
719
  )
707
720
  ),
@@ -844,7 +857,7 @@ module.exports = grammar({
844
857
  'literal',
845
858
  functionContext((async) =>
846
859
  seq(
847
- ...(async ? ['async'] : []),
860
+ ...(async ? [alias(sym('_async_keyword'), 'async')] : []),
848
861
  'function',
849
862
  field('name', optional($.identifier)),
850
863
  functionScope(async, seq($._call_signature, field('body', $.statement_block)))
@@ -860,11 +873,11 @@ module.exports = grammar({
860
873
  choice(
861
874
  seq(
862
875
  sym('_default_declaration_start'),
863
- ...(async ? ['async'] : []),
876
+ ...(async ? [alias(sym('_async_keyword'), 'async')] : []),
864
877
  'function',
865
878
  field('name', optional($.identifier))
866
879
  ),
867
- seq(...(async ? ['async'] : []), 'function', field('name', $.identifier))
880
+ seq(...(async ? [alias(sym('_async_keyword'), 'async')] : []), 'function', field('name', $.identifier))
868
881
  ),
869
882
  functionScope(async, seq($._call_signature, field('body', $.statement_block)))
870
883
  )
@@ -876,7 +889,7 @@ module.exports = grammar({
876
889
  'literal',
877
890
  functionContext((async) =>
878
891
  seq(
879
- ...(async ? ['async'] : []),
892
+ ...(async ? [alias(sym('_async_keyword'), 'async')] : []),
880
893
  'function',
881
894
  '*',
882
895
  field('name', optional($.identifier)),
@@ -893,12 +906,17 @@ module.exports = grammar({
893
906
  choice(
894
907
  seq(
895
908
  sym('_default_declaration_start'),
896
- ...(async ? ['async'] : []),
909
+ ...(async ? [alias(sym('_async_keyword'), 'async')] : []),
897
910
  'function',
898
911
  '*',
899
912
  field('name', optional($.identifier))
900
913
  ),
901
- seq(...(async ? ['async'] : []), 'function', '*', field('name', $.identifier))
914
+ seq(
915
+ ...(async ? [alias(sym('_async_keyword'), 'async')] : []),
916
+ 'function',
917
+ '*',
918
+ field('name', $.identifier)
919
+ )
902
920
  ),
903
921
  functionScope(async, seq($._call_signature, field('body', $.statement_block)), 'generator_function')
904
922
  )
@@ -909,11 +927,15 @@ module.exports = grammar({
909
927
  prec.right(
910
928
  functionContext((async) =>
911
929
  seq(
912
- ...(async ? ['async'] : []),
930
+ ...(async ? [alias(sym('_async_keyword'), 'async')] : []),
913
931
  choice(
914
932
  field(
915
933
  'parameter',
916
- choice(alias($._reserved_identifier, $.identifier), alias($.undefined, $.identifier), $.identifier)
934
+ choice(
935
+ aliasWithAsyncKeyword($._reserved_identifier, $.identifier),
936
+ alias($.undefined, $.identifier),
937
+ $.identifier
938
+ )
917
939
  ),
918
940
  $._call_signature
919
941
  ),
@@ -964,7 +986,7 @@ module.exports = grammar({
964
986
  functionContext((async) =>
965
987
  seq(
966
988
  optional(sym('_constructor_async_function_start')),
967
- ...(async ? ['async'] : []),
989
+ ...(async ? [alias(sym('_async_keyword'), 'async')] : []),
968
990
  'function',
969
991
  field('name', optional($.identifier)),
970
992
  functionScope(async, seq($._call_signature, field('body', $.statement_block)))
@@ -978,7 +1000,7 @@ module.exports = grammar({
978
1000
  functionContext((async) =>
979
1001
  seq(
980
1002
  optional(sym('_constructor_async_function_start')),
981
- ...(async ? ['async'] : []),
1003
+ ...(async ? [alias(sym('_async_keyword'), 'async')] : []),
982
1004
  'function',
983
1005
  '*',
984
1006
  field('name', optional($.identifier)),
@@ -993,7 +1015,7 @@ module.exports = grammar({
993
1015
  $.parenthesized_expression,
994
1016
  $._identifier,
995
1017
  alias(sym('_await_yield_identifier'), $.identifier),
996
- alias($._reserved_identifier, $.identifier),
1018
+ aliasWithAsyncKeyword($._reserved_identifier, $.identifier),
997
1019
  $.this,
998
1020
  $.super,
999
1021
  $.number,
@@ -1122,7 +1144,7 @@ module.exports = grammar({
1122
1144
  $.member_expression,
1123
1145
  $.subscript_expression,
1124
1146
  $._identifier,
1125
- alias($._reserved_identifier, $.identifier),
1147
+ aliasWithAsyncKeyword($._reserved_identifier, $.identifier),
1126
1148
  $._destructuring_pattern
1127
1149
  ),
1128
1150
 
@@ -1136,7 +1158,7 @@ module.exports = grammar({
1136
1158
  choice(
1137
1159
  $.member_expression,
1138
1160
  $.subscript_expression,
1139
- alias($._reserved_identifier, $.identifier),
1161
+ aliasWithAsyncKeyword($._reserved_identifier, $.identifier),
1140
1162
  $._identifier,
1141
1163
  $.parenthesized_expression
1142
1164
  ),
@@ -1502,7 +1524,7 @@ module.exports = grammar({
1502
1524
  seq(
1503
1525
  repeat(field('decorator', $.decorator)),
1504
1526
  optional('static'),
1505
- ...(async ? ['async'] : []),
1527
+ ...(async ? [alias(sym('_async_keyword'), 'async')] : []),
1506
1528
  ...(generator ? ['*'] : [optional(choice('get', 'set'))]),
1507
1529
  field('name', $._property_name),
1508
1530
  choice(
@@ -1542,7 +1564,7 @@ module.exports = grammar({
1542
1564
  reserved(
1543
1565
  'properties',
1544
1566
  choice(
1545
- alias(
1567
+ aliasWithAsyncKeyword(
1546
1568
  choice(
1547
1569
  $.identifier,
1548
1570
  sym('_yield_identifier'),
@@ -1564,7 +1586,7 @@ module.exports = grammar({
1564
1586
  reserved(
1565
1587
  'properties',
1566
1588
  choice(
1567
- alias(choice($.identifier, $._reserved_identifier), sym('property_identifier')),
1589
+ aliasWithAsyncKeyword(choice($.identifier, $._reserved_identifier), sym('property_identifier')),
1568
1590
  $.private_property_identifier,
1569
1591
  $.string,
1570
1592
  $.number,
@@ -1594,6 +1616,14 @@ module.exports = grammar({
1594
1616
  },
1595
1617
  });
1596
1618
 
1619
+ /**
1620
+ * @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} rule
1621
+ * @param {import('@willbooster/web-tree-sitter/dsl').SymbolRule<string>} symbol
1622
+ */
1623
+ function aliasWithAsyncKeyword(rule, symbol) {
1624
+ return choice(alias(rule, symbol), alias(sym('_async_keyword'), symbol));
1625
+ }
1626
+
1597
1627
  /**
1598
1628
  * Creates a rule to match one or more of the rules separated by a comma
1599
1629
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-javascript",
3
- "version": "8.0.0",
3
+ "version": "8.0.1",
4
4
  "description": "JavaScript grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
Binary file
Binary file
package/tree-sitter.json CHANGED
@@ -48,7 +48,7 @@
48
48
  }
49
49
  ],
50
50
  "metadata": {
51
- "version": "8.0.0",
51
+ "version": "8.0.1",
52
52
  "license": "MIT",
53
53
  "description": "JavaScript grammar for tree-sitter",
54
54
  "authors": [