@@ -107,7 +107,8 @@ module.exports = grammar({
107107 [ $ . variant_declaration ] ,
108108 [ $ . unit , $ . _function_type_parameter_list ] ,
109109 [ $ . functor_parameter , $ . module_primary_expression , $ . module_identifier_path ] ,
110- [ $ . _reserved_identifier , $ . function ]
110+ [ $ . _reserved_identifier , $ . function ] ,
111+ [ $ . polyvar_type ]
111112 ] ,
112113
113114 rules : {
@@ -260,20 +261,22 @@ module.exports = grammar({
260261 optional ( 'export' ) ,
261262 'type' ,
262263 optional ( 'rec' ) ,
263- $ . _type_declaration ,
264+ $ . _type_declaration
264265 ) ,
265266
266267 _type_declaration : $ => seq (
267268 choice ( $ . type_identifier , $ . type_identifier_path ) ,
268269 optional ( $ . type_parameters ) ,
269270 optional ( seq (
270- choice ( '=' , '+=' ) ,
271- optional ( 'private' ) ,
272- $ . _type ,
273- repeat ( $ . type_constraint ) ,
274271 optional ( seq ( '=' , $ . _type ) ) ,
275- optional ( alias ( $ . _type_declaration_and , $ . type_declaration ) ) ,
272+ optional ( seq (
273+ choice ( '=' , '+=' ) ,
274+ optional ( 'private' ) ,
275+ $ . _type ,
276+ ) ) ,
277+ repeat ( $ . type_constraint ) ,
276278 ) ) ,
279+ optional ( alias ( $ . _type_declaration_and , $ . type_declaration ) )
277280 ) ,
278281
279282 _type_declaration_and : $ => seq (
@@ -363,6 +366,7 @@ module.exports = grammar({
363366 ) ,
364367
365368 polyvar_type : $ => prec . left ( seq (
369+ repeat ( $ . decorator ) ,
366370 choice ( '[' , '[>' , '[<' , ) ,
367371 optional ( '|' ) ,
368372 barSep1 ( $ . polyvar_declaration ) ,
@@ -373,7 +377,7 @@ module.exports = grammar({
373377 polyvar_declaration : $ => prec . right (
374378 choice (
375379 seq (
376- optional ( $ . decorator ) ,
380+ repeat ( $ . decorator ) ,
377381 $ . polyvar_identifier ,
378382 optional ( $ . polyvar_parameters ) ,
379383 ) ,
@@ -425,10 +429,11 @@ module.exports = grammar({
425429
426430 ) ,
427431
428- generic_type : $ => seq (
432+ generic_type : $ => prec . left ( seq (
429433 $ . _type_identifier ,
430- $ . type_arguments
431- ) ,
434+ $ . type_arguments ,
435+ optional ( $ . as_aliasing_type )
436+ ) ) ,
432437
433438 type_arguments : $ => seq (
434439 '<' ,
@@ -627,20 +632,28 @@ module.exports = grammar({
627632
628633 tuple : $ => seq (
629634 '(' ,
630- commaSep2t ( $ . expression ) ,
635+ commaSep2t (
636+ seq ( repeat ( $ . decorator ) , $ . expression )
637+ ) ,
631638 ')' ,
632639 ) ,
633640
634641 array : $ => seq (
635642 '[' ,
636- commaSept ( $ . expression ) ,
643+ commaSept (
644+ seq ( repeat ( $ . decorator ) , $ . expression )
645+ ) ,
637646 ']'
638647 ) ,
639648
640649 list : $ => seq (
641650 $ . _list_constructor ,
642651 '{' ,
643- optional ( commaSep1t ( $ . _list_element ) ) ,
652+ optional (
653+ commaSep1t (
654+ seq ( repeat ( $ . decorator ) , $ . _list_element )
655+ )
656+ ) ,
644657 '}'
645658 ) ,
646659
@@ -798,6 +811,7 @@ module.exports = grammar({
798811 seq (
799812 '=' ,
800813 optional ( '?' ) ,
814+ repeat ( $ . decorator ) ,
801815 field ( 'value' , $ . expression ) ,
802816 optional ( field ( 'type' , $ . type_annotation ) ) ,
803817 ) ,
@@ -930,20 +944,29 @@ module.exports = grammar({
930944
931945 tuple_pattern : $ => seq (
932946 '(' ,
933- commaSep2t ( alias ( $ . _pattern , $ . tuple_item_pattern ) ) ,
947+ commaSep2t (
948+ alias (
949+ seq ( repeat ( $ . decorator ) , $ . _pattern ) ,
950+ $ . tuple_item_pattern
951+ )
952+ ) ,
934953 ')' ,
935954 ) ,
936955
937956 array_pattern : $ => seq (
938957 '[' ,
939- optional ( commaSep1t ( $ . _collection_element_pattern ) ) ,
958+ optional ( commaSep1t (
959+ seq ( repeat ( $ . decorator ) , $ . _collection_element_pattern )
960+ ) ) ,
940961 ']' ,
941962 ) ,
942963
943964 list_pattern : $ => seq (
944965 $ . _list_constructor ,
945966 '{' ,
946- optional ( commaSep1t ( $ . _collection_element_pattern ) ) ,
967+ optional ( commaSep1t (
968+ seq ( repeat ( $ . decorator ) , $ . _collection_element_pattern )
969+ ) ) ,
947970 '}' ,
948971 ) ,
949972
0 commit comments