@@ -101,6 +101,7 @@ module.exports = grammar({
101101 [ $ . _inline_if_statement , $ . arithmetic_if_statement , $ . _block_if_statement , $ . identifier ] ,
102102 [ $ . file_position_statement , $ . identifier ] ,
103103 [ $ . cray_pointer_declaration , $ . identifier ] ,
104+ [ $ . unit_identifier , $ . identifier ] ,
104105 ] ,
105106
106107 supertypes : $ => [
@@ -561,6 +562,7 @@ module.exports = grammar({
561562 $ . import_statement ,
562563 $ . public_statement ,
563564 $ . private_statement ,
565+ $ . bind_statement ,
564566 $ . enum ,
565567 $ . enumeration_type ,
566568 $ . namelist_statement ,
@@ -573,6 +575,8 @@ module.exports = grammar({
573575 $ . cray_pointer_declaration ,
574576 // This catches statement functions, which are completely ambiguous
575577 $ . assignment_statement ,
578+ // This can appear immediately after procedure statement, or after `return`
579+ $ . entry_statement ,
576580 ) ) ,
577581
578582 use_statement : $ => seq (
@@ -614,7 +618,10 @@ module.exports = grammar({
614618 caseInsensitive ( 'implicit' ) ,
615619 choice (
616620 commaSep1 ( seq (
617- $ . intrinsic_type ,
621+ choice (
622+ $ . intrinsic_type ,
623+ $ . derived_type
624+ ) ,
618625 '(' ,
619626 commaSep1 ( $ . implicit_range ) ,
620627 ')'
@@ -635,15 +642,22 @@ module.exports = grammar({
635642
636643 save_statement : $ => prec ( 1 , seq (
637644 caseInsensitive ( 'save' ) ,
638- optional ( seq (
639- optional ( '::' ) ,
640- commaSep1 ( choice (
641- $ . identifier ,
642- seq ( '/' , $ . identifier , '/' ) ,
643- ) ) ,
644- ) ) ,
645+ optional ( $ . _identifier_or_common_block ) ,
645646 ) ) ,
646647
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+
647661 private_statement : $ => prec . right ( 1 , seq (
648662 caseInsensitive ( 'private' ) ,
649663 optional ( seq (
@@ -712,7 +726,7 @@ module.exports = grammar({
712726 ) ,
713727 $ . _end_of_statement
714728 ) ,
715- $ . variable_declaration ,
729+ seq ( $ . variable_declaration , $ . _end_of_statement ) ,
716730 $ . preproc_include ,
717731 $ . preproc_def ,
718732 $ . preproc_function_def ,
@@ -753,6 +767,7 @@ module.exports = grammar({
753767 seq ( ',' , commaSep1 ( $ . _derived_type_qualifier ) , '::' , $ . _type_name )
754768 ) ,
755769 optional ( alias ( $ . argument_list , $ . derived_type_parameter_list ) ) ,
770+ $ . _end_of_statement ,
756771 ) ,
757772
758773 end_type_statement : $ => blockStructureEnding ( $ , 'type' ) ,
@@ -840,7 +855,15 @@ module.exports = grammar({
840855 procedure_declaration : $ => seq (
841856 caseInsensitive ( 'procedure' ) ,
842857 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+ ')'
844867 ) ) ,
845868 optional ( seq ( ',' , commaSep1 ( $ . procedure_attribute ) ) ) ,
846869 ) ,
@@ -849,7 +872,6 @@ module.exports = grammar({
849872 repeat1 ( choice (
850873 alias ( $ . _standalone_type_qualifier , $ . type_qualifier ) ,
851874 $ . variable_attributes ,
852- $ . language_binding ,
853875 ) ) ,
854876 optional ( '::' ) ,
855877 commaSep1 ( field ( 'declarator' , $ . _variable_declarator ) ) ,
@@ -895,11 +917,16 @@ module.exports = grammar({
895917 '=>' ,
896918 field ( 'right' , $ . _expression )
897919 ) ,
920+ data_declarator : $ => seq (
921+ field ( 'left' , $ . _variable_declarator ) ,
922+ field ( 'right' , $ . data_value ) ,
923+ ) ,
898924
899925 _declaration_targets : $ => commaSep1 ( field ( 'declarator' , choice (
900926 $ . _variable_declarator ,
901927 alias ( $ . _declaration_assignment , $ . init_declarator ) ,
902928 alias ( $ . _declaration_pointer_association , $ . pointer_init_declarator ) ,
929+ $ . data_declarator ,
903930 ) ) ) ,
904931
905932 _intrinsic_type : $ => choice (
@@ -964,6 +991,7 @@ module.exports = grammar({
964991 _standalone_type_qualifier : $ => choice (
965992 caseInsensitive ( 'abstract' ) ,
966993 caseInsensitive ( 'allocatable' ) ,
994+ caseInsensitive ( 'asynchronous' ) ,
967995 caseInsensitive ( 'automatic' ) ,
968996 prec . right ( seq (
969997 caseInsensitive ( 'codimension' ) ,
@@ -1457,7 +1485,7 @@ module.exports = grammar({
14571485 whiteSpacedKeyword ( 'select' , 'case' ) ,
14581486 $ . selector ,
14591487 $ . _end_of_statement ,
1460- repeat1 ( choice (
1488+ repeat ( choice (
14611489 $ . case_statement ,
14621490 $ . preproc_include ,
14631491 $ . preproc_def ,
@@ -1475,7 +1503,7 @@ module.exports = grammar({
14751503 whiteSpacedKeyword ( 'select' , 'type' ) ,
14761504 $ . selector ,
14771505 $ . _end_of_statement ,
1478- repeat1 ( choice (
1506+ repeat ( choice (
14791507 $ . type_statement ,
14801508 $ . preproc_include ,
14811509 $ . preproc_def ,
@@ -1493,7 +1521,7 @@ module.exports = grammar({
14931521 whiteSpacedKeyword ( 'select' , 'rank' ) ,
14941522 $ . selector ,
14951523 $ . _end_of_statement ,
1496- repeat1 ( choice (
1524+ repeat ( choice (
14971525 $ . rank_statement ,
14981526 $ . preproc_include ,
14991527 $ . preproc_def ,
@@ -1732,14 +1760,20 @@ module.exports = grammar({
17321760 ) ,
17331761
17341762 // 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+ ) ,
17391770
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+ )
17431777 ) ,
17441778
17451779 _file_position_spec : $ => choice (
@@ -1983,6 +2017,10 @@ module.exports = grammar({
19832017 '(' ,
19842018 commaSep1 ( $ . _expression ) ,
19852019 ',' ,
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 ) , '::' ) ) ,
19862024 $ . loop_control_expression ,
19872025 ')'
19882026 ) ,
@@ -2094,15 +2132,24 @@ module.exports = grammar({
20942132 ) ,
20952133
20962134 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+ ')' ,
20982142 ) ) ,
20992143
21002144 string_literal : $ => seq (
21012145 // Having a kind _prefix_, with an underscore and no whitespace,
21022146 // is _really_ hard to parse without breaking other things, so
21032147 // we have to rely on an external scanner
21042148 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+ ) ) ,
21062153 // Although external scanner enforces trailing underscore, we
21072154 // also need to *capture* it here
21082155 token . immediate ( '_' ) ,
@@ -2230,6 +2277,7 @@ module.exports = grammar({
22302277 identifier : $ => choice (
22312278 / [ a - z A - Z _ $ ] [ \w $ ] * / ,
22322279 caseInsensitive ( 'allocatable' ) ,
2280+ caseInsensitive ( 'asynchronous' ) ,
22332281 caseInsensitive ( 'automatic' ) ,
22342282 caseInsensitive ( 'block' ) ,
22352283 caseInsensitive ( 'byte' ) ,
@@ -2285,6 +2333,7 @@ module.exports = grammar({
22852333 caseInsensitive ( 'target' ) ,
22862334 caseInsensitive ( 'texture' ) ,
22872335 prec ( - 1 , caseInsensitive ( 'type' ) ) ,
2336+ caseInsensitive ( 'unit' ) ,
22882337 caseInsensitive ( 'unlock' ) ,
22892338 caseInsensitive ( 'value' ) ,
22902339 caseInsensitive ( 'wait' ) ,
0 commit comments