@@ -229,6 +229,8 @@ module.exports = grammar({
229229 ']' ,
230230 ) ,
231231
232+ _attribute_list : $ => choice ( $ . attribute_list , $ . preproc_if_in_attribute_list ) ,
233+
232234 attribute_target_specifier : _ => seq (
233235 choice ( 'field' , 'event' , 'method' , 'param' , 'property' , 'return' , 'type' ) ,
234236 ':' ,
@@ -267,7 +269,7 @@ module.exports = grammar({
267269 ) ,
268270
269271 _class_declaration_initializer : $ => seq (
270- repeat ( $ . attribute_list ) ,
272+ repeat ( $ . _attribute_list ) ,
271273 repeat ( $ . modifier ) ,
272274 'class' ,
273275 field ( 'name' , $ . identifier ) ,
@@ -283,7 +285,7 @@ module.exports = grammar({
283285 ) ,
284286
285287 _struct_declaration_initializer : $ => seq (
286- repeat ( $ . attribute_list ) ,
288+ repeat ( $ . _attribute_list ) ,
287289 repeat ( $ . modifier ) ,
288290 optional ( 'ref' ) ,
289291 'struct' ,
@@ -293,7 +295,7 @@ module.exports = grammar({
293295 ) ,
294296
295297 enum_declaration : $ => seq (
296- repeat ( $ . attribute_list ) ,
298+ repeat ( $ . _attribute_list ) ,
297299 repeat ( $ . modifier ) ,
298300 'enum' ,
299301 field ( 'name' , $ . identifier ) ,
@@ -313,7 +315,7 @@ module.exports = grammar({
313315 ) ,
314316
315317 enum_member_declaration : $ => seq (
316- repeat ( $ . attribute_list ) ,
318+ repeat ( $ . _attribute_list ) ,
317319 field ( 'name' , $ . identifier ) ,
318320 optional ( seq ( '=' , field ( 'value' , $ . expression ) ) ) ,
319321 ) ,
@@ -325,7 +327,7 @@ module.exports = grammar({
325327 ) ,
326328
327329 _interface_declaration_initializer : $ => seq (
328- repeat ( $ . attribute_list ) ,
330+ repeat ( $ . _attribute_list ) ,
329331 repeat ( $ . modifier ) ,
330332 'interface' ,
331333 field ( 'name' , $ . identifier ) ,
@@ -341,7 +343,7 @@ module.exports = grammar({
341343 ) ,
342344
343345 _delegate_declaration_initializer : $ => seq (
344- repeat ( $ . attribute_list ) ,
346+ repeat ( $ . _attribute_list ) ,
345347 repeat ( $ . modifier ) ,
346348 'delegate' ,
347349 field ( 'type' , $ . type ) ,
@@ -357,7 +359,7 @@ module.exports = grammar({
357359 ) ,
358360
359361 _record_declaration_initializer : $ => seq (
360- repeat ( $ . attribute_list ) ,
362+ repeat ( $ . _attribute_list ) ,
361363 repeat ( $ . modifier ) ,
362364 'record' ,
363365 optional ( choice ( 'class' , 'struct' ) ) ,
@@ -406,7 +408,7 @@ module.exports = grammar({
406408 type_parameter_list : $ => seq ( '<' , commaSep1 ( $ . type_parameter ) , '>' ) ,
407409
408410 type_parameter : $ => seq (
409- repeat ( $ . attribute_list ) ,
411+ repeat ( $ . _attribute_list ) ,
410412 optional ( choice ( 'in' , 'out' ) ) ,
411413 field ( 'name' , $ . identifier ) ,
412414 ) ,
@@ -432,7 +434,7 @@ module.exports = grammar({
432434 constructor_constraint : _ => seq ( 'new' , '(' , ')' ) ,
433435
434436 operator_declaration : $ => seq (
435- repeat ( $ . attribute_list ) ,
437+ repeat ( $ . _attribute_list ) ,
436438 repeat ( $ . modifier ) ,
437439 field ( 'type' , $ . type ) ,
438440 optional ( $ . explicit_interface_specifier ) ,
@@ -459,7 +461,7 @@ module.exports = grammar({
459461 ) ,
460462
461463 conversion_operator_declaration : $ => seq (
462- repeat ( $ . attribute_list ) ,
464+ repeat ( $ . _attribute_list ) ,
463465 repeat ( $ . modifier ) ,
464466 choice (
465467 'implicit' ,
@@ -504,7 +506,7 @@ module.exports = grammar({
504506 ) ,
505507
506508 field_declaration : $ => seq (
507- repeat ( $ . attribute_list ) ,
509+ repeat ( $ . _attribute_list ) ,
508510 repeat ( $ . modifier ) ,
509511 $ . variable_declaration ,
510512 ';' ,
@@ -516,15 +518,15 @@ module.exports = grammar({
516518 ) ,
517519
518520 _constructor_declaration_initializer : $ => seq (
519- repeat ( $ . attribute_list ) ,
521+ repeat ( $ . _attribute_list ) ,
520522 repeat ( $ . modifier ) ,
521523 field ( 'name' , $ . identifier ) ,
522524 field ( 'parameters' , $ . parameter_list ) ,
523525 optional ( $ . constructor_initializer ) ,
524526 ) ,
525527
526528 destructor_declaration : $ => seq (
527- repeat ( $ . attribute_list ) ,
529+ repeat ( $ . _attribute_list ) ,
528530 optional ( 'extern' ) ,
529531 '~' ,
530532 field ( 'name' , $ . identifier ) ,
@@ -533,7 +535,7 @@ module.exports = grammar({
533535 ) ,
534536
535537 method_declaration : $ => seq (
536- repeat ( $ . attribute_list ) ,
538+ repeat ( $ . _attribute_list ) ,
537539 repeat ( $ . modifier ) ,
538540 field ( 'returns' , $ . type ) ,
539541 optional ( $ . explicit_interface_specifier ) ,
@@ -545,7 +547,7 @@ module.exports = grammar({
545547 ) ,
546548
547549 event_declaration : $ => seq (
548- repeat ( $ . attribute_list ) ,
550+ repeat ( $ . _attribute_list ) ,
549551 repeat ( $ . modifier ) ,
550552 'event' ,
551553 field ( 'type' , $ . type ) ,
@@ -558,7 +560,7 @@ module.exports = grammar({
558560 ) ,
559561
560562 event_field_declaration : $ => prec . dynamic ( 1 , seq (
561- repeat ( $ . attribute_list ) ,
563+ repeat ( $ . _attribute_list ) ,
562564 repeat ( $ . modifier ) ,
563565 'event' ,
564566 $ . variable_declaration ,
@@ -572,14 +574,14 @@ module.exports = grammar({
572574 ) ,
573575
574576 accessor_declaration : $ => seq (
575- repeat ( $ . attribute_list ) ,
577+ repeat ( $ . _attribute_list ) ,
576578 repeat ( $ . modifier ) ,
577579 field ( 'name' , choice ( 'get' , 'set' , 'add' , 'remove' , 'init' , $ . identifier ) ) ,
578580 $ . _function_body ,
579581 ) ,
580582
581583 indexer_declaration : $ => seq (
582- repeat ( $ . attribute_list ) ,
584+ repeat ( $ . _attribute_list ) ,
583585 repeat ( $ . modifier ) ,
584586 field ( 'type' , $ . type ) ,
585587 optional ( $ . explicit_interface_specifier ) ,
@@ -598,7 +600,7 @@ module.exports = grammar({
598600 ) ,
599601
600602 property_declaration : $ => seq (
601- repeat ( $ . attribute_list ) ,
603+ repeat ( $ . _attribute_list ) ,
602604 repeat ( $ . modifier ) ,
603605 field ( 'type' , $ . type ) ,
604606 optional ( $ . explicit_interface_specifier ) ,
@@ -635,14 +637,14 @@ module.exports = grammar({
635637 ) ,
636638
637639 parameter : $ => seq (
638- repeat ( $ . attribute_list ) ,
640+ repeat ( $ . _attribute_list ) ,
639641 optional ( $ . _parameter_type_with_modifiers ) ,
640642 field ( 'name' , $ . identifier ) ,
641643 optional ( seq ( '=' , $ . expression ) ) ,
642644 ) ,
643645
644646 _parameter_array : $ => seq (
645- repeat ( $ . attribute_list ) ,
647+ repeat ( $ . _attribute_list ) ,
646648 'params' ,
647649 field ( 'type' , choice ( $ . array_type , $ . nullable_type ) ) ,
648650 field ( 'name' , $ . identifier ) ,
@@ -1117,7 +1119,7 @@ module.exports = grammar({
11171119 ) ,
11181120
11191121 _local_function_declaration : $ => seq (
1120- repeat ( $ . attribute_list ) ,
1122+ repeat ( $ . _attribute_list ) ,
11211123 repeat ( $ . modifier ) ,
11221124 field ( 'type' , $ . type ) ,
11231125 field ( 'name' , $ . identifier ) ,
@@ -1623,7 +1625,7 @@ module.exports = grammar({
16231625 ) ) ,
16241626
16251627 _lambda_expression_init : $ => prec ( - 1 , seq (
1626- repeat ( $ . attribute_list ) ,
1628+ repeat ( $ . _attribute_list ) ,
16271629 repeat ( prec ( - 1 , alias ( choice ( 'static' , 'async' ) , $ . modifier ) ) ) ,
16281630 optional ( field ( 'type' , $ . type ) ) ,
16291631 field ( 'parameters' , $ . _lambda_parameters ) ,
@@ -1912,6 +1914,7 @@ module.exports = grammar({
19121914 ...preprocIf ( '_in_top_level' , $ => choice ( $ . _top_level_item_no_statement , $ . statement ) ) ,
19131915 ...preprocIf ( '_in_expression' , $ => $ . expression , - 2 , false ) ,
19141916 ...preprocIf ( '_in_enum_member_declaration' , $ => $ . enum_member_declaration , 0 , false ) ,
1917+ ...preprocIf ( '_in_attribute_list' , $ => $ . attribute_list , - 1 , false ) ,
19151918
19161919 preproc_arg : _ => token ( prec ( - 1 , / \S ( [ ^ / \n ] | \/ [ ^ * ] | \\ \r ? \n ) * / ) ) ,
19171920 preproc_directive : _ => / # [ \t ] * [ a - z A - Z 0 - 9 ] \w * / ,
0 commit comments