Classifies statements by their role in the block structure: opening a construct or program
unit, continuing one (else, case, contains, ...), or closing one.
Classification looks only at a statement's code tokens. Keywords are not reserved in Fortran,
so a keyword followed by =, => or % is treated as a variable (end = 1).
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public, | parameter | :: | C_ANY | = | 1 |
a bare |
| integer, | public, | parameter | :: | C_ASSOCIATE | = | 15 | |
| integer, | public, | parameter | :: | C_BLOCK | = | 16 | |
| integer, | public, | parameter | :: | C_BLOCK_DATA | = | 8 | |
| integer, | public, | parameter | :: | C_CONTAINS | = | 21 |
|
| integer, | public, | parameter | :: | C_CRITICAL | = | 17 | |
| integer, | public, | parameter | :: | C_DO | = | 13 | |
| integer, | public, | parameter | :: | C_ENUM | = | 11 | |
| integer, | public, | parameter | :: | C_ENUMERATION | = | 22 |
|
| integer, | public, | parameter | :: | C_FORALL | = | 20 | |
| integer, | public, | parameter | :: | C_FUNCTION | = | 6 | |
| integer, | public, | parameter | :: | C_IF | = | 12 | |
| integer, | public, | parameter | :: | C_INTERFACE | = | 9 | |
| integer, | public, | parameter | :: | C_MODULE | = | 3 | |
| integer, | public, | parameter | :: | C_NONE | = | 0 |
no construct |
| integer, | public, | parameter | :: | C_PROCEDURE | = | 7 |
separate module procedure ( |
| integer, | public, | parameter | :: | C_PROGRAM | = | 2 | |
| integer, | public, | parameter | :: | C_SELECT | = | 14 | |
| integer, | public, | parameter | :: | C_SUBMODULE | = | 4 | |
| integer, | public, | parameter | :: | C_SUBROUTINE | = | 5 | |
| integer, | public, | parameter | :: | C_TEAM | = | 18 | |
| integer, | public, | parameter | :: | C_TYPE | = | 10 | |
| integer, | public, | parameter | :: | C_WHERE | = | 19 | |
| character(len=*), | private, | parameter | :: | LABELS(0:NCONSTRUCTS) | = | [character(len=16)::'none', 'end', 'program', 'module', 'submodule', 'subroutine', 'function', 'procedure', 'block data', 'interface', 'type', 'enum', 'if', 'do', 'select', 'associate', 'block', 'critical', 'change team', 'where', 'forall', 'contains', 'enumeration type'] | |
| integer, | private, | parameter | :: | NCONSTRUCTS | = | 22 | |
| integer, | public, | parameter | :: | ROLE_CLOSE | = | 3 | |
| integer, | public, | parameter | :: | ROLE_MIDDLE | = | 2 | |
| integer, | public, | parameter | :: | ROLE_NONE | = | 0 | |
| integer, | public, | parameter | :: | ROLE_OPEN | = | 1 | |
| integer, | private, | parameter | :: | WORD_LEN | = | 32 |
longer than any keyword |
What a statement does to the block structure, as found by classify_statement.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public | :: | construct | = | C_NONE |
the construct opened, continued or closed: one of the |
|
| integer, | public | :: | do_label | = | 0 |
for |
|
| integer, | public | :: | label | = | 0 |
statement label, or 0 |
|
| character(len=:), | public, | allocatable | :: | name |
construct name, as in |
||
| integer, | public | :: | role | = | ROLE_NONE |
|
The words of a statement, with combined keywords such as endif split into end, if.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public | :: | n | = | 0 |
number of words |
|
| integer, | public, | allocatable | :: | tok(:) |
index into the code token list for each word |
||
| type(string_t), | public, | allocatable | :: | w(:) |
the words of the first token; the others are its code tokens |
Classify a code statement. in_interface is true directly inside an interface block,
where module procedure lists procedures instead of starting one.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | src |
source text |
||
| type(token_list_t), | intent(in) | :: | tokens |
tokens of |
||
| type(statement_view_t), | intent(in) | :: | v |
the statement |
||
| logical, | intent(in) | :: | in_interface |
the innermost open construct is an interface block |
The construct that end second third closes (C_ANY for a bare end), or C_NONE if
second names no construct, so that the end is not a closing statement.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | second |
the word after |
||
| character(len=*), | intent(in) | :: | third |
the word after that, or |
Name of a construct for messages ('if', 'select', 'end' for a bare end), or '?'.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | construct |
one of the |
Split a keyword that may be written as one word (endif, elseif, selectcase,
endblockdata, ...) into its parts. Other words are returned unchanged.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | w |
the word, in lowercase |
Length of the text of construct_label.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | construct |
one of the |
Set label to the value of text, unless that is not a statement label. This is not an internal
read, because it runs in parallel, where those take a lock in the runtime library.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | text |
the label |
||
| integer, | intent(inout) | :: | label |
its value, or as it was |
Set the role and construct of info.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(stmt_info_t), | intent(inout) | :: | info |
the classification to update |
||
| integer, | intent(in) | :: | role |
one of the |
||
| integer, | intent(in) | :: | construct |
one of the |