@@ -101,6 +101,7 @@ module.exports = grammar({
101
101
[ $ . _inline_if_statement , $ . arithmetic_if_statement , $ . _block_if_statement , $ . identifier ] ,
102
102
[ $ . file_position_statement , $ . identifier ] ,
103
103
[ $ . cray_pointer_declaration , $ . identifier ] ,
104
+ [ $ . unit_identifier , $ . identifier ] ,
104
105
] ,
105
106
106
107
supertypes : $ => [
@@ -561,6 +562,7 @@ module.exports = grammar({
561
562
$ . import_statement ,
562
563
$ . public_statement ,
563
564
$ . private_statement ,
565
+ $ . bind_statement ,
564
566
$ . enum ,
565
567
$ . enumeration_type ,
566
568
$ . namelist_statement ,
@@ -573,6 +575,8 @@ module.exports = grammar({
573
575
$ . cray_pointer_declaration ,
574
576
// This catches statement functions, which are completely ambiguous
575
577
$ . assignment_statement ,
578
+ // This can appear immediately after procedure statement, or after `return`
579
+ $ . entry_statement ,
576
580
) ) ,
577
581
578
582
use_statement : $ => seq (
@@ -614,7 +618,10 @@ module.exports = grammar({
614
618
caseInsensitive ( 'implicit' ) ,
615
619
choice (
616
620
commaSep1 ( seq (
617
- $ . intrinsic_type ,
621
+ choice (
622
+ $ . intrinsic_type ,
623
+ $ . derived_type
624
+ ) ,
618
625
'(' ,
619
626
commaSep1 ( $ . implicit_range ) ,
620
627
')'
@@ -635,15 +642,22 @@ module.exports = grammar({
635
642
636
643
save_statement : $ => prec ( 1 , seq (
637
644
caseInsensitive ( 'save' ) ,
638
- optional ( seq (
639
- optional ( '::' ) ,
640
- commaSep1 ( choice (
641
- $ . identifier ,
642
- seq ( '/' , $ . identifier , '/' ) ,
643
- ) ) ,
644
- ) ) ,
645
+ optional ( $ . _identifier_or_common_block ) ,
645
646
) ) ,
646
647
648
+ bind_statement : $ => seq (
649
+ $ . language_binding ,
650
+ $ . _identifier_or_common_block ,
651
+ ) ,
652
+
653
+ _identifier_or_common_block : $ => seq (
654
+ optional ( '::' ) ,
655
+ commaSep1 ( choice (
656
+ $ . identifier ,
657
+ seq ( '/' , alias ( $ . identifier , $ . common_block ) , '/' ) ,
658
+ ) ) ,
659
+ ) ,
660
+
647
661
private_statement : $ => prec . right ( 1 , seq (
648
662
caseInsensitive ( 'private' ) ,
649
663
optional ( seq (
@@ -712,7 +726,7 @@ module.exports = grammar({
712
726
) ,
713
727
$ . _end_of_statement
714
728
) ,
715
- $ . variable_declaration ,
729
+ seq ( $ . variable_declaration , $ . _end_of_statement ) ,
716
730
$ . preproc_include ,
717
731
$ . preproc_def ,
718
732
$ . preproc_function_def ,
@@ -753,6 +767,7 @@ module.exports = grammar({
753
767
seq ( ',' , commaSep1 ( $ . _derived_type_qualifier ) , '::' , $ . _type_name )
754
768
) ,
755
769
optional ( alias ( $ . argument_list , $ . derived_type_parameter_list ) ) ,
770
+ $ . _end_of_statement ,
756
771
) ,
757
772
758
773
end_type_statement : $ => blockStructureEnding ( $ , 'type' ) ,
@@ -840,7 +855,15 @@ module.exports = grammar({
840
855
procedure_declaration : $ => seq (
841
856
caseInsensitive ( 'procedure' ) ,
842
857
optional ( seq (
843
- '(' , optional ( alias ( $ . identifier , $ . procedure_interface ) ) , ')'
858
+ '(' ,
859
+ optional (
860
+ choice (
861
+ alias ( $ . identifier , $ . procedure_interface ) ,
862
+ $ . intrinsic_type ,
863
+ $ . derived_type ,
864
+ )
865
+ ) ,
866
+ ')'
844
867
) ) ,
845
868
optional ( seq ( ',' , commaSep1 ( $ . procedure_attribute ) ) ) ,
846
869
) ,
@@ -849,7 +872,6 @@ module.exports = grammar({
849
872
repeat1 ( choice (
850
873
alias ( $ . _standalone_type_qualifier , $ . type_qualifier ) ,
851
874
$ . variable_attributes ,
852
- $ . language_binding ,
853
875
) ) ,
854
876
optional ( '::' ) ,
855
877
commaSep1 ( field ( 'declarator' , $ . _variable_declarator ) ) ,
@@ -895,11 +917,16 @@ module.exports = grammar({
895
917
'=>' ,
896
918
field ( 'right' , $ . _expression )
897
919
) ,
920
+ data_declarator : $ => seq (
921
+ field ( 'left' , $ . _variable_declarator ) ,
922
+ field ( 'right' , $ . data_value ) ,
923
+ ) ,
898
924
899
925
_declaration_targets : $ => commaSep1 ( field ( 'declarator' , choice (
900
926
$ . _variable_declarator ,
901
927
alias ( $ . _declaration_assignment , $ . init_declarator ) ,
902
928
alias ( $ . _declaration_pointer_association , $ . pointer_init_declarator ) ,
929
+ $ . data_declarator ,
903
930
) ) ) ,
904
931
905
932
_intrinsic_type : $ => choice (
@@ -964,6 +991,7 @@ module.exports = grammar({
964
991
_standalone_type_qualifier : $ => choice (
965
992
caseInsensitive ( 'abstract' ) ,
966
993
caseInsensitive ( 'allocatable' ) ,
994
+ caseInsensitive ( 'asynchronous' ) ,
967
995
caseInsensitive ( 'automatic' ) ,
968
996
prec . right ( seq (
969
997
caseInsensitive ( 'codimension' ) ,
@@ -1457,7 +1485,7 @@ module.exports = grammar({
1457
1485
whiteSpacedKeyword ( 'select' , 'case' ) ,
1458
1486
$ . selector ,
1459
1487
$ . _end_of_statement ,
1460
- repeat1 ( choice (
1488
+ repeat ( choice (
1461
1489
$ . case_statement ,
1462
1490
$ . preproc_include ,
1463
1491
$ . preproc_def ,
@@ -1475,7 +1503,7 @@ module.exports = grammar({
1475
1503
whiteSpacedKeyword ( 'select' , 'type' ) ,
1476
1504
$ . selector ,
1477
1505
$ . _end_of_statement ,
1478
- repeat1 ( choice (
1506
+ repeat ( choice (
1479
1507
$ . type_statement ,
1480
1508
$ . preproc_include ,
1481
1509
$ . preproc_def ,
@@ -1493,7 +1521,7 @@ module.exports = grammar({
1493
1521
whiteSpacedKeyword ( 'select' , 'rank' ) ,
1494
1522
$ . selector ,
1495
1523
$ . _end_of_statement ,
1496
- repeat1 ( choice (
1524
+ repeat ( choice (
1497
1525
$ . rank_statement ,
1498
1526
$ . preproc_include ,
1499
1527
$ . preproc_def ,
@@ -1732,14 +1760,20 @@ module.exports = grammar({
1732
1760
) ,
1733
1761
1734
1762
// precedence is used to override a conflict with the complex literal
1735
- unit_identifier : $ => prec ( 1 , choice (
1736
- $ . number_literal ,
1737
- $ . _io_expressions
1738
- ) ) ,
1763
+ unit_identifier : $ => seq (
1764
+ optional ( seq ( caseInsensitive ( 'unit' ) , '=' ) ) ,
1765
+ prec ( 1 , choice (
1766
+ $ . number_literal ,
1767
+ $ . _io_expressions
1768
+ ) )
1769
+ ) ,
1739
1770
1740
- format_identifier : $ => choice (
1741
- $ . statement_label_reference ,
1742
- $ . _io_expressions
1771
+ format_identifier : $ => seq (
1772
+ optional ( seq ( caseInsensitive ( 'fmt' ) , '=' ) ) ,
1773
+ choice (
1774
+ $ . statement_label_reference ,
1775
+ $ . _io_expressions
1776
+ )
1743
1777
) ,
1744
1778
1745
1779
_file_position_spec : $ => choice (
@@ -1983,6 +2017,10 @@ module.exports = grammar({
1983
2017
'(' ,
1984
2018
commaSep1 ( $ . _expression ) ,
1985
2019
',' ,
2020
+ // This should really be _inside_ loop_control_expression, but
2021
+ // type-spec only valid here, and not other places that use
2022
+ // loop_control_expression
2023
+ optional ( seq ( field ( 'type' , $ . intrinsic_type ) , '::' ) ) ,
1986
2024
$ . loop_control_expression ,
1987
2025
')'
1988
2026
) ,
@@ -2094,15 +2132,24 @@ module.exports = grammar({
2094
2132
) ,
2095
2133
2096
2134
null_literal : $ => prec ( 1 , seq (
2097
- caseInsensitive ( 'null' ) , '(' , ')'
2135
+ caseInsensitive ( 'null' ) ,
2136
+ '(' ,
2137
+ optional ( field ( 'mold' , choice (
2138
+ $ . identifier ,
2139
+ $ . derived_type_member_expression ,
2140
+ ) ) ) ,
2141
+ ')' ,
2098
2142
) ) ,
2099
2143
2100
2144
string_literal : $ => seq (
2101
2145
// Having a kind _prefix_, with an underscore and no whitespace,
2102
2146
// is _really_ hard to parse without breaking other things, so
2103
2147
// we have to rely on an external scanner
2104
2148
optional ( seq (
2105
- field ( 'kind' , alias ( $ . _string_literal_kind , $ . identifier ) ) ,
2149
+ field ( 'kind' , choice (
2150
+ alias ( $ . _string_literal_kind , $ . identifier ) ,
2151
+ alias ( $ . _integer_literal , $ . number_literal )
2152
+ ) ) ,
2106
2153
// Although external scanner enforces trailing underscore, we
2107
2154
// also need to *capture* it here
2108
2155
token . immediate ( '_' ) ,
@@ -2230,6 +2277,7 @@ module.exports = grammar({
2230
2277
identifier : $ => choice (
2231
2278
/ [ a - z A - Z _ $ ] [ \w $ ] * / ,
2232
2279
caseInsensitive ( 'allocatable' ) ,
2280
+ caseInsensitive ( 'asynchronous' ) ,
2233
2281
caseInsensitive ( 'automatic' ) ,
2234
2282
caseInsensitive ( 'block' ) ,
2235
2283
caseInsensitive ( 'byte' ) ,
@@ -2285,6 +2333,7 @@ module.exports = grammar({
2285
2333
caseInsensitive ( 'target' ) ,
2286
2334
caseInsensitive ( 'texture' ) ,
2287
2335
prec ( - 1 , caseInsensitive ( 'type' ) ) ,
2336
+ caseInsensitive ( 'unit' ) ,
2288
2337
caseInsensitive ( 'unlock' ) ,
2289
2338
caseInsensitive ( 'value' ) ,
2290
2339
caseInsensitive ( 'wait' ) ,
0 commit comments