@@ -399,11 +399,12 @@ module.exports = grammar({
399
399
400
400
message_value : ( $ ) => seq ( "(" , $ . _expression , ")" ) ,
401
401
402
- struct_body : ( $ ) => seq ( "{" , semicolonSepWithTrailing ( $ . field ) , "}" ) ,
402
+ struct_body : ( $ ) => seq ( "{" , repeat ( $ . field ) , "}" ) ,
403
403
404
404
/* Fields (of messages, structs, contracts, traits) */
405
405
406
- field : ( $ ) => seq ( field ( "name" , $ . identifier ) , $ . _field_after_id ) ,
406
+ field : ( $ ) =>
407
+ seq ( field ( "name" , $ . identifier ) , $ . _field_after_id , optional ( ";" ) ) ,
407
408
408
409
// Like _constant, but without a semicolon at the end
409
410
storage_constant : ( $ ) =>
@@ -420,12 +421,14 @@ module.exports = grammar({
420
421
seq ( field ( "name" , $ . identifier ) , $ . _field_after_id ) ,
421
422
422
423
_field_after_id : ( $ ) =>
423
- seq (
424
- ":" ,
425
- field ( "type" , $ . _type ) ,
426
- field ( "_completion_anchor" , optional ( $ . identifier ) ) ,
427
- field ( "tlb" , optional ( $ . tlb_serialization ) ) ,
428
- optional ( seq ( "=" , field ( "value" , $ . _expression ) ) ) ,
424
+ prec . left (
425
+ seq (
426
+ ":" ,
427
+ field ( "type" , $ . _type ) ,
428
+ field ( "_completion_anchor" , optional ( $ . identifier ) ) ,
429
+ field ( "tlb" , optional ( $ . tlb_serialization ) ) ,
430
+ optional ( seq ( "=" , field ( "value" , $ . _expression ) ) ) ,
431
+ ) ,
429
432
) ,
430
433
431
434
/* Contracts, Traits */
@@ -465,13 +468,13 @@ module.exports = grammar({
465
468
"{" ,
466
469
repeat (
467
470
choice (
468
- seq ( $ . _body_item_without_semicolon , ";" ) ,
471
+ seq ( $ . storage_constant , optional ( ";" ) ) ,
472
+ seq ( $ . storage_variable , optional ( ";" ) ) ,
469
473
$ . init_function ,
470
474
$ . _receiver_function ,
471
475
alias ( $ . _function_definition , $ . storage_function ) ,
472
476
) ,
473
477
) ,
474
- optional ( $ . _body_item_without_semicolon ) ,
475
478
"}" ,
476
479
) ,
477
480
@@ -480,22 +483,15 @@ module.exports = grammar({
480
483
"{" ,
481
484
repeat (
482
485
choice (
483
- seq ( $ . _body_item_without_semicolon , ";" ) ,
486
+ seq ( $ . storage_constant , optional ( ";" ) ) ,
487
+ seq ( $ . storage_variable , optional ( ";" ) ) ,
484
488
$ . _receiver_function ,
485
489
alias ( $ . _function_definition , $ . storage_function ) ,
486
490
) ,
487
491
) ,
488
- optional ( $ . _body_item_without_semicolon ) ,
489
492
"}" ,
490
493
) ,
491
494
492
- _body_item_without_semicolon : ( $ ) =>
493
- choice (
494
- $ . storage_constant ,
495
- $ . storage_variable ,
496
- alias ( $ . _function_declaration , $ . storage_function ) ,
497
- ) ,
498
-
499
495
init_function : ( $ ) =>
500
496
seq (
501
497
"init" ,
0 commit comments