TokenIterator_t Derived Type

type, public :: TokenIterator_t

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.


Components

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).


Type-Bound Procedures

procedure, public :: size => size_TokenIterator_t

  • private elemental function size_TokenIterator_t(this)

    Return the number of tokens in this Iterator.

    Arguments

    Type IntentOptional Attributes Name
    class(TokenIterator_t), intent(in) :: this

    Return Value integer

procedure, public :: remaining_items

  • private elemental function remaining_items(this)

    Return the number of remaining items in this Iterator.

    Arguments

    Type IntentOptional Attributes Name
    class(TokenIterator_t), intent(in) :: this

    Return Value integer

procedure, public :: get_rest

  • private function get_rest(this) result(res)

    Arguments

    Type IntentOptional Attributes Name
    class(TokenIterator_t), intent(inout) :: this

    Return Value type(Token_t), (this%remaining_items())

procedure, public :: next

  • private function next(this, if_exhausted) result(res)

    Return the next Token and increment the iterator.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(TokenIterator_t), intent(inout) :: this
    character(len=*), intent(in), optional :: if_exhausted

    Return Value character(len=:), allocatable

procedure, public :: glimpse

  • private function glimpse(this, if_exhausted) result(res)

    Return the next Token.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(TokenIterator_t), intent(inout) :: this
    character(len=*), intent(in), optional :: if_exhausted

    Return Value character(len=:), allocatable

procedure, public :: reset

  • private elemental subroutine reset(this, k)

    Reset the iterator

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(TokenIterator_t), intent(inout) :: this
    integer, intent(in), optional :: k