A class for looping over tokens parsed from semantic lines.
Note that a semantic line may stretch over several “raw” lines, if line continuation is used.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(Token_t), | public, | allocatable | :: | tokens(:) | |||
integer, | private | :: | i_curr_token | = | 1 | ||
character(len=:), | private, | allocatable | :: | file_name |
The name of file where the line came from (if available). |
||
integer, | private, | allocatable | :: | current_line |
The current line (if available). |
Return the number of tokens in this Iterator.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(TokenIterator_t), | intent(in) | :: | this |
Return the number of remaining items in this Iterator.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(TokenIterator_t), | intent(in) | :: | this |
Return the next Token and increment the iterator.
If the iterator is exhausted, this function throws an error
unless the argument if_exhausted
is present, which is then
returned instead.
To view the next Token without incrementing the iterator
use glimpse
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(TokenIterator_t), | intent(inout) | :: | this | |||
character(len=*), | intent(in), | optional | :: | if_exhausted |
Return the next Token.
If the iterator is exhausted, this function throws an error
unless the argument if_exhausted
is present, which is then
returned instead.
To view the next Token and incrementing the iterator
use next
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(TokenIterator_t), | intent(inout) | :: | this | |||
character(len=*), | intent(in), | optional | :: | if_exhausted |
Reset the iterator
If k
is not present, the iterator is reset to the beginning.
If k
is present, it has to be smaller 0 and resets the
iterator by this amount of steps.
In particular call tokens%reset(-1)
resets the
iterator one element and allows to reread the previous element.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(TokenIterator_t), | intent(inout) | :: | this | |||
integer, | intent(in), | optional | :: | k |