[libc] Update dependency for __support_fputil_nearest_integer in bazel overlay.
[llvm-project.git] / flang / docs / f2018-grammar.md
blob89d2184adde856f6d7146b9760bbb68225b5d32f
1 # Fortran 2018 Grammar
3 Grammar used by Flang to parse Fortran 2018.
5 ```
6 R0001 digit -> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
7 R0002 letter ->
8         A | B | C | D | E | F | G | H | I | J | K | L | M |
9         N | O | P | Q | R | S | T | U | V | W | X | Y | Z
10 R0003 rep-char
12 R401 xzy-list -> xzy [, xzy]...
13 R402 xzy-name -> name
14 R403 scalar-xyz -> xyz
16 R501 program -> program-unit [program-unit]...
17 R502 program-unit ->
18        main-program | external-subprogram | module | submodule | block-data
19 R503 external-subprogram -> function-subprogram | subroutine-subprogram
20 R504 specification-part ->
21        [use-stmt]... [import-stmt]... [implicit-part]
22        [declaration-construct]...
23 R505 implicit-part -> [implicit-part-stmt]... implicit-stmt
24 R506 implicit-part-stmt ->
25        implicit-stmt | parameter-stmt | format-stmt | entry-stmt
26 R507 declaration-construct ->
27        specification-construct | data-stmt | format-stmt | entry-stmt |
28        stmt-function-stmt
29 R508 specification-construct ->
30        derived-type-def | enum-def | generic-stmt | interface-block |
31        parameter-stmt | procedure-declaration-stmt |
32        other-specification-stmt | type-declaration-stmt
33 R509 execution-part -> executable-construct [execution-part-construct]...
34 R510 execution-part-construct ->
35        executable-construct | format-stmt | entry-stmt | data-stmt
36 R511 internal-subprogram-part -> contains-stmt [internal-subprogram]...
37 R512 internal-subprogram -> function-subprogram | subroutine-subprogram
38 R513 other-specification-stmt ->
39        access-stmt | allocatable-stmt | asynchronous-stmt | bind-stmt |
40        codimension-stmt | contiguous-stmt | dimension-stmt | external-stmt |
41        intent-stmt | intrinsic-stmt | namelist-stmt | optional-stmt |
42        pointer-stmt | protected-stmt | save-stmt | target-stmt |
43        volatile-stmt | value-stmt | common-stmt | equivalence-stmt
44 R514 executable-construct ->
45        action-stmt | associate-construct | block-construct | case-construct |
46        change-team-construct | critical-construct | do-construct |
47        if-construct | select-rank-construct | select-type-construct |
48        where-construct | forall-construct
49 R515 action-stmt ->
50        allocate-stmt | assignment-stmt | backspace-stmt | call-stmt |
51        close-stmt | continue-stmt | cycle-stmt | deallocate-stmt |
52        endfile-stmt | error-stop-stmt | event-post-stmt | event-wait-stmt |
53        exit-stmt | fail-image-stmt | flush-stmt | form-team-stmt |
54        goto-stmt | if-stmt | inquire-stmt | lock-stmt | nullify-stmt |
55        open-stmt | pointer-assignment-stmt | print-stmt | read-stmt |
56        return-stmt | rewind-stmt | stop-stmt | sync-all-stmt |
57        sync-images-stmt | sync-memory-stmt | sync-team-stmt | unlock-stmt |
58        wait-stmt | where-stmt | write-stmt | computed-goto-stmt | forall-stmt
59 R516 keyword -> name
61 R601 alphanumeric-character -> letter | digit | underscore  @ | $
62 R602 underscore -> _
63 R603 name -> letter [alphanumeric-character]...
64 R604 constant -> literal-constant | named-constant
65 R605 literal-constant ->
66        int-literal-constant | real-literal-constant |
67        complex-literal-constant | logical-literal-constant |
68        char-literal-constant | boz-literal-constant
69 R606 named-constant -> name
70 R607 int-constant -> constant
71 R608 intrinsic-operator ->
72        power-op | mult-op | add-op | concat-op | rel-op |
73        not-op | and-op | or-op | equiv-op
74 R609 defined-operator ->
75        defined-unary-op | defined-binary-op | extended-intrinsic-op
76 R610 extended-intrinsic-op -> intrinsic-operator
77 R611 label -> digit [digit]...
78 R620 delimiter -> ( | ) | / | [ | ] | (/ | /)
80 R701 type-param-value -> scalar-int-expr | * | :
81 R702 type-spec -> intrinsic-type-spec | derived-type-spec
82 R703 declaration-type-spec ->
83        intrinsic-type-spec | TYPE ( intrinsic-type-spec ) |
84        TYPE ( derived-type-spec ) | CLASS ( derived-type-spec ) |
85        CLASS ( * ) | TYPE ( * )
86 R704 intrinsic-type-spec ->
87        integer-type-spec | REAL [kind-selector] | DOUBLE PRECISION |
88        COMPLEX [kind-selector] | CHARACTER [char-selector] |
89        LOGICAL [kind-selector] @ DOUBLE COMPLEX
90 R705 integer-type-spec -> INTEGER [kind-selector]
91 R706 kind-selector ->
92        ( [KIND =] scalar-int-constant-expr )  @ * scalar-int-constant-expr
93 R707 signed-int-literal-constant -> [sign] int-literal-constant
94 R708 int-literal-constant -> digit-string [_ kind-param]
95 R709 kind-param -> digit-string | scalar-int-constant-name
96 R710 signed-digit-string -> [sign] digit-string
97 R711 digit-string -> digit [digit]...
98 R712 sign -> + | -
99 R713 signed-real-literal-constant -> [sign] real-literal-constant
100 R714 real-literal-constant ->
101        significand [exponent-letter exponent] [_ kind-param] |
102        digit-string exponent-letter exponent [_ kind-param]
103 R715 significand -> digit-string . [digit-string] | . digit-string
104 R716 exponent-letter -> E | D  @ | Q
105 R717 exponent -> signed-digit-string
106 R718 complex-literal-constant -> ( real-part , imag-part )
107 R719 real-part ->
108        signed-int-literal-constant | signed-real-literal-constant |
109        named-constant
110 R720 imag-part ->
111        signed-int-literal-constant | signed-real-literal-constant |
112        named-constant
113 R721 char-selector ->
114        length-selector |
115        ( LEN = type-param-value , KIND = scalar-int-constant-expr ) |
116        ( type-param-value , [KIND =] scalar-int-constant-expr ) |
117        ( KIND = scalar-int-constant-expr [, LEN = type-param-value] )
118 R722 length-selector -> ( [LEN =] type-param-value ) | * char-length [,]
119 R723 char-length -> ( type-param-value ) | digit-string
120 R724 char-literal-constant ->
121        [kind-param _] ' [rep-char]... ' | [kind-param _] " [rep-char]... "
122 R725 logical-literal-constant ->
123        .TRUE. [_ kind-param] | .FALSE. [_ kind-param] @ | .T. | .F.
124 R726 derived-type-def ->
125        derived-type-stmt [type-param-def-stmt]... [private-or-sequence]...
126        [component-part] [type-bound-procedure-part] end-type-stmt
127 R727 derived-type-stmt ->
128        TYPE [[, type-attr-spec-list] ::] type-name [( type-param-name-list )]
129 R728 type-attr-spec ->
130        ABSTRACT | access-spec | BIND(C) | EXTENDS ( parent-type-name )
131 R729 private-or-sequence -> private-components-stmt | sequence-stmt
132 R730 end-type-stmt -> END TYPE [type-name]
133 R731 sequence-stmt -> SEQUENCE
134 R732 type-param-def-stmt ->
135        integer-type-spec , type-param-attr-spec :: type-param-decl-list
136 R733 type-param-decl -> type-param-name [= scalar-int-constant-expr]
137 R734 type-param-attr-spec -> KIND | LEN
138 R735 component-part -> [component-def-stmt]...
139 R736 component-def-stmt -> data-component-def-stmt | proc-component-def-stmt
140 R737 data-component-def-stmt ->
141        declaration-type-spec [[, component-attr-spec-list] ::]
142        component-decl-list
143 R738 component-attr-spec ->
144        access-spec | ALLOCATABLE |
145        CODIMENSION lbracket coarray-spec rbracket | CONTIGUOUS |
146        DIMENSION ( component-array-spec ) | POINTER
147 R739 component-decl ->
148        component-name [( component-array-spec )]
149        [lbracket coarray-spec rbracket] [* char-length]
150        [component-initialization]
151 R740 component-array-spec ->
152        explicit-shape-spec-list | deferred-shape-spec-list
153 R741 proc-component-def-stmt ->
154        PROCEDURE ( [proc-interface] ) , proc-component-attr-spec-list ::
155         proc-decl-list
156 R742 proc-component-attr-spec ->
157        access-spec | NOPASS | PASS [(arg-name)] | POINTER
158 R743 component-initialization ->
159        = constant-expr | => null-init | => initial-data-target
160 R744 initial-data-target -> designator
161 R745 private-components-stmt -> PRIVATE
162 R746 type-bound-procedure-part ->
163        contains-stmt [binding-private-stmt] [type-bound-proc-binding]...
164 R747 binding-private-stmt -> PRIVATE
165 R748 type-bound-proc-binding ->
166        type-bound-procedure-stmt | type-bound-generic-stmt |
167        final-procedure-stmt
168 R749 type-bound-procedure-stmt ->
169        PROCEDURE [[, bind-attr-list] ::] type-bound-proc-decl-list |
170        PROCEDURE ( interface-name ) , bind-attr-list :: binding-name-list
171 R750 type-bound-proc-decl -> binding-name [=> procedure-name]
172 R751 type-bound-generic-stmt ->
173        GENERIC [, access-spec] :: generic-spec => binding-name-list
174 R752 bind-attr ->
175        access-spec | DEFERRED | NON_OVERRIDABLE | NOPASS | PASS [(arg-name)]
176 R753 final-procedure-stmt -> FINAL [::] final-subroutine-name-list
177 R754 derived-type-spec -> type-name [(type-param-spec-list)]
178 R755 type-param-spec -> [keyword =] type-param-value
179 R756 structure-constructor -> derived-type-spec ( [component-spec-list] )
180 R757 component-spec -> [keyword =] component-data-source
181 R758 component-data-source -> expr | data-target | proc-target
182 R759 enum-def ->
183        enum-def-stmt enumerator-def-stmt [enumerator-def-stmt]... end-enum-stmt
184 R760 enum-def-stmt -> ENUM, BIND(C)
185 R761 enumerator-def-stmt -> ENUMERATOR [::] enumerator-list
186 R762 enumerator -> named-constant [= scalar-int-constant-expr]
187 R763 end-enum-stmt -> END ENUM
188 R764 boz-literal-constant -> binary-constant | octal-constant | hex-constant
189 R765 binary-constant -> B ' digit [digit]... ' | B " digit [digit]... "
190 R766 octal-constant -> O ' digit [digit]... ' | O " digit [digit]... "
191 R767 hex-constant ->
192        Z ' hex-digit [hex-digit]... ' | Z " hex-digit [hex-digit]... "
193 R768 hex-digit -> digit | A | B | C | D | E | F
194 R769 array-constructor -> (/ ac-spec /) | lbracket ac-spec rbracket
195 R770 ac-spec -> type-spec :: | [type-spec ::] ac-value-list
196 R771 lbracket -> [
197 R772 rbracket -> ]
198 R773 ac-value -> expr | ac-implied-do
199 R774 ac-implied-do -> ( ac-value-list , ac-implied-do-control )
200 R775 ac-implied-do-control ->
201        [integer-type-spec ::] ac-do-variable = scalar-int-expr ,
202        scalar-int-expr [, scalar-int-expr]
203 R776 ac-do-variable -> do-variable
205 R801 type-declaration-stmt ->
206        declaration-type-spec [[, attr-spec]... ::] entity-decl-list
207 R802 attr-spec ->
208        access-spec | ALLOCATABLE | ASYNCHRONOUS |
209        CODIMENSION lbracket coarray-spec rbracket | CONTIGUOUS |
210        DIMENSION ( array-spec ) | EXTERNAL | INTENT ( intent-spec ) |
211        INTRINSIC | language-binding-spec | OPTIONAL | PARAMETER |
212        POINTER | PROTECTED | SAVE | TARGET | VALUE | VOLATILE
213 R803 entity-decl ->
214        object-name [( array-spec )] [lbracket coarray-spec rbracket]
215          [* char-length] [initialization] |
216        function-name [* char-length]
217 R804 object-name -> name
218 R805 initialization -> = constant-expr | => null-init | => initial-data-target
219 R806 null-init -> function-reference     {constrained to be NULL()}
220 R807 access-spec -> PUBLIC | PRIVATE
221 R808 language-binding-spec ->
222        BIND ( C [, NAME = scalar-default-char-constant-expr] )
223 R809 coarray-spec -> deferred-coshape-spec-list | explicit-coshape-spec
224 R810 deferred-coshape-spec -> :
225 R811 explicit-coshape-spec ->
226        [[lower-cobound :] upper-cobound ,]... [lower-cobound :] *
227 R812 lower-cobound -> specification-expr
228 R813 upper-cobound -> specification-expr
229 R814 dimension-spec -> DIMENSION ( array-spec )
230 R815 array-spec ->
231        explicit-shape-spec-list | assumed-shape-spec-list |
232        deferred-shape-spec-list | assumed-size-spec | implied-shape-spec |
233        implied-shape-or-assumed-size-spec | assumed-rank-spec
234 R816 explicit-shape-spec -> [lower-bound :] upper-bound
235 R817 lower-bound -> specification-expr
236 R818 upper-bound -> specification-expr
237 R819 assumed-shape-spec -> [lower-bound] :
238 R820 deferred-shape-spec -> :
239 R821 assumed-implied-spec -> [lower-bound :] *
240 R822 assumed-size-spec -> explicit-shape-spec-list , assumed-implied-spec
241 R823 implied-shape-or-assumed-size-spec -> assumed-implied-spec
242 R824 implied-shape-spec -> assumed-implied-spec , assumed-implied-spec-list
243 R825 assumed-rank-spec -> ..
244 R826 intent-spec -> IN | OUT | INOUT
245 R827 access-stmt -> access-spec [[::] access-id-list]
246 R828 access-id -> access-name | generic-spec
247 R829 allocatable-stmt -> ALLOCATABLE [::] allocatable-decl-list
248 R830 allocatable-decl ->
249        object-name [( array-spec )] [lbracket coarray-spec rbracket]
250 R831 asynchronous-stmt -> ASYNCHRONOUS [::] object-name-list
251 R832 bind-stmt -> language-binding-spec [::] bind-entity-list
252 R833 bind-entity -> entity-name | / common-block-name /
253 R834 codimension-stmt -> CODIMENSION [::] codimension-decl-list
254 R835 codimension-decl -> coarray-name lbracket coarray-spec rbracket
255 R836 contiguous-stmt -> CONTIGUOUS [::] object-name-list
256 R837 data-stmt -> DATA data-stmt-set [[,] data-stmt-set]...
257 R838 data-stmt-set -> data-stmt-object-list / data-stmt-value-list /
258 R839 data-stmt-object -> variable | data-implied-do
259 R840 data-implied-do ->
260        ( data-i-do-object-list , [integer-type-spec ::]
261        data-i-do-variable = scalar-int-constant-expr ,
262        scalar-int-constant-expr [, scalar-int-constant-expr] )
263 R841 data-i-do-object ->
264        array-element | scalar-structure-component | data-implied-do
265 R842 data-i-do-variable -> do-variable
266 R843 data-stmt-value -> [data-stmt-repeat *] data-stmt-constant
267 R844 data-stmt-repeat -> scalar-int-constant | scalar-int-constant-subobject
268 R845 data-stmt-constant ->
269        scalar-constant | scalar-constant-subobject |
270        signed-int-literal-constant | signed-real-literal-constant |
271        null-init | initial-data-target | structure-constructor
272 R846 int-constant-subobject -> constant-subobject
273 R847 constant-subobject -> designator
274 R848 dimension-stmt ->
275        DIMENSION [::] array-name ( array-spec )
276        [, array-name ( array-spec )]...
277 R849 intent-stmt -> INTENT ( intent-spec ) [::] dummy-arg-name-list
278 R850 optional-stmt -> OPTIONAL [::] dummy-arg-name-list
279 R851 parameter-stmt -> PARAMETER ( named-constant-def-list )
280 R852 named-constant-def -> named-constant = constant-expr
281 R853 pointer-stmt -> POINTER [::] pointer-decl-list
282 R854 pointer-decl ->
283        object-name [( deferred-shape-spec-list )] | proc-entity-name
284 R855 protected-stmt -> PROTECTED [::] entity-name-list
285 R856 save-stmt -> SAVE [[::] saved-entity-list]
286 R857 saved-entity -> object-name | proc-pointer-name | / common-block-name /
287 R858 proc-pointer-name -> name
288 R859 target-stmt -> TARGET [::] target-decl-list
289 R860 target-decl ->
290        object-name [( array-spec )] [lbracket coarray-spec rbracket]
291 R861 value-stmt -> VALUE [::] dummy-arg-name-list
292 R862 volatile-stmt -> VOLATILE [::] object-name-list
293 R863 implicit-stmt ->
294        IMPLICIT implicit-spec-list |
295        IMPLICIT NONE [( [implicit-name-spec-list] )]
296 R864 implicit-spec -> declaration-type-spec ( letter-spec-list )
297 R865 letter-spec -> letter [- letter]
298 R866 implicit-name-spec -> EXTERNAL | TYPE
299 R867 import-stmt ->
300        IMPORT [[::] import-name-list] | IMPORT , ONLY : import-name-list |
301        IMPORT , NONE | IMPORT , ALL
302 R868 namelist-stmt ->
303        NAMELIST / namelist-group-name / namelist-group-object-list
304        [[,] / namelist-group-name / namelist-group-object-list]...
305 R869 namelist-group-object -> variable-name
306 R870 equivalence-stmt -> EQUIVALENCE equivalence-set-list
307 R871 equivalence-set -> ( equivalence-object , equivalence-object-list )
308 R872 equivalence-object -> variable-name | array-element | substring
309 R873 common-stmt ->
310        COMMON [/ [common-block-name] /] common-block-object-list
311        [[,] / [common-block-name] / common-block-object-list]...
312 R874 common-block-object -> variable-name [( array-spec )]
314 R901 designator ->
315        object-name | array-element | array-section |
316        coindexed-named-object | complex-part-designator |
317        structure-component | substring
318 R902 variable -> designator | function-reference
319 R903 variable-name -> name
320 R904 logical-variable -> variable
321 R905 char-variable -> variable
322 R906 default-char-variable -> variable
323 R907 int-variable -> variable
324 R908 substring -> parent-string ( substring-range )
325 R909 parent-string ->
326        scalar-variable-name | array-element | coindexed-named-object |
327        scalar-structure-component | scalar-char-literal-constant |
328        scalar-named-constant
329 R910 substring-range -> [scalar-int-expr] : [scalar-int-expr]
330 R911 data-ref -> part-ref [% part-ref]...
331 R912 part-ref -> part-name [( section-subscript-list )] [image-selector]
332 R913 structure-component -> data-ref
333 R914 coindexed-named-object -> data-ref
334 R915 complex-part-designator -> designator % RE | designator % IM
335 R916 type-param-inquiry -> designator % type-param-name
336 R917 array-element -> data-ref
337 R918 array-section ->
338        data-ref [( substring-range )] | complex-part-designator
339 R919 subscript -> scalar-int-expr
340 R920 section-subscript -> subscript | subscript-triplet | vector-subscript
341 R921 subscript-triplet -> [subscript] : [subscript] [: stride]
342 R922 stride -> scalar-int-expr
343 R923 vector-subscript -> int-expr
344 R924 image-selector ->
345        lbracket cosubscript-list [, image-selector-spec-list] rbracket
346 R925 cosubscript -> scalar-int-expr
347 R926 image-selector-spec ->
348        STAT = stat-variable | TEAM = team-value |
349        TEAM_NUMBER = scalar-int-expr
350 R927 allocate-stmt ->
351        ALLOCATE ( [type-spec ::] allocation-list [, alloc-opt-list] )
352 R928 alloc-opt ->
353        ERRMSG = errmsg-variable | MOLD = source-expr |
354        SOURCE = source-expr | STAT = stat-variable
355 R929 stat-variable -> scalar-int-variable
356 R930 errmsg-variable -> scalar-default-char-variable
357 R931 source-expr -> expr
358 R932 allocation ->
359        allocate-object [( allocate-shape-spec-list )]
360        [lbracket allocate-coarray-spec rbracket]
361 R933 allocate-object -> variable-name | structure-component
362 R934 allocate-shape-spec -> [lower-bound-expr :] upper-bound-expr
363 R935 lower-bound-expr -> scalar-int-expr
364 R936 upper-bound-expr -> scalar-int-expr
365 R937 allocate-coarray-spec ->
366        [allocate-coshape-spec-list ,] [lower-bound-expr :] *
367 R938 allocate-coshape-spec -> [lower-bound-expr :] upper-bound-expr
368 R939 nullify-stmt -> NULLIFY ( pointer-object-list )
369 R940 pointer-object -> variable-name | structure-component | proc-pointer-name
370 R941 deallocate-stmt ->
371        DEALLOCATE ( allocate-object-list [, dealloc-opt-list] )
372 R942 dealloc-opt -> STAT = stat-variable | ERRMSG = errmsg-variable
374 R1001 primary ->
375         literal-constant | designator | array-constructor |
376         structure-constructor | function-reference | type-param-inquiry |
377         type-param-name | ( expr )
378 R1002 level-1-expr -> [defined-unary-op] primary
379 R1003 defined-unary-op -> . letter [letter]... .
380 R1004 mult-operand -> level-1-expr [power-op mult-operand]
381 R1005 add-operand -> [add-operand mult-op] mult-operand
382 R1006 level-2-expr -> [[level-2-expr] add-op] add-operand
383 R1007 power-op -> **
384 R1008 mult-op -> * | /
385 R1009 add-op -> + | -
386 R1010 level-3-expr -> [level-3-expr concat-op] level-2-expr
387 R1011 concat-op -> //
388 R1012 level-4-expr -> [level-3-expr rel-op] level-3-expr
389 R1013 rel-op ->
390         .EQ. | .NE. | .LT. | .LE. | .GT. | .GE. |
391         == | /= | < | <= | > | >=  @ | <>
392 R1014 and-operand -> [not-op] level-4-expr
393 R1015 or-operand -> [or-operand and-op] and-operand
394 R1016 equiv-operand -> [equiv-operand or-op] or-operand
395 R1017 level-5-expr -> [level-5-expr equiv-op] equiv-operand
396 R1018 not-op -> .NOT.
397 R1019 and-op -> .AND.
398 R1020 or-op -> .OR.
399 R1021 equiv-op -> .EQV. | .NEQV.
400 R1022 expr -> [expr defined-binary-op] level-5-expr
401 R1023 defined-binary-op -> . letter [letter]... .
402 R1024 logical-expr -> expr
403 R1025 default-char-expr -> expr
404 R1026 int-expr -> expr
405 R1027 numeric-expr -> expr
406 R1028 specification-expr -> scalar-int-expr
407 R1029 constant-expr -> expr
408 R1030 default-char-constant-expr -> default-char-expr
409 R1031 int-constant-expr -> int-expr
410 R1032 assignment-stmt -> variable = expr
411 R1033 pointer-assignment-stmt ->
412         data-pointer-object [( bounds-spec-list )] => data-target |
413         data-pointer-object ( bounds-remapping-list ) => data-target |
414         proc-pointer-object => proc-target
415 R1034 data-pointer-object ->
416         variable-name | scalar-variable % data-pointer-component-name
417 R1035 bounds-spec -> lower-bound-expr :
418 R1036 bounds-remapping -> lower-bound-expr : upper-bound-expr
419 R1037 data-target -> expr
420 R1038 proc-pointer-object -> proc-pointer-name | proc-component-ref
421 R1039 proc-component-ref -> scalar-variable % procedure-component-name
422 R1040 proc-target -> expr | procedure-name | proc-component-ref
423 R1041 where-stmt -> WHERE ( mask-expr ) where-assignment-stmt
424 R1042 where-construct ->
425         where-construct-stmt [where-body-construct]...
426         [masked-elsewhere-stmt [where-body-construct]...]...
427         [elsewhere-stmt [where-body-construct]...] end-where-stmt
428 R1043 where-construct-stmt -> [where-construct-name :] WHERE ( mask-expr )
429 R1044 where-body-construct ->
430         where-assignment-stmt | where-stmt | where-construct
431 R1045 where-assignment-stmt -> assignment-stmt
432 R1046 mask-expr -> logical-expr
433 R1047 masked-elsewhere-stmt -> ELSEWHERE ( mask-expr ) [where-construct-name]
434 R1048 elsewhere-stmt -> ELSEWHERE [where-construct-name]
435 R1049 end-where-stmt -> END WHERE [where-construct-name]
436 R1050 forall-construct ->
437         forall-construct-stmt [forall-body-construct]... end-forall-stmt
438 R1051 forall-construct-stmt ->
439         [forall-construct-name :] FORALL concurrent-header
440 R1052 forall-body-construct ->
441         forall-assignment-stmt | where-stmt | where-construct |
442         forall-construct | forall-stmt
443 R1053 forall-assignment-stmt -> assignment-stmt | pointer-assignment-stmt
444 R1054 end-forall-stmt -> END FORALL [forall-construct-name]
445 R1055 forall-stmt -> FORALL concurrent-header forall-assignment-stmt
447 R1101 block -> [execution-part-construct]...
448 R1102 associate-construct -> associate-stmt block end-associate-stmt
449 R1103 associate-stmt ->
450         [associate-construct-name :] ASSOCIATE ( association-list )
451 R1104 association -> associate-name => selector
452 R1105 selector -> expr | variable
453 R1106 end-associate-stmt -> END ASSOCIATE [associate-construct-name]
454 R1107 block-construct ->
455         block-stmt [block-specification-part] block end-block-stmt
456 R1108 block-stmt -> [block-construct-name :] BLOCK
457 R1109 block-specification-part ->
458         [use-stmt]... [import-stmt]...
459         [[declaration-construct]... specification-construct]
460 R1110 end-block-stmt -> END BLOCK [block-construct-name]
461 R1111 change-team-construct -> change-team-stmt block end-change-team-stmt
462 R1112 change-team-stmt ->
463         [team-construct-name :] CHANGE TEAM ( team-value
464         [, coarray-association-list] [, sync-stat-list] )
465 R1113 coarray-association -> codimension-decl => selector
466 R1114 end-change-team-stmt ->
467         END TEAM [( [sync-stat-list] )] [team-construct-name]
468 R1115 team-value -> scalar-expr
469 R1116 critical-construct -> critical-stmt block end-critical-stmt
470 R1117 critical-stmt ->
471         [critical-construct-name :] CRITICAL [( [sync-stat-list] )]
472 R1118 end-critical-stmt -> END CRITICAL [critical-construct-name]
473 R1119 do-construct -> do-stmt block end-do
474 R1120 do-stmt -> nonlabel-do-stmt | label-do-stmt
475 R1121 label-do-stmt -> [do-construct-name :] DO label [loop-control]
476 R1122 nonlabel-do-stmt -> [do-construct-name :] DO [loop-control]
477 R1123 loop-control ->
478         [,] do-variable = scalar-int-expr , scalar-int-expr
479           [, scalar-int-expr] |
480         [,] WHILE ( scalar-logical-expr ) |
481         [,] CONCURRENT concurrent-header concurrent-locality
482 R1124 do-variable -> scalar-int-variable-name
483 R1125 concurrent-header ->
484         ( [integer-type-spec ::] concurrent-control-list [, scalar-mask-expr] )
485 R1126 concurrent-control ->
486         index-name = concurrent-limit : concurrent-limit [: concurrent-step]
487 R1127 concurrent-limit -> scalar-int-expr
488 R1128 concurrent-step -> scalar-int-expr
489 R1129 concurrent-locality -> [locality-spec]...
490 R1130 locality-spec ->
491         LOCAL ( variable-name-list ) | LOCAL_INIT ( variable-name-list ) |
492         SHARED ( variable-name-list ) | DEFAULT ( NONE )
493 R1131 end-do -> end-do-stmt | continue-stmt
494 R1132 end-do-stmt -> END DO [do-construct-name]
495 R1133 cycle-stmt -> CYCLE [do-construct-name]
496 R1134 if-construct ->
497         if-then-stmt block [else-if-stmt block]... [else-stmt block]
498         end-if-stmt
499 R1135 if-then-stmt -> [if-construct-name :] IF ( scalar-logical-expr ) THEN
500 R1136 else-if-stmt -> ELSE IF ( scalar-logical-expr ) THEN [if-construct-name]
501 R1137 else-stmt -> ELSE [if-construct-name]
502 R1138 end-if-stmt -> END IF [if-construct-name]
503 R1139 if-stmt -> IF ( scalar-logical-expr ) action-stmt
504 R1140 case-construct -> select-case-stmt [case-stmt block]... end-select-stmt
505 R1141 select-case-stmt -> [case-construct-name :] SELECT CASE ( case-expr )
506 R1142 case-stmt -> CASE case-selector [case-construct-name]
507 R1143 end-select-stmt -> END SELECT [case-construct-name]
508 R1144 case-expr -> scalar-expr
509 R1145 case-selector -> ( case-value-range-list ) | DEFAULT
510 R1146 case-value-range ->
511         case-value | case-value : | : case-value | case-value : case-value
512 R1147 case-value -> scalar-constant-expr
513 R1148 select-rank-construct ->
514         select-rank-stmt [select-rank-case-stmt block]... end-select-rank-stmt
515 R1149 select-rank-stmt ->
516         [select-construct-name :] SELECT RANK ( [associate-name =>] selector )
517 R1150 select-rank-case-stmt ->
518         RANK ( scalar-int-constant-expr ) [select-construct-name] |
519         RANK ( * ) [select-construct-name] |
520         RANK DEFAULT [select-construct-name]
521 R1151 end-select-rank-stmt -> END SELECT [select-construct-name]
522 R1152 select-type-construct ->
523         select-type-stmt [type-guard-stmt block]... end-select-type-stmt
524 R1153 select-type-stmt ->
525         [select-construct-name :] SELECT TYPE ( [associate-name =>] selector )
526 R1154 type-guard-stmt ->
527         TYPE IS ( type-spec ) [select-construct-name] |
528         CLASS IS ( derived-type-spec ) [select-construct-name] |
529         CLASS DEFAULT [select-construct-name]
530 R1155 end-select-type-stmt -> END SELECT [select-construct-name]
531 R1156 exit-stmt -> EXIT [construct-name]
532 R1157 goto-stmt -> GO TO label
533 R1158 computed-goto-stmt -> GO TO ( label-list ) [,] scalar-int-expr
534 R1159 continue-stmt -> CONTINUE
535 R1160 stop-stmt -> STOP [stop-code] [, QUIET = scalar-logical-expr]
536 R1161 error-stop-stmt -> ERROR STOP [stop-code] [, QUIET = scalar-logical-expr]
537 R1162 stop-code -> scalar-default-char-expr | scalar-int-expr
538 R1163 fail-image-stmt -> FAIL IMAGE
539 R1164 sync-all-stmt -> SYNC ALL [( [sync-stat-list] )]
540 R1165 sync-stat -> STAT = stat-variable | ERRMSG = errmsg-variable
541 R1166 sync-images-stmt -> SYNC IMAGES ( image-set [, sync-stat-list] )
542 R1167 image-set -> int-expr | *
543 R1168 sync-memory-stmt -> SYNC MEMORY [( [sync-stat-list] )]
544 R1169 sync-team-stmt -> SYNC TEAM ( team-value [, sync-stat-list] )
545 R1170 event-post-stmt -> EVENT POST ( event-variable [, sync-stat-list] )
546 R1171 event-variable -> scalar-variable
547 R1172 event-wait-stmt -> EVENT WAIT ( event-variable [, event-wait-spec-list] )
548 R1173 event-wait-spec -> until-spec | sync-stat
549 R1174 until-spec -> UNTIL_COUNT = scalar-int-expr
550 R1175 form-team-stmt ->
551         FORM TEAM ( team-number , team-variable [, form-team-spec-list] )
552 R1176 team-number -> scalar-int-expr
553 R1177 team-variable -> scalar-variable
554 R1178 form-team-spec -> NEW_INDEX = scalar-int-expr | sync-stat
555 R1179 lock-stmt -> LOCK ( lock-variable [, lock-stat-list] )
556 R1180 lock-stat -> ACQUIRED_LOCK = scalar-logical-variable | sync-stat
557 R1181 unlock-stmt -> UNLOCK ( lock-variable [, sync-stat-list] )
558 R1182 lock-variable -> scalar-variable
560 R1201 io-unit -> file-unit-number | * | internal-file-variable
561 R1202 file-unit-number -> scalar-int-expr
562 R1203 internal-file-variable -> char-variable
563 R1204 open-stmt -> OPEN ( connect-spec-list )
564 R1205 connect-spec ->
565         [UNIT =] file-unit-number | ACCESS = scalar-default-char-expr |
566         ACTION = scalar-default-char-expr |
567         ASYNCHRONOUS = scalar-default-char-expr |
568         BLANK = scalar-default-char-expr |
569         DECIMAL = scalar-default-char-expr | DELIM = scalar-default-char-expr |
570         ENCODING = scalar-default-char-expr | ERR = label |
571         FILE = file-name-expr | FORM = scalar-default-char-expr |
572         IOMSG = iomsg-variable | IOSTAT = scalar-int-variable |
573         NEWUNIT = scalar-int-variable | PAD = scalar-default-char-expr |
574         POSITION = scalar-default-char-expr | RECL = scalar-int-expr |
575         ROUND = scalar-default-char-expr | SIGN = scalar-default-char-expr |
576         STATUS = scalar-default-char-expr
577         @ | CARRIAGECONTROL = scalar-default-char-expr
578           | CONVERT = scalar-default-char-expr
579           | DISPOSE = scalar-default-char-expr
580 R1206 file-name-expr -> scalar-default-char-expr
581 R1207 iomsg-variable -> scalar-default-char-variable
582 R1208 close-stmt -> CLOSE ( close-spec-list )
583 R1209 close-spec ->
584         [UNIT =] file-unit-number | IOSTAT = scalar-int-variable |
585         IOMSG = iomsg-variable | ERR = label |
586         STATUS = scalar-default-char-expr
587 R1210 read-stmt ->
588         READ ( io-control-spec-list ) [input-item-list] |
589         READ format [, input-item-list]
590 R1211 write-stmt -> WRITE ( io-control-spec-list ) [output-item-list]
591 R1212 print-stmt -> PRINT format [, output-item-list]
592 R1213 io-control-spec ->
593         [UNIT =] io-unit | [FMT =] format | [NML =] namelist-group-name |
594         ADVANCE = scalar-default-char-expr |
595         ASYNCHRONOUS = scalar-default-char-constant-expr |
596         BLANK = scalar-default-char-expr | DECIMAL = scalar-default-char-expr |
597         DELIM = scalar-default-char-expr | END = label | EOR = label |
598         ERR = label | ID = id-variable | IOMSG = iomsg-variable |
599         IOSTAT = scalar-int-variable | PAD = scalar-default-char-expr |
600         POS = scalar-int-expr | REC = scalar-int-expr |
601         ROUND = scalar-default-char-expr | SIGN = scalar-default-char-expr |
602         SIZE = scalar-int-variable
603 R1214 id-variable -> scalar-int-variable
604 R1215 format -> default-char-expr | label | *
605 R1216 input-item -> variable | io-implied-do
606 R1217 output-item -> expr | io-implied-do
607 R1218 io-implied-do -> ( io-implied-do-object-list , io-implied-do-control )
608 R1219 io-implied-do-object -> input-item | output-item
609 R1220 io-implied-do-control ->
610         do-variable = scalar-int-expr , scalar-int-expr [, scalar-int-expr]
611 R1221 dtv-type-spec -> TYPE ( derived-type-spec ) | CLASS ( derived-type-spec )
612 R1222 wait-stmt -> WAIT ( wait-spec-list )
613 R1223 wait-spec ->
614         [UNIT =] file-unit-number | END = label | EOR = label | ERR = label |
615         ID = scalar-int-expr | IOMSG = iomsg-variable |
616         IOSTAT = scalar-int-variable
617 R1224 backspace-stmt ->
618         BACKSPACE file-unit-number | BACKSPACE ( position-spec-list )
619 R1225 endfile-stmt -> ENDFILE file-unit-number | ENDFILE ( position-spec-list )
620 R1226 rewind-stmt -> REWIND file-unit-number | REWIND ( position-spec-list )
621 R1227 position-spec ->
622         [UNIT =] file-unit-number | IOMSG = iomsg-variable |
623         IOSTAT = scalar-int-variable | ERR = label
624 R1228 flush-stmt -> FLUSH file-unit-number | FLUSH ( flush-spec-list )
625 R1229 flush-spec ->
626         [UNIT =] file-unit-number | IOSTAT = scalar-int-variable |
627         IOMSG = iomsg-variable | ERR = label
628 R1230 inquire-stmt ->
629         INQUIRE ( inquire-spec-list ) |
630         INQUIRE ( IOLENGTH = scalar-int-variable ) output-item-list
631 R1231 inquire-spec ->
632         [UNIT =] file-unit-number | FILE = file-name-expr |
633         ACCESS = scalar-default-char-variable |
634         ACTION = scalar-default-char-variable |
635         ASYNCHRONOUS = scalar-default-char-variable |
636         BLANK = scalar-default-char-variable |
637         DECIMAL = scalar-default-char-variable |
638         DELIM = scalar-default-char-variable |
639         ENCODING = scalar-default-char-variable |
640         ERR = label | EXIST = scalar-logical-variable |
641         FORM = scalar-default-char-variable |
642         FORMATTED = scalar-default-char-variable | ID = scalar-int-expr |
643         IOMSG = iomsg-variable | IOSTAT = scalar-int-variable |
644         NAME = scalar-default-char-variable |
645         NAMED = scalar-logical-variable | NEXTREC = scalar-int-variable |
646         NUMBER = scalar-int-variable | OPENED = scalar-logical-variable |
647         PAD = scalar-default-char-variable |
648         PENDING = scalar-logical-variable | POS = scalar-int-variable |
649         POSITION = scalar-default-char-variable |
650         READ = scalar-default-char-variable |
651         READWRITE = scalar-default-char-variable |
652         RECL = scalar-int-variable | ROUND = scalar-default-char-variable |
653         SEQUENTIAL = scalar-default-char-variable |
654         SIGN = scalar-default-char-variable | SIZE = scalar-int-variable |
655         STREAM = scalar-default-char-variable |
656         STATUS = scalar-default-char-variable |
657         WRITE = scalar-default-char-variable
658         @ | CARRIAGECONTROL = scalar-default-char-expr
659           | CONVERT = scalar-default-char-expr
660           | DISPOSE = scalar-default-char-expr
662 R1301 format-stmt -> FORMAT format-specification
663 R1302 format-specification ->
664         ( [format-items] ) | ( [format-items ,] unlimited-format-item )
665 R1303 format-items -> format-item [[,] format-item]...
666 R1304 format-item ->
667         [r] data-edit-desc | control-edit-desc | char-string-edit-desc | [r] ( format-items )
668 R1305 unlimited-format-item -> * ( format-items )
669 R1306 r -> digit-string
670 R1307 data-edit-desc ->
671         I w [. m] | B w [. m] | O w [. m] | Z w [. m] | F w . d |
672         E w . d [E e] | EN w . d [E e] | ES w . d [E e] | EX w . d [E e] |
673         G w [. d [E e]] | L w | A [w] | D w . d |
674         DT [char-literal-constant] [( v-list )]
675 R1308 w -> digit-string
676 R1309 m -> digit-string
677 R1310 d -> digit-string
678 R1311 e -> digit-string
679 R1312 v -> [sign] digit-string
680 R1313 control-edit-desc ->
681         position-edit-desc | [r] / | : | sign-edit-desc | k P |
682         blank-interp-edit-desc | round-edit-desc | decimal-edit-desc |
683         @ $ | \
684 R1314 k -> [sign] digit-string
685 R1315 position-edit-desc -> T n | TL n | TR n | n X
686 R1316 n -> digit-string
687 R1317 sign-edit-desc -> SS | SP | S
688 R1318 blank-interp-edit-desc -> BN | BZ
689 R1319 round-edit-desc -> RU | RD | RZ | RN | RC | RP
690 R1320 decimal-edit-desc -> DC | DP
691 R1321 char-string-edit-desc -> char-literal-constant
693 R1401 main-program ->
694         [program-stmt] [specification-part] [execution-part]
695         [internal-subprogram-part] end-program-stmt
696 R1402 program-stmt -> PROGRAM program-name
697 R1403 end-program-stmt -> END [PROGRAM [program-name]]
698 R1404 module ->
699         module-stmt [specification-part] [module-subprogram-part]
700         end-module-stmt
701 R1405 module-stmt -> MODULE module-name
702 R1406 end-module-stmt -> END [MODULE [module-name]]
703 R1407 module-subprogram-part -> contains-stmt [module-subprogram]...
704 R1408 module-subprogram ->
705         function-subprogram | subroutine-subprogram |
706         separate-module-subprogram
707 R1409 use-stmt ->
708         USE [[, module-nature] ::] module-name [, rename-list] |
709         USE [[, module-nature] ::] module-name , ONLY : [only-list]
710 R1410 module-nature -> INTRINSIC | NON_INTRINSIC
711 R1411 rename ->
712         local-name => use-name |
713         OPERATOR ( local-defined-operator ) =>
714           OPERATOR ( use-defined-operator )
715 R1412 only -> generic-spec | only-use-name | rename
716 R1413 only-use-name -> use-name
717 R1414 local-defined-operator -> defined-unary-op | defined-binary-op
718 R1415 use-defined-operator -> defined-unary-op | defined-binary-op
719 R1416 submodule ->
720         submodule-stmt [specification-part] [module-subprogram-part]
721         end-submodule-stmt
722 R1417 submodule-stmt -> SUBMODULE ( parent-identifier ) submodule-name
723 R1418 parent-identifier -> ancestor-module-name [: parent-submodule-name]
724 R1419 end-submodule-stmt -> END [SUBMODULE [submodule-name]]
725 R1420 block-data -> block-data-stmt [specification-part] end-block-data-stmt
726 R1421 block-data-stmt -> BLOCK DATA [block-data-name]
727 R1422 end-block-data-stmt -> END [BLOCK DATA [block-data-name]]
729 R1501 interface-block ->
730         interface-stmt [interface-specification]... end-interface-stmt
731 R1502 interface-specification -> interface-body | procedure-stmt
732 R1503 interface-stmt -> INTERFACE [generic-spec] | ABSTRACT INTERFACE
733 R1504 end-interface-stmt -> END INTERFACE [generic-spec]
734 R1505 interface-body ->
735         function-stmt [specification-part] end-function-stmt |
736         subroutine-stmt [specification-part] end-subroutine-stmt
737 R1506 procedure-stmt -> [MODULE] PROCEDURE [::] specific-procedure-list
738 R1507 specific-procedure -> procedure-name
739 R1508 generic-spec ->
740         generic-name | OPERATOR ( defined-operator ) |
741         ASSIGNMENT ( = ) | defined-io-generic-spec
742 R1509 defined-io-generic-spec ->
743         READ ( FORMATTED ) | READ ( UNFORMATTED ) |
744         WRITE ( FORMATTED ) | WRITE ( UNFORMATTED )
745 R1510 generic-stmt ->
746         GENERIC [, access-spec] :: generic-spec => specific-procedure-list
747 R1511 external-stmt -> EXTERNAL [::] external-name-list
748 R1512 procedure-declaration-stmt ->
749         PROCEDURE ( [proc-interface] ) [[, proc-attr-spec]... ::]
750         proc-decl-list
751 R1513 proc-interface -> interface-name | declaration-type-spec
752 R1514 proc-attr-spec ->
753         access-spec | proc-language-binding-spec | INTENT ( intent-spec ) |
754         OPTIONAL | POINTER | PROTECTED | SAVE
755 R1515 proc-decl -> procedure-entity-name [=> proc-pointer-init]
756 R1516 interface-name -> name
757 R1517 proc-pointer-init -> null-init | initial-proc-target
758 R1518 initial-proc-target -> procedure-name
759 R1519 intrinsic-stmt -> INTRINSIC [::] intrinsic-procedure-name-list
760 R1520 function-reference -> procedure-designator ( [actual-arg-spec-list] )
761 R1521 call-stmt -> CALL procedure-designator [( [actual-arg-spec-list] )]
762 R1522 procedure-designator ->
763         procedure-name | proc-component-ref | data-ref % binding-name
764 R1523 actual-arg-spec -> [keyword =] actual-arg
765 R1524 actual-arg ->
766         expr | variable | procedure-name | proc-component-ref | alt-return-spec
767 R1525 alt-return-spec -> * label
768 R1526 prefix -> prefix-spec [prefix-spec]...
769 R1527 prefix-spec ->
770         declaration-type-spec | ELEMENTAL | IMPURE | MODULE | NON_RECURSIVE |
771         PURE | RECURSIVE
772 R1528 proc-language-binding-spec -> language-binding-spec
773 R1529 function-subprogram ->
774         function-stmt [specification-part] [execution-part]
775         [internal-subprogram-part] end-function-stmt
776 R1530 function-stmt ->
777         [prefix] FUNCTION function-name ( [dummy-arg-name-list] ) [suffix]
778 R1531 dummy-arg-name -> name
779 R1532 suffix ->
780         proc-language-binding-spec [RESULT ( result-name )] |
781         RESULT ( result-name ) [proc-language-binding-spec]
782 R1533 end-function-stmt -> END [FUNCTION [function-name]]
783 R1534 subroutine-subprogram ->
784         subroutine-stmt [specification-part] [execution-part]
785         [internal-subprogram-part] end-subroutine-stmt
786 R1535 subroutine-stmt ->
787         [prefix] SUBROUTINE subroutine-name
788         [( [dummy-arg-list] ) [proc-language-binding-spec]]
789 R1536 dummy-arg -> dummy-arg-name | *
790 R1537 end-subroutine-stmt -> END [SUBROUTINE [subroutine-name]]
791 R1538 separate-module-subprogram ->
792         mp-subprogram-stmt [specification-part] [execution-part]
793         [internal-subprogram-part] end-mp-subprogram-stmt
794 R1539 mp-subprogram-stmt -> MODULE PROCEDURE procedure-name
795 R1540 end-mp-subprogram-stmt -> END [PROCEDURE [procedure-name]]
796 R1541 entry-stmt -> ENTRY entry-name [( [dummy-arg-list] ) [suffix]]
797 R1542 return-stmt -> RETURN [scalar-int-expr]
798 R1543 contains-stmt -> CONTAINS
799 R1544 stmt-function-stmt ->
800         function-name ( [dummy-arg-name-list] ) = scalar-expr
801 ```