@@ -10,11 +10,14 @@ module.exports = grammar({
1010 $ . _template_chars ,
1111 $ . _lparen ,
1212 $ . _rparen ,
13- $ . _list_constructor
13+ $ . _list_constructor ,
14+ $ . _decorator ,
15+ $ . _decorator_inline ,
1416 ] ,
1517
1618 extras : $ => [
1719 $ . comment ,
20+ $ . decorator ,
1821 / [ \s \uFEFF \u2060 \u200B \u00A0 ] /
1922 ] ,
2023
@@ -77,41 +80,28 @@ module.exports = grammar({
7780 [ $ . primary_expression , $ . _literal_pattern ] ,
7881 [ $ . primary_expression , $ . lazy_pattern ] ,
7982 [ $ . primary_expression , $ . _jsx_child ] ,
80- [ $ . tuple_pattern , $ . parameter ] ,
81- [ $ . primary_expression , $ . parameter ] ,
82- [ $ . primary_expression , $ . record_field ] ,
8383 [ $ . tuple_type , $ . function_type_parameter ] ,
8484 [ $ . list , $ . list_pattern ] ,
8585 [ $ . array , $ . array_pattern ] ,
86- [ $ . record_field , $ . record_pattern ] ,
87- [ $ . expression_statement , $ . ternary_expression ] ,
8886 [ $ . type_declaration ] ,
89- [ $ . type_binding ] ,
9087 [ $ . let_declaration ] ,
91- [ $ . let_declaration , $ . ternary_expression ] ,
9288 [ $ . variant_identifier , $ . module_identifier ] ,
9389 [ $ . variant , $ . variant_pattern ] ,
94- [ $ . variant_declaration , $ . function_type_parameter ] ,
9590 [ $ . variant_arguments , $ . _variant_pattern_parameters ] ,
9691 [ $ . polyvar , $ . polyvar_pattern ] ,
9792 [ $ . _pattern ] ,
98- [ $ . _record_element , $ . jsx_expression ] ,
9993 [ $ . _record_element , $ . _record_single_field ] ,
10094 [ $ . _record_pun_field , $ . _record_single_pun_field ] ,
10195 [ $ . _record_field_name , $ . record_pattern ] ,
102- [ $ . decorator ] ,
10396 [ $ . _statement , $ . _one_or_more_statements ] ,
10497 [ $ . _inline_type , $ . function_type_parameters ] ,
10598 [ $ . primary_expression , $ . parameter , $ . _pattern ] ,
10699 [ $ . parameter , $ . _pattern ] ,
107100 [ $ . parameter , $ . parenthesized_pattern ] ,
108101 [ $ . parameter , $ . tuple_item_pattern ] ,
109- [ $ . variant_declaration ] ,
110102 [ $ . unit , $ . _function_type_parameter_list ] ,
111103 [ $ . functor_parameter , $ . module_primary_expression , $ . module_identifier_path ] ,
112104 [ $ . _reserved_identifier , $ . function ] ,
113- [ $ . polyvar_type ] ,
114- [ $ . let_binding , $ . or_pattern ] ,
115105 [ $ . exception_pattern , $ . or_pattern ] ,
116106 [ $ . type_binding , $ . _inline_type ] ,
117107 [ $ . _module_structure , $ . parenthesized_module_expression ]
@@ -141,28 +131,12 @@ module.exports = grammar({
141131 ) ,
142132
143133 statement : $ => choice (
144- alias ( $ . _decorated_statement , $ . decorated ) ,
145- $ . decorator_statement ,
146134 $ . expression_statement ,
147135 $ . declaration ,
148136 $ . open_statement ,
149137 $ . include_statement ,
150138 ) ,
151139
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-
166140 block : $ => prec . right ( seq (
167141 '{' ,
168142 optional ( $ . _one_or_more_statements ) ,
@@ -282,7 +256,7 @@ module.exports = grammar({
282256 'type' ,
283257 optional ( 'rec' ) ,
284258 sep1 (
285- seq ( repeat ( $ . _newline ) , repeat ( $ . decorator ) , 'and' ) ,
259+ seq ( repeat ( $ . _newline ) , 'and' ) ,
286260 $ . type_binding
287261 )
288262 ) ,
@@ -314,7 +288,6 @@ module.exports = grammar({
314288
315289 type_annotation : $ => seq (
316290 ':' ,
317- repeat ( $ . decorator ) ,
318291 $ . _inline_type ,
319292 ) ,
320293
@@ -367,7 +340,6 @@ module.exports = grammar({
367340 ) ) ,
368341
369342 variant_declaration : $ => prec . right ( seq (
370- repeat ( $ . decorator ) ,
371343 $ . variant_identifier ,
372344 optional ( $ . variant_parameters ) ,
373345 optional ( $ . type_annotation ) ,
@@ -380,7 +352,6 @@ module.exports = grammar({
380352 ) ,
381353
382354 polyvar_type : $ => prec . left ( seq (
383- repeat ( $ . decorator ) ,
384355 choice ( '[' , '[>' , '[<' , ) ,
385356 optional ( '|' ) ,
386357 barSep1 ( $ . polyvar_declaration ) ,
@@ -390,7 +361,6 @@ module.exports = grammar({
390361 polyvar_declaration : $ => prec . right (
391362 choice (
392363 seq (
393- repeat ( $ . decorator ) ,
394364 $ . polyvar_identifier ,
395365 optional ( $ . polyvar_parameters ) ,
396366 ) ,
@@ -411,7 +381,6 @@ module.exports = grammar({
411381 ) ,
412382
413383 record_type_field : $ => seq (
414- repeat ( $ . decorator ) ,
415384 optional ( 'mutable' ) ,
416385 alias ( $ . value_identifier , $ . property_identifier ) ,
417386 optional ( '?' ) ,
@@ -433,7 +402,6 @@ module.exports = grammar({
433402 object_type_field : $ => choice (
434403 seq ( '...' , choice ( $ . type_identifier , $ . type_identifier_path ) ) ,
435404 seq (
436- repeat ( $ . decorator ) ,
437405 alias ( $ . string , $ . property_identifier ) ,
438406 ':' ,
439407 $ . _type ,
@@ -471,7 +439,6 @@ module.exports = grammar({
471439
472440 function_type_parameter : $ => seq (
473441 optional ( $ . uncurry ) ,
474- repeat ( $ . decorator ) ,
475442 choice (
476443 $ . _type ,
477444 seq ( $ . uncurry , $ . _type ) ,
@@ -483,7 +450,7 @@ module.exports = grammar({
483450 choice ( 'export' , 'let' ) ,
484451 optional ( 'rec' ) ,
485452 sep1 (
486- seq ( repeat ( $ . _newline ) , repeat ( $ . decorator ) , 'and' ) ,
453+ seq ( repeat ( $ . _newline ) , 'and' ) ,
487454 $ . let_binding
488455 )
489456 ) ,
@@ -495,14 +462,12 @@ module.exports = grammar({
495462 $ . type_annotation ,
496463 optional (
497464 seq ( '=' ,
498- repeat ( $ . decorator ) ,
499465 field ( 'body' , $ . expression )
500466 )
501467 )
502468 ) ,
503469 seq (
504470 '=' ,
505- repeat ( $ . decorator ) ,
506471 field ( 'body' , $ . expression ) ,
507472 )
508473 )
@@ -559,7 +524,6 @@ module.exports = grammar({
559524
560525 parenthesized_expression : $ => seq (
561526 '(' ,
562- repeat ( $ . decorator ) ,
563527 $ . expression ,
564528 optional ( $ . type_annotation ) ,
565529 ')'
@@ -578,7 +542,6 @@ module.exports = grammar({
578542 $ . _definition_signature
579543 ) ,
580544 '=>' ,
581- repeat ( $ . decorator ) ,
582545 field ( 'body' , $ . expression ) ,
583546 ) ) ,
584547
@@ -647,27 +610,21 @@ module.exports = grammar({
647610 tuple : $ => seq (
648611 '(' ,
649612 commaSep2t (
650- seq ( repeat ( $ . decorator ) , $ . expression )
613+ $ . expression
651614 ) ,
652615 ')' ,
653616 ) ,
654617
655618 array : $ => seq (
656619 '[' ,
657- commaSept (
658- seq ( repeat ( $ . decorator ) , $ . expression )
659- ) ,
620+ commaSept ( $ . expression ) ,
660621 ']'
661622 ) ,
662623
663624 list : $ => seq (
664625 $ . _list_constructor ,
665626 '{' ,
666- optional (
667- commaSep1t (
668- seq ( repeat ( $ . decorator ) , $ . _list_element )
669- )
670- ) ,
627+ optional ( commaSep1t ( $ . _list_element ) ) ,
671628 '}'
672629 ) ,
673630
@@ -773,7 +730,6 @@ module.exports = grammar({
773730
774731 _call_argument : $ => choice (
775732 seq (
776- repeat ( $ . decorator ) ,
777733 $ . expression ,
778734 optional ( $ . type_annotation ) ,
779735 ) ,
@@ -788,7 +744,6 @@ module.exports = grammar({
788744 seq (
789745 '=' ,
790746 optional ( '?' ) ,
791- repeat ( $ . decorator ) ,
792747 field ( 'value' , $ . expression ) ,
793748 optional ( field ( 'type' , $ . type_annotation ) ) ,
794749 ) ,
@@ -933,7 +888,6 @@ module.exports = grammar({
933888 ) ,
934889
935890 tuple_item_pattern : $ => seq (
936- repeat ( $ . decorator ) ,
937891 $ . _pattern ,
938892 optional ( $ . type_annotation ) ,
939893 ) ,
@@ -947,17 +901,15 @@ module.exports = grammar({
947901 array_pattern : $ => seq (
948902 '[' ,
949903 optional ( commaSep1t (
950- seq ( repeat ( $ . decorator ) , $ . _collection_element_pattern )
904+ $ . _collection_element_pattern
951905 ) ) ,
952906 ']' ,
953907 ) ,
954908
955909 list_pattern : $ => seq (
956910 $ . _list_constructor ,
957911 '{' ,
958- optional ( commaSep1t (
959- seq ( repeat ( $ . decorator ) , $ . _collection_element_pattern )
960- ) ) ,
912+ optional ( commaSep1t ( $ . _collection_element_pattern ) ) ,
961913 '}' ,
962914 ) ,
963915
@@ -1089,10 +1041,9 @@ module.exports = grammar({
10891041 $ . expression ,
10901042 ) ,
10911043
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 )
10961047 ) ,
10971048
10981049 decorator_arguments : $ => seq (
@@ -1365,8 +1316,6 @@ module.exports = grammar({
13651316
13661317 module_identifier : $ => / [ A - Z ] [ a - z A - Z 0 - 9 _ ' ] * / ,
13671318
1368- decorator_identifier : $ => / [ a - z A - Z 0 - 9 _ \. ] + / ,
1369-
13701319 extension_identifier : $ => / [ a - z A - Z 0 - 9 _ \. ] + / ,
13711320
13721321 number : $ => {
0 commit comments