@@ -104,6 +104,7 @@ module.exports = grammar({
104
104
] ,
105
105
106
106
supertypes : $ => [
107
+ $ . _specification_parts ,
107
108
$ . _expression ,
108
109
$ . _statements ,
109
110
$ . _argument_item ,
@@ -534,27 +535,13 @@ module.exports = grammar({
534
535
// Variable Declarations
535
536
536
537
_specification_part : $ => prec ( 1 , choice (
537
- $ . include_statement ,
538
- seq ( $ . use_statement , $ . _end_of_statement ) ,
539
- seq ( $ . implicit_statement , $ . _end_of_statement ) ,
540
- seq ( $ . save_statement , $ . _end_of_statement ) ,
541
- seq ( $ . import_statement , $ . _end_of_statement ) ,
542
- $ . public_statement ,
543
- $ . private_statement ,
544
- $ . enum ,
545
- $ . enumeration_type ,
546
- $ . interface ,
547
- $ . derived_type_definition ,
548
- seq ( $ . namelist_statement , $ . _end_of_statement ) ,
549
- seq ( $ . common_statement , $ . _end_of_statement ) ,
550
- seq ( $ . variable_declaration , $ . _end_of_statement ) ,
551
- seq ( $ . variable_modification , $ . _end_of_statement ) ,
552
- seq ( $ . parameter_statement , $ . _end_of_statement ) ,
553
- seq ( $ . equivalence_statement , $ . _end_of_statement ) ,
554
- seq ( $ . data_statement , $ . _end_of_statement ) ,
538
+ // Split out so it can be used as a supertype
539
+ $ . _specification_parts ,
540
+ // This catches statement functions, which are completely ambiguous
555
541
seq ( $ . assignment_statement , $ . _end_of_statement ) ,
542
+ // This allows format statements in the specification part,
543
+ // without making the statements rule particularly awkward
556
544
prec ( 1 , seq ( $ . statement_label , $ . format_statement , $ . _end_of_statement ) ) ,
557
- $ . cray_pointer_declaration ,
558
545
$ . preproc_include ,
559
546
$ . preproc_def ,
560
547
$ . preproc_function_def ,
@@ -564,6 +551,28 @@ module.exports = grammar({
564
551
';' ,
565
552
) ) ,
566
553
554
+ _specification_parts : $ => prec ( 1 , choice (
555
+ $ . include_statement ,
556
+ $ . use_statement ,
557
+ $ . implicit_statement ,
558
+ $ . save_statement ,
559
+ $ . import_statement ,
560
+ $ . public_statement ,
561
+ $ . private_statement ,
562
+ $ . enum ,
563
+ $ . enumeration_type ,
564
+ $ . interface ,
565
+ $ . derived_type_definition ,
566
+ $ . namelist_statement ,
567
+ $ . common_statement ,
568
+ $ . variable_declaration ,
569
+ $ . variable_modification ,
570
+ $ . parameter_statement ,
571
+ $ . equivalence_statement ,
572
+ $ . data_statement ,
573
+ $ . cray_pointer_declaration ,
574
+ ) ) ,
575
+
567
576
use_statement : $ => seq (
568
577
caseInsensitive ( 'use' ) ,
569
578
choice (
@@ -578,7 +587,8 @@ module.exports = grammar({
578
587
seq ( ',' , commaSep1 ( $ . use_alias ) ) ,
579
588
$ . included_items
580
589
)
581
- )
590
+ ) ,
591
+ $ . _end_of_statement ,
582
592
) ,
583
593
584
594
included_items : $ => seq (
@@ -619,7 +629,8 @@ module.exports = grammar({
619
629
')'
620
630
) )
621
631
)
622
- )
632
+ ) ,
633
+ $ . _end_of_statement
623
634
) ,
624
635
625
636
save_statement : $ => prec ( 1 , seq (
@@ -630,7 +641,8 @@ module.exports = grammar({
630
641
$ . identifier ,
631
642
seq ( '/' , $ . identifier , '/' ) ,
632
643
) ) ,
633
- ) )
644
+ ) ) ,
645
+ $ . _end_of_statement ,
634
646
) ) ,
635
647
636
648
private_statement : $ => prec . right ( 1 , seq (
@@ -653,15 +665,17 @@ module.exports = grammar({
653
665
654
666
namelist_statement : $ => seq (
655
667
caseInsensitive ( 'namelist' ) ,
656
- repeat1 ( $ . variable_group )
668
+ repeat1 ( $ . variable_group ) ,
669
+ $ . _end_of_statement
657
670
) ,
658
671
659
672
common_statement : $ => seq (
660
673
caseInsensitive ( 'common' ) ,
661
674
repeat1 ( choice (
662
675
$ . variable_group ,
663
676
commaSep1 ( $ . _variable_declarator )
664
- ) )
677
+ ) ) ,
678
+ $ . _end_of_statement
665
679
) ,
666
680
667
681
variable_group : $ => seq (
@@ -678,7 +692,8 @@ module.exports = grammar({
678
692
679
693
import_statement : $ => prec . left ( seq (
680
694
caseInsensitive ( 'import' ) ,
681
- optional ( $ . _import_names )
695
+ optional ( $ . _import_names ) ,
696
+ $ . _end_of_statement
682
697
) ) ,
683
698
_import_names : $ => choice (
684
699
seq ( optional ( '::' ) , commaSep1 ( $ . identifier ) ) ,
@@ -701,7 +716,7 @@ module.exports = grammar({
701
716
$ . _end_of_statement
702
717
) ,
703
718
$ . include_statement ,
704
- seq ( $ . variable_declaration , $ . _end_of_statement ) ,
719
+ $ . variable_declaration ,
705
720
$ . preproc_include ,
706
721
$ . preproc_def ,
707
722
$ . preproc_function_def ,
@@ -825,7 +840,8 @@ module.exports = grammar({
825
840
)
826
841
) ) ,
827
842
optional ( '::' ) ,
828
- $ . _declaration_targets
843
+ $ . _declaration_targets ,
844
+ $ . _end_of_statement
829
845
) ,
830
846
831
847
procedure_declaration : $ => seq (
@@ -844,6 +860,7 @@ module.exports = grammar({
844
860
) ) ,
845
861
optional ( '::' ) ,
846
862
commaSep1 ( field ( 'declarator' , $ . _variable_declarator ) ) ,
863
+ $ . _end_of_statement ,
847
864
) ,
848
865
849
866
variable_attributes : $ => seq (
@@ -1024,14 +1041,16 @@ module.exports = grammar({
1024
1041
caseInsensitive ( 'parameter' ) ,
1025
1042
'(' ,
1026
1043
commaSep1 ( $ . parameter_assignment ) ,
1027
- ')'
1044
+ ')' ,
1045
+ $ . _end_of_statement
1028
1046
) ) ,
1029
1047
1030
1048
parameter_assignment : $ => seq ( $ . identifier , '=' , $ . _expression ) ,
1031
1049
1032
1050
equivalence_statement : $ => seq (
1033
1051
caseInsensitive ( 'equivalence' ) ,
1034
- commaSep1 ( $ . equivalence_set )
1052
+ commaSep1 ( $ . equivalence_set ) ,
1053
+ $ . _end_of_statement ,
1035
1054
) ,
1036
1055
1037
1056
equivalence_set : $ => seq (
@@ -1189,7 +1208,8 @@ module.exports = grammar({
1189
1208
1190
1209
data_statement : $ => seq (
1191
1210
caseInsensitive ( 'data' ) ,
1192
- sep1 ( $ . data_set , optional ( ',' ) )
1211
+ sep1 ( $ . data_set , optional ( ',' ) ) ,
1212
+ $ . _end_of_statement ,
1193
1213
) ,
1194
1214
data_set : $ => prec ( 1 , seq (
1195
1215
commaSep1 (
0 commit comments