@@ -30,6 +30,48 @@ module.exports = grammar({
30
30
/ [ \s \p{ Zs} \uFEFF \u2028 \u2029 \u2060 \u200B ] / ,
31
31
] ,
32
32
33
+ reserved : {
34
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#reserved_words
35
+ global : $ => [
36
+ 'break' ,
37
+ 'case' ,
38
+ 'catch' ,
39
+ 'class' ,
40
+ 'const' ,
41
+ 'continue' ,
42
+ 'debugger' ,
43
+ 'default' ,
44
+ 'delete' ,
45
+ 'do' ,
46
+ 'else' ,
47
+ 'export' ,
48
+ 'extends' ,
49
+ 'false' ,
50
+ 'finally' ,
51
+ 'for' ,
52
+ 'function' ,
53
+ 'if' ,
54
+ 'import' ,
55
+ 'in' ,
56
+ 'instanceof' ,
57
+ 'new' ,
58
+ 'null' ,
59
+ 'return' ,
60
+ 'super' ,
61
+ 'switch' ,
62
+ 'this' ,
63
+ 'throw' ,
64
+ 'true' ,
65
+ 'try' ,
66
+ 'typeof' ,
67
+ 'var' ,
68
+ 'void' ,
69
+ 'while' ,
70
+ 'with' ,
71
+ ] ,
72
+ properties : $ => [ ] ,
73
+ } ,
74
+
33
75
supertypes : $ => [
34
76
$ . statement ,
35
77
$ . declaration ,
@@ -173,6 +215,7 @@ module.exports = grammar({
173
215
_module_export_name : $ => choice (
174
216
$ . identifier ,
175
217
$ . string ,
218
+ 'default' ,
176
219
) ,
177
220
178
221
declaration : $ => choice (
@@ -841,7 +884,8 @@ module.exports = grammar({
841
884
choice ( '.' , field ( 'optional_chain' , $ . optional_chain ) ) ,
842
885
field ( 'property' , choice (
843
886
$ . private_property_identifier ,
844
- alias ( $ . identifier , $ . property_identifier ) ) ) ,
887
+ reserved ( 'properties' , alias ( $ . identifier , $ . property_identifier ) ) ,
888
+ ) ) ,
845
889
) ) ,
846
890
847
891
subscript_expression : $ => prec . right ( 'member' , seq (
@@ -1224,7 +1268,7 @@ module.exports = grammar({
1224
1268
field ( 'value' , choice ( $ . pattern , $ . assignment_pattern ) ) ,
1225
1269
) ,
1226
1270
1227
- _property_name : $ => choice (
1271
+ _property_name : $ => reserved ( 'properties' , choice (
1228
1272
alias (
1229
1273
choice ( $ . identifier , $ . _reserved_identifier ) ,
1230
1274
$ . property_identifier ,
@@ -1233,7 +1277,7 @@ module.exports = grammar({
1233
1277
$ . string ,
1234
1278
$ . number ,
1235
1279
$ . computed_property_name ,
1236
- ) ,
1280
+ ) ) ,
1237
1281
1238
1282
computed_property_name : $ => seq (
1239
1283
'[' ,
0 commit comments