@@ -31,19 +31,43 @@ module.exports = grammar({
31
31
] ,
32
32
33
33
reserved : {
34
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#reserved_words
34
35
global : $ => [
36
+ 'break' ,
37
+ 'case' ,
38
+ 'catch' ,
39
+ 'class' ,
35
40
'const' ,
41
+ 'continue' ,
42
+ 'debugger' ,
43
+ 'default' ,
44
+ 'delete' ,
36
45
'do' ,
37
46
'else' ,
47
+ 'export' ,
48
+ 'extends' ,
49
+ 'false' ,
38
50
'finally' ,
39
51
'for' ,
40
52
'function' ,
41
53
'if' ,
42
- 'let' ,
54
+ 'import' ,
55
+ 'in' ,
56
+ 'instanceof' ,
57
+ 'new' ,
58
+ 'null' ,
43
59
'return' ,
60
+ 'super' ,
61
+ 'switch' ,
62
+ 'this' ,
44
63
'throw' ,
64
+ 'true' ,
65
+ 'try' ,
66
+ 'typeof' ,
45
67
'var' ,
68
+ 'void' ,
46
69
'while' ,
70
+ 'with' ,
47
71
] ,
48
72
properties : $ => [ ] ,
49
73
} ,
@@ -62,7 +86,6 @@ module.exports = grammar({
62
86
$ . _expressions ,
63
87
$ . _semicolon ,
64
88
$ . _identifier ,
65
- $ . _reserved_identifier ,
66
89
$ . _jsx_attribute ,
67
90
$ . _jsx_element_name ,
68
91
$ . _jsx_child ,
@@ -108,9 +131,6 @@ module.exports = grammar({
108
131
109
132
conflicts : $ => [
110
133
[ $ . primary_expression , $ . _property_name ] ,
111
- [ $ . primary_expression , $ . _property_name , $ . arrow_function ] ,
112
- [ $ . primary_expression , $ . arrow_function ] ,
113
- [ $ . primary_expression , $ . method_definition ] ,
114
134
[ $ . primary_expression , $ . rest_pattern ] ,
115
135
[ $ . primary_expression , $ . pattern ] ,
116
136
[ $ . primary_expression , $ . _for_header ] ,
@@ -122,7 +142,6 @@ module.exports = grammar({
122
142
[ $ . labeled_statement , $ . _property_name ] ,
123
143
[ $ . computed_property_name , $ . array ] ,
124
144
[ $ . binary_expression , $ . _initializer ] ,
125
- [ $ . class_static_block , $ . _property_name ] ,
126
145
] ,
127
146
128
147
word : $ => $ . identifier ,
@@ -191,6 +210,7 @@ module.exports = grammar({
191
210
_module_export_name : $ => choice (
192
211
$ . identifier ,
193
212
$ . string ,
213
+ 'default' ,
194
214
) ,
195
215
196
216
declaration : $ => choice (
@@ -443,7 +463,7 @@ module.exports = grammar({
443
463
empty_statement : _ => ';' ,
444
464
445
465
labeled_statement : $ => prec . dynamic ( - 1 , seq (
446
- field ( 'label' , alias ( choice ( $ . identifier , $ . _reserved_identifier ) , $ . statement_identifier ) ) ,
466
+ field ( 'label' , alias ( $ . identifier , $ . statement_identifier ) ) ,
447
467
':' ,
448
468
field ( 'body' , $ . statement ) ,
449
469
) ) ,
@@ -515,7 +535,6 @@ module.exports = grammar({
515
535
$ . member_expression ,
516
536
$ . parenthesized_expression ,
517
537
$ . _identifier ,
518
- alias ( $ . _reserved_identifier , $ . identifier ) ,
519
538
$ . this ,
520
539
$ . super ,
521
540
$ . number ,
@@ -548,10 +567,7 @@ module.exports = grammar({
548
567
$ . pair ,
549
568
$ . spread_element ,
550
569
$ . method_definition ,
551
- alias (
552
- choice ( $ . identifier , $ . _reserved_identifier ) ,
553
- $ . shorthand_property_identifier ,
554
- ) ,
570
+ alias ( $ . identifier , $ . shorthand_property_identifier ) ,
555
571
) ) ) ,
556
572
'}' ,
557
573
) ) ,
@@ -562,10 +578,7 @@ module.exports = grammar({
562
578
$ . pair_pattern ,
563
579
$ . rest_pattern ,
564
580
$ . object_assignment_pattern ,
565
- alias (
566
- choice ( $ . identifier , $ . _reserved_identifier ) ,
567
- $ . shorthand_property_identifier_pattern ,
568
- ) ,
581
+ alias ( $ . identifier , $ . shorthand_property_identifier_pattern ) ,
569
582
) ) ) ,
570
583
'}' ,
571
584
) ) ,
@@ -579,10 +592,7 @@ module.exports = grammar({
579
592
object_assignment_pattern : $ => seq (
580
593
field ( 'left' , choice (
581
594
$ . _destructuring_pattern ,
582
- alias (
583
- choice ( $ . _reserved_identifier , $ . identifier ) ,
584
- $ . shorthand_property_identifier_pattern ,
585
- ) ,
595
+ alias ( $ . identifier , $ . shorthand_property_identifier_pattern ) ,
586
596
) ) ,
587
597
'=' ,
588
598
field ( 'right' , $ . expression ) ,
@@ -784,7 +794,6 @@ module.exports = grammar({
784
794
optional ( 'async' ) ,
785
795
choice (
786
796
field ( 'parameter' , choice (
787
- alias ( $ . _reserved_identifier , $ . identifier ) ,
788
797
$ . identifier ,
789
798
) ) ,
790
799
$ . _call_signature ,
@@ -847,7 +856,6 @@ module.exports = grammar({
847
856
$ . member_expression ,
848
857
$ . subscript_expression ,
849
858
$ . _identifier ,
850
- alias ( $ . _reserved_identifier , $ . identifier ) ,
851
859
$ . _destructuring_pattern ,
852
860
) ,
853
861
@@ -860,7 +868,6 @@ module.exports = grammar({
860
868
_augmented_assignment_lhs : $ => choice (
861
869
$ . member_expression ,
862
870
$ . subscript_expression ,
863
- alias ( $ . _reserved_identifier , $ . identifier ) ,
864
871
$ . identifier ,
865
872
$ . parenthesized_expression ,
866
873
) ,
@@ -1218,10 +1225,7 @@ module.exports = grammar({
1218
1225
) ,
1219
1226
1220
1227
_property_name : $ => reserved ( 'properties' , choice (
1221
- alias ( choice (
1222
- $ . identifier ,
1223
- $ . _reserved_identifier ,
1224
- ) , $ . property_identifier ) ,
1228
+ alias ( $ . identifier , $ . property_identifier ) ,
1225
1229
$ . private_property_identifier ,
1226
1230
$ . string ,
1227
1231
$ . number ,
@@ -1234,15 +1238,6 @@ module.exports = grammar({
1234
1238
']' ,
1235
1239
) ,
1236
1240
1237
- _reserved_identifier : _ => choice (
1238
- 'get' ,
1239
- 'set' ,
1240
- 'async' ,
1241
- 'static' ,
1242
- 'export' ,
1243
- 'let' ,
1244
- ) ,
1245
-
1246
1241
_semicolon : $ => choice ( $ . _automatic_semicolon , ';' ) ,
1247
1242
} ,
1248
1243
} ) ;
0 commit comments