abstract_lexer Derived Type

type, public, abstract :: abstract_lexer

Abstract base class for TOML lexers.


Type-Bound Procedures

Extract a token

  • private subroutine extract_string(lexer, token, string)

    Extract string value of token, works for keypath, string, multiline string, literal, and mulitline literal tokens.

    Arguments

    Type IntentOptional Attributes Name
    class(toml_lexer), intent(in) :: lexer

    Instance of the lexer

    type(toml_token), intent(in) :: token

    Token to extract string value from

    character(len=:), intent(out), allocatable :: string

    String value of token

  • private subroutine extract_integer(lexer, token, val)

    Extract integer value of token

    Arguments

    Type IntentOptional Attributes Name
    class(toml_lexer), intent(in) :: lexer

    Instance of the lexer

    type(toml_token), intent(in) :: token

    Token to extract integer value from

    integer(kind=tfi), intent(out) :: val

    Integer value of token

  • private subroutine extract_float(lexer, token, val)

    Extract floating point value of token

    Arguments

    Type IntentOptional Attributes Name
    class(toml_lexer), intent(in) :: lexer

    Instance of the lexer

    type(toml_token), intent(in) :: token

    Token to extract floating point value from

    real(kind=tfr), intent(out) :: val

    Floating point value of token

  • private subroutine extract_bool(lexer, token, val)

    Extract boolean value of token

    Arguments

    Type IntentOptional Attributes Name
    class(toml_lexer), intent(in) :: lexer

    Instance of the lexer

    type(toml_token), intent(in) :: token

    Token to extract boolean value from

    logical, intent(out) :: val

    Boolean value of token

  • private subroutine extract_datetime(lexer, token, val)

    Extract datetime value of token

    Arguments

    Type IntentOptional Attributes Name
    class(toml_lexer), intent(in) :: lexer

    Instance of the lexer

    type(toml_token), intent(in) :: token

    Token to extract datetime value from

    type(toml_datetime), intent(out) :: val

    Datetime value of token

procedure(extract_bool), public, deferred :: extract_bool

Extract a boolean from a token

  • subroutine extract_bool(lexer, token, val) Prototype

    Extract boolean value of token

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_lexer), intent(in) :: lexer

    Instance of the lexer

    type(toml_token), intent(in) :: token

    Token to extract boolean value from

    logical, intent(out) :: val

    Boolean value of token

procedure(extract_datetime), public, deferred :: extract_datetime

Extract a timestamp from a token

  • subroutine extract_datetime(lexer, token, val) Prototype

    Extract datetime value of token

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_lexer), intent(in) :: lexer

    Instance of the lexer

    type(toml_token), intent(in) :: token

    Token to extract datetime value from

    type(toml_datetime), intent(out) :: val

    Datetime value of token

procedure(extract_float), public, deferred :: extract_float

Extract a float from a token

  • subroutine extract_float(lexer, token, val) Prototype

    Extract floating point value of token

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_lexer), intent(in) :: lexer

    Instance of the lexer

    type(toml_token), intent(in) :: token

    Token to extract floating point value from

    real(kind=tfr), intent(out) :: val

    Floating point value of token

procedure(extract_integer), public, deferred :: extract_integer

Extract an integer from a token

  • subroutine extract_integer(lexer, token, val) Prototype

    Extract integer value of token

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_lexer), intent(in) :: lexer

    Instance of the lexer

    type(toml_token), intent(in) :: token

    Token to extract integer value from

    integer(kind=tfi), intent(out) :: val

    Integer value of token

procedure(extract_string), public, deferred :: extract_string

Extract a string from a token

  • subroutine extract_string(lexer, token, string) Prototype

    Extract string value of token, works for keypath, string, multiline string, literal, and mulitline literal tokens.

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_lexer), intent(in) :: lexer

    Instance of the lexer

    type(toml_token), intent(in) :: token

    Token to extract string value from

    character(kind=tfc, len=:), intent(out), allocatable :: string

    String value of token

procedure(get_info), public, deferred :: get_info

Get information about the source

  • subroutine get_info(lexer, meta, output) Prototype

    Extract information about the source

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_lexer), intent(in) :: lexer

    Instance of the lexer

    character(kind=tfc, len=*), intent(in) :: meta

    Query about the source

    character(kind=tfc, len=:), intent(out), allocatable :: output

    Metadata about the source

procedure(next), public, deferred :: next

Obtain the next token

  • subroutine next(lexer, token) Prototype

    Advance the lexer to the next token.

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_lexer), intent(inout) :: lexer

    Instance of the lexer

    type(toml_token), intent(inout) :: token

    Current lexeme

Source Code

   type, abstract :: abstract_lexer
   contains
      !> Obtain the next token
      procedure(next), deferred :: next
      !> Extract a token
      generic :: extract => &
         & extract_string, extract_integer, extract_float, extract_bool, extract_datetime
      !> Extract a string from a token
      procedure(extract_string), deferred :: extract_string
      !> Extract an integer from a token
      procedure(extract_integer), deferred :: extract_integer
      !> Extract a float from a token
      procedure(extract_float), deferred :: extract_float
      !> Extract a boolean from a token
      procedure(extract_bool), deferred :: extract_bool
      !> Extract a timestamp from a token
      procedure(extract_datetime), deferred :: extract_datetime
      !> Get information about the source
      procedure(get_info), deferred :: get_info
   end type abstract_lexer