@@ -10,11 +10,14 @@ module.exports = grammar({
10
10
$ . _template_chars ,
11
11
$ . _lparen ,
12
12
$ . _rparen ,
13
- $ . _list_constructor
13
+ $ . _list_constructor ,
14
+ $ . _decorator ,
15
+ $ . _decorator_inline ,
14
16
] ,
15
17
16
18
extras : $ => [
17
19
$ . comment ,
20
+ $ . decorator ,
18
21
/ [ \s \uFEFF \u2060 \u200B \u00A0 ] /
19
22
] ,
20
23
@@ -77,41 +80,28 @@ module.exports = grammar({
77
80
[ $ . primary_expression , $ . _literal_pattern ] ,
78
81
[ $ . primary_expression , $ . lazy_pattern ] ,
79
82
[ $ . primary_expression , $ . _jsx_child ] ,
80
- [ $ . tuple_pattern , $ . parameter ] ,
81
- [ $ . primary_expression , $ . parameter ] ,
82
- [ $ . primary_expression , $ . record_field ] ,
83
83
[ $ . tuple_type , $ . function_type_parameter ] ,
84
84
[ $ . list , $ . list_pattern ] ,
85
85
[ $ . array , $ . array_pattern ] ,
86
- [ $ . record_field , $ . record_pattern ] ,
87
- [ $ . expression_statement , $ . ternary_expression ] ,
88
86
[ $ . type_declaration ] ,
89
- [ $ . type_binding ] ,
90
87
[ $ . let_declaration ] ,
91
- [ $ . let_declaration , $ . ternary_expression ] ,
92
88
[ $ . variant_identifier , $ . module_identifier ] ,
93
89
[ $ . variant , $ . variant_pattern ] ,
94
- [ $ . variant_declaration , $ . function_type_parameter ] ,
95
90
[ $ . variant_arguments , $ . _variant_pattern_parameters ] ,
96
91
[ $ . polyvar , $ . polyvar_pattern ] ,
97
92
[ $ . _pattern ] ,
98
- [ $ . _record_element , $ . jsx_expression ] ,
99
93
[ $ . _record_element , $ . _record_single_field ] ,
100
94
[ $ . _record_pun_field , $ . _record_single_pun_field ] ,
101
95
[ $ . _record_field_name , $ . record_pattern ] ,
102
- [ $ . decorator ] ,
103
96
[ $ . _statement , $ . _one_or_more_statements ] ,
104
97
[ $ . _inline_type , $ . function_type_parameters ] ,
105
98
[ $ . primary_expression , $ . parameter , $ . _pattern ] ,
106
99
[ $ . parameter , $ . _pattern ] ,
107
100
[ $ . parameter , $ . parenthesized_pattern ] ,
108
101
[ $ . parameter , $ . tuple_item_pattern ] ,
109
- [ $ . variant_declaration ] ,
110
102
[ $ . unit , $ . _function_type_parameter_list ] ,
111
103
[ $ . functor_parameter , $ . module_primary_expression , $ . module_identifier_path ] ,
112
104
[ $ . _reserved_identifier , $ . function ] ,
113
- [ $ . polyvar_type ] ,
114
- [ $ . let_binding , $ . or_pattern ] ,
115
105
[ $ . exception_pattern , $ . or_pattern ] ,
116
106
[ $ . type_binding , $ . _inline_type ] ,
117
107
[ $ . _module_structure , $ . parenthesized_module_expression ]
@@ -141,28 +131,12 @@ module.exports = grammar({
141
131
) ,
142
132
143
133
statement : $ => choice (
144
- alias ( $ . _decorated_statement , $ . decorated ) ,
145
- $ . decorator_statement ,
146
134
$ . expression_statement ,
147
135
$ . declaration ,
148
136
$ . open_statement ,
149
137
$ . include_statement ,
150
138
) ,
151
139
152
- _decorated_statement : $ => seq (
153
- repeat1 ( $ . decorator ) ,
154
- choice (
155
- $ . declaration ,
156
- $ . expression_statement
157
- )
158
- ) ,
159
-
160
- decorator_statement : $ => seq (
161
- '@@' ,
162
- $ . decorator_identifier ,
163
- optional ( $ . decorator_arguments )
164
- ) ,
165
-
166
140
block : $ => prec . right ( seq (
167
141
'{' ,
168
142
optional ( $ . _one_or_more_statements ) ,
@@ -282,7 +256,7 @@ module.exports = grammar({
282
256
'type' ,
283
257
optional ( 'rec' ) ,
284
258
sep1 (
285
- seq ( repeat ( $ . _newline ) , repeat ( $ . decorator ) , 'and' ) ,
259
+ seq ( repeat ( $ . _newline ) , 'and' ) ,
286
260
$ . type_binding
287
261
)
288
262
) ,
@@ -314,7 +288,6 @@ module.exports = grammar({
314
288
315
289
type_annotation : $ => seq (
316
290
':' ,
317
- repeat ( $ . decorator ) ,
318
291
$ . _inline_type ,
319
292
) ,
320
293
@@ -367,7 +340,6 @@ module.exports = grammar({
367
340
) ) ,
368
341
369
342
variant_declaration : $ => prec . right ( seq (
370
- repeat ( $ . decorator ) ,
371
343
$ . variant_identifier ,
372
344
optional ( $ . variant_parameters ) ,
373
345
optional ( $ . type_annotation ) ,
@@ -380,7 +352,6 @@ module.exports = grammar({
380
352
) ,
381
353
382
354
polyvar_type : $ => prec . left ( seq (
383
- repeat ( $ . decorator ) ,
384
355
choice ( '[' , '[>' , '[<' , ) ,
385
356
optional ( '|' ) ,
386
357
barSep1 ( $ . polyvar_declaration ) ,
@@ -390,7 +361,6 @@ module.exports = grammar({
390
361
polyvar_declaration : $ => prec . right (
391
362
choice (
392
363
seq (
393
- repeat ( $ . decorator ) ,
394
364
$ . polyvar_identifier ,
395
365
optional ( $ . polyvar_parameters ) ,
396
366
) ,
@@ -411,7 +381,6 @@ module.exports = grammar({
411
381
) ,
412
382
413
383
record_type_field : $ => seq (
414
- repeat ( $ . decorator ) ,
415
384
optional ( 'mutable' ) ,
416
385
alias ( $ . value_identifier , $ . property_identifier ) ,
417
386
optional ( '?' ) ,
@@ -433,7 +402,6 @@ module.exports = grammar({
433
402
object_type_field : $ => choice (
434
403
seq ( '...' , choice ( $ . type_identifier , $ . type_identifier_path ) ) ,
435
404
seq (
436
- repeat ( $ . decorator ) ,
437
405
alias ( $ . string , $ . property_identifier ) ,
438
406
':' ,
439
407
$ . _type ,
@@ -471,7 +439,6 @@ module.exports = grammar({
471
439
472
440
function_type_parameter : $ => seq (
473
441
optional ( $ . uncurry ) ,
474
- repeat ( $ . decorator ) ,
475
442
choice (
476
443
$ . _type ,
477
444
seq ( $ . uncurry , $ . _type ) ,
@@ -483,7 +450,7 @@ module.exports = grammar({
483
450
choice ( 'export' , 'let' ) ,
484
451
optional ( 'rec' ) ,
485
452
sep1 (
486
- seq ( repeat ( $ . _newline ) , repeat ( $ . decorator ) , 'and' ) ,
453
+ seq ( repeat ( $ . _newline ) , 'and' ) ,
487
454
$ . let_binding
488
455
)
489
456
) ,
@@ -495,14 +462,12 @@ module.exports = grammar({
495
462
$ . type_annotation ,
496
463
optional (
497
464
seq ( '=' ,
498
- repeat ( $ . decorator ) ,
499
465
field ( 'body' , $ . expression )
500
466
)
501
467
)
502
468
) ,
503
469
seq (
504
470
'=' ,
505
- repeat ( $ . decorator ) ,
506
471
field ( 'body' , $ . expression ) ,
507
472
)
508
473
)
@@ -559,7 +524,6 @@ module.exports = grammar({
559
524
560
525
parenthesized_expression : $ => seq (
561
526
'(' ,
562
- repeat ( $ . decorator ) ,
563
527
$ . expression ,
564
528
optional ( $ . type_annotation ) ,
565
529
')'
@@ -578,7 +542,6 @@ module.exports = grammar({
578
542
$ . _definition_signature
579
543
) ,
580
544
'=>' ,
581
- repeat ( $ . decorator ) ,
582
545
field ( 'body' , $ . expression ) ,
583
546
) ) ,
584
547
@@ -647,27 +610,21 @@ module.exports = grammar({
647
610
tuple : $ => seq (
648
611
'(' ,
649
612
commaSep2t (
650
- seq ( repeat ( $ . decorator ) , $ . expression )
613
+ $ . expression
651
614
) ,
652
615
')' ,
653
616
) ,
654
617
655
618
array : $ => seq (
656
619
'[' ,
657
- commaSept (
658
- seq ( repeat ( $ . decorator ) , $ . expression )
659
- ) ,
620
+ commaSept ( $ . expression ) ,
660
621
']'
661
622
) ,
662
623
663
624
list : $ => seq (
664
625
$ . _list_constructor ,
665
626
'{' ,
666
- optional (
667
- commaSep1t (
668
- seq ( repeat ( $ . decorator ) , $ . _list_element )
669
- )
670
- ) ,
627
+ optional ( commaSep1t ( $ . _list_element ) ) ,
671
628
'}'
672
629
) ,
673
630
@@ -773,7 +730,6 @@ module.exports = grammar({
773
730
774
731
_call_argument : $ => choice (
775
732
seq (
776
- repeat ( $ . decorator ) ,
777
733
$ . expression ,
778
734
optional ( $ . type_annotation ) ,
779
735
) ,
@@ -788,7 +744,6 @@ module.exports = grammar({
788
744
seq (
789
745
'=' ,
790
746
optional ( '?' ) ,
791
- repeat ( $ . decorator ) ,
792
747
field ( 'value' , $ . expression ) ,
793
748
optional ( field ( 'type' , $ . type_annotation ) ) ,
794
749
) ,
@@ -933,7 +888,6 @@ module.exports = grammar({
933
888
) ,
934
889
935
890
tuple_item_pattern : $ => seq (
936
- repeat ( $ . decorator ) ,
937
891
$ . _pattern ,
938
892
optional ( $ . type_annotation ) ,
939
893
) ,
@@ -947,17 +901,15 @@ module.exports = grammar({
947
901
array_pattern : $ => seq (
948
902
'[' ,
949
903
optional ( commaSep1t (
950
- seq ( repeat ( $ . decorator ) , $ . _collection_element_pattern )
904
+ $ . _collection_element_pattern
951
905
) ) ,
952
906
']' ,
953
907
) ,
954
908
955
909
list_pattern : $ => seq (
956
910
$ . _list_constructor ,
957
911
'{' ,
958
- optional ( commaSep1t (
959
- seq ( repeat ( $ . decorator ) , $ . _collection_element_pattern )
960
- ) ) ,
912
+ optional ( commaSep1t ( $ . _collection_element_pattern ) ) ,
961
913
'}' ,
962
914
) ,
963
915
@@ -1089,10 +1041,9 @@ module.exports = grammar({
1089
1041
$ . expression ,
1090
1042
) ,
1091
1043
1092
- decorator : $ => seq (
1093
- '@' ,
1094
- $ . decorator_identifier ,
1095
- optional ( $ . decorator_arguments )
1044
+ decorator : $ => choice (
1045
+ alias ( $ . _decorator_inline , $ . decorator_identifier ) ,
1046
+ seq ( alias ( $ . _decorator , $ . decorator_identifier ) , $ . decorator_arguments )
1096
1047
) ,
1097
1048
1098
1049
decorator_arguments : $ => seq (
@@ -1365,8 +1316,6 @@ module.exports = grammar({
1365
1316
1366
1317
module_identifier : $ => / [ A - Z ] [ a - z A - Z 0 - 9 _ ' ] * / ,
1367
1318
1368
- decorator_identifier : $ => / [ a - z A - Z 0 - 9 _ \. ] + / ,
1369
-
1370
1319
extension_identifier : $ => / [ a - z A - Z 0 - 9 _ \. ] + / ,
1371
1320
1372
1321
number : $ => {
0 commit comments