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 |
the ) that closes a (
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 |
whether a code token's lowercase text is a given one
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 of a code token
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 a code token
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 |
type, public :: statement_view_t !! 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. integer, allocatable :: code(:) !! indices into the token list of the code tokens !! (see [[code_tokens]]) integer :: n = 0 !! number of code tokens integer :: first = 1 !! first code token after a statement label (`10 continue`) integer, allocatable :: kinds(:) !! kind of each code token (`TK_*`) integer, allocatable :: depth(:) !! open `(` and `[` around each code token; a bracket is !! outside its own pair character(len=:), allocatable :: low !! lowercase text of the code tokens, one after another integer, allocatable :: lo(:) !! where the text of each code token starts in `low` integer, allocatable :: hi(:) !! where it ends contains procedure :: word => view_word !! lowercase text of a code token procedure :: is => view_is !! whether a code token's lowercase text is a given one procedure :: kind_of => view_kind_of !! kind of a code token procedure :: closing => view_closing !! the `)` that closes a `(` end type statement_view_t