Block structure of a file: the nesting depth of every statement, from a stack of open
constructs, plus diagnostics for statements that do not fit (an end with nothing to close,
an else outside an if, a construct still open at the end of the file, ...).
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private, | parameter | :: | FY_CLOSE | = | 3 |
|
| integer, | private, | parameter | :: | FY_MIDDLE | = | 2 |
|
| integer, | private, | parameter | :: | FY_OPEN | = | 1 |
|
| integer, | private, | parameter | :: | FY_OTHER | = | 0 |
not a block directive ( |
| integer, | private, | parameter | :: | PP_ELSE | = | 2 | |
| integer, | private, | parameter | :: | PP_ENDIF | = | 3 | |
| integer, | private, | parameter | :: | PP_IF | = | 1 | |
| integer, | private, | parameter | :: | PP_OTHER | = | 0 |
A problem with the block structure, such as an end that matches no open construct.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public | :: | line | = | 0 |
source line of the statement concerned |
|
| character(len=:), | public, | allocatable | :: | message |
what is wrong, e.g. |
Scope stacks for one preprocessor conditional: as it was at the #if (restored at each
#elif / #else) and as it was at the end of the first branch (used after #endif).
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(scope_t), | public, | allocatable | :: | after_first(:) |
the stack at the end of the first branch; unallocated until then |
||
| type(scope_t), | public, | allocatable | :: | at_if(:) |
the stack at the |
The open constructs, outermost first.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(scope_t), | public, | allocatable | :: | s(:) |
storage; only |
||
| integer, | public | :: | top | = | 0 |
number of open constructs |
| procedure, public :: push => stack_push | open a construct |
| procedure, public :: restore => stack_restore | replace the open constructs by saved ones |
| procedure, public :: snapshot => stack_snapshot | the open constructs, to save |
An open construct on the scope stack.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public | :: | construct | = | C_NONE |
one of the |
|
| integer, | public | :: | do_label | = | 0 |
for |
|
| integer, | public | :: | line | = | 0 |
source line of the opening statement |
The block structure of a source: for each item (see ffmt_statements) what it is and how deeply it is nested.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public, | allocatable | :: | depth(:) |
nesting depth of each item: the constructs around it |
||
| integer, | public, | allocatable | :: | fypp(:) |
fypp blocks ( |
||
| type(stmt_info_t), | public, | allocatable | :: | info(:) |
classification of each item ( |
||
| integer, | public, | allocatable | :: | procedures(:) |
how many are procedure definitions (subroutine, function or separate module procedure, but not interface bodies) |
||
| integer, | public, | allocatable | :: | units(:) |
how many of those are program units (module, submodule or main program) |
True if an end of kind closing ends the open construct open.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | closing |
construct named by the |
||
| integer, | intent(in) | :: | open |
construct that is open |
Kind of a preprocessor line (lowercase text): PP_IF, PP_ELSE (#elif, #else), PP_ENDIF
or PP_OTHER.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | text |
text of the preprocessor token, in lowercase |
The number of fypp blocks around each item of source. The directives are counted wherever
they are, also inside a continued statement; a directive line itself is at the level outside
its block, like else and end statements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(source_t), | intent(in) | :: | source |
the source |
Kind of a preprocessor line (lowercase text) as a fypp block directive: one of the FY_* constants.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | text |
text of the preprocessor token, in lowercase |
True if a middle statement of construct middle (else of C_IF, contains, ...) may
appear directly inside the open construct open.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | middle |
construct of the middle statement |
||
| integer, | intent(in) | :: | open |
construct that is open |
The open constructs, outermost first.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(scope_stack_t), | intent(in) | :: | self |
the stack |
Classify every statement and compute its depth: the number of constructs enclosing it, and
how many of those are program units and procedures, so callers can choose not to indent
their bodies.
An opening statement is at the depth outside its construct, the statements inside are one
deeper, and middle (else, contains, ...) and closing statements are at the opening depth.
Non-code items get the depth of the code around them.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(source_t), | intent(in) | :: | source |
the source |
||
| type(statement_view_t), | intent(in) | :: | views(:) |
the view of each item (see statement_views) |
||
| type(structure_t), | intent(out) | :: | st |
the structure |
||
| type(diagnostic_t), | intent(out), | allocatable | :: | diags(:) |
structure problems found, in the order found |
Open construct sc, growing the storage as needed.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(scope_stack_t), | intent(inout) | :: | self |
the stack |
||
| type(scope_t), | intent(in) | :: | sc |
the construct to open |
Replace the open constructs by scopes (outermost first).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(scope_stack_t), | intent(inout) | :: | self |
the stack |
||
| type(scope_t), | intent(in) | :: | scopes(:) |
a saved stack (see stack_snapshot) |