Groups tokens into statements and standalone lines.
A code statement runs from its first token to the line break that ends it, including any
continuation lines and the comment, blank and preprocessor lines between them. Statements
separated by ; on one line are split after the ;. Lines outside statements that hold only
blanks, a comment or a preprocessor directive become items of their own. Together the items
cover every token exactly once, in order.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public, | parameter | :: | SK_BLANK | = | 2 |
a line with only blanks |
| integer, | public, | parameter | :: | SK_CODE | = | 1 |
a code statement |
| integer, | public, | parameter | :: | SK_COMMENT | = | 3 |
a line with only a comment |
| integer, | public, | parameter | :: | SK_PREPROC | = | 4 |
a preprocessor directive line |
The items of a source text, in order.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public | :: | n | = | 0 |
number of items |
|
| type(statement_t), | public, | allocatable | :: | s(:) |
storage; only |
| procedure, public :: push | append an item |
An item: a code statement or a standalone line, as a range of the token list.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public | :: | first | = | 1 |
first token |
|
| integer, | public | :: | kind | = | SK_CODE |
one of the SK_* constants |
|
| integer, | public | :: | last | = | 0 |
last token |
The code tokens of one statement, with their lowercase text and bracket depth: what the rules
that read a statement word by word need. The procedures take an index j into code(:);
outside 1:n a word is '' and its kind 0, so a rule can look before and after a token
without checking the bounds.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public, | allocatable | :: | code(:) |
indices into the token list of the code tokens (see code_tokens) |
||
| integer, | public, | allocatable | :: | depth(:) |
open |
||
| integer, | public | :: | first | = | 1 |
first code token after a statement label ( |
|
| integer, | public, | allocatable | :: | hi(:) |
where it ends |
||
| integer, | public, | allocatable | :: | kinds(:) |
kind of each code token ( |
||
| integer, | public, | allocatable | :: | lo(:) |
where the text of each code token starts in |
||
| character(len=:), | public, | allocatable | :: | low |
lowercase text of the code tokens, one after another |
||
| integer, | public | :: | n | = | 0 |
number of code tokens |
| procedure, public :: closing => view_closing | the |
| procedure, public :: is => view_is | whether a code token's lowercase text is a given one |
| procedure, public :: kind_of => view_kind_of | kind of a code token |
| procedure, public :: word => view_word | lowercase text of a code token |
Indices of the code tokens of a statement: no blanks, line breaks, comments, continuation
markers, preprocessor lines or ; separators.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | src |
source text |
||
| type(token_list_t), | intent(in) | :: | tokens |
tokens of |
||
| type(statement_t), | intent(in) | :: | stmt |
the statement |
True if the last token of the line before any comment is a continuation &.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(token_list_t), | intent(in) | :: | tokens |
the token list |
||
| integer, | intent(in) | :: | i |
tokens to search, up to the end of the line |
||
| integer, | intent(in) | :: | lend |
tokens to search, up to the end of the line |
A ; in i:lend that is followed by more code on the line, or 0.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | src |
source text |
||
| type(token_list_t), | intent(in) | :: | tokens |
tokens of |
||
| integer, | intent(in) | :: | i |
tokens to search, up to the end of the line |
||
| integer, | intent(in) | :: | lend |
tokens to search, up to the end of the line |
Index of the line break that ends the line containing token i, or the last token.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(token_list_t), | intent(in) | :: | tokens |
the token list |
||
| integer, | intent(in) | :: | i |
a token at or after the start of the line |
Kind of the line i:lend from its first non-blank token.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(token_list_t), | intent(in) | :: | tokens |
the token list |
||
| integer, | intent(in) | :: | i |
first and last token of the line |
||
| integer, | intent(in) | :: | lend |
first and last token of the line |
The view of code statement stmt (see set_view, which fills one in place, without a copy).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | src |
source text |
||
| type(token_list_t), | intent(in) | :: | tokens |
tokens of |
||
| type(statement_t), | intent(in) | :: | stmt |
the statement |
Index of the ) that closes the ( at code token j (counting only parentheses), or 0 if
token j is not ( or it is not closed.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(statement_view_t), | intent(in) | :: | v |
the statement |
||
| integer, | intent(in) | :: | j |
index into |
True if the lowercase text of code token j is text, without making a copy of it. Outside
the statement only '' matches.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(statement_view_t), | intent(in) | :: | v |
the statement |
||
| integer, | intent(in) | :: | j |
index into |
||
| character(len=*), | intent(in) | :: | text |
the text, in lowercase |
Kind (TK_*) of code token j, or 0 outside the statement.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(statement_view_t), | intent(in) | :: | v |
the statement |
||
| integer, | intent(in) | :: | j |
index into |
Lowercase text of code token j, or '' outside the statement.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(statement_view_t), | intent(in) | :: | v |
the statement |
||
| integer, | intent(in) | :: | j |
index into |
Append item s, growing the storage as needed.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(statement_list_t), | intent(inout) | :: | self |
the item list |
||
| type(statement_t), | intent(in) | :: | s |
item to append |
Make v the view of code statement stmt.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | src |
source text |
||
| type(token_list_t), | intent(in) | :: | tokens |
tokens of |
||
| type(statement_t), | intent(in) | :: | stmt |
the statement |
||
| type(statement_view_t), | intent(out) | :: | v |
the view |
Group tokens into code statements and standalone blank, comment and preprocessor lines.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | src |
source text |
||
| type(token_list_t), | intent(in) | :: | tokens |
tokens of |
||
| type(statement_list_t), | intent(out) | :: | stmts |
the items, covering every token once |