Tokenizer for TOML documents.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | buffer | = | 0 |
Index in the buffer queue |
|
character(kind=tfc, len=:), | public, | allocatable | :: | chunk |
Current source chunk, for convenience stored as character array rather than string |
||
type(toml_context), | public | :: | context |
Douple-ended queue for buffering tokens |
|||
character(len=:), | public, | allocatable | :: | filename |
Name of the source file, used for error reporting |
||
integer, | public | :: | pos | = | 0 |
Current internal position in the source chunk |
|
type(stack_item), | public, | allocatable | :: | stack(:) |
Stack of scopes, used to identify the current state of the lexer |
||
integer, | public | :: | top | = | 0 |
Last scope of the lexer |
Extract string value of token, works for keypath, string, multiline string, literal, and mulitline literal tokens.
Type | Intent | Optional | 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 |
Extract integer value of token
Type | Intent | Optional | 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 |
Extract floating point value of token
Type | Intent | Optional | 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 |
Extract boolean value of token
Type | Intent | Optional | 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 |
Extract datetime value of token
Type | Intent | Optional | 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 |
Extract a boolean from a token
Extract boolean value of token
Type | Intent | Optional | 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 |
Extract a timestamp from a token
Extract datetime value of token
Type | Intent | Optional | 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 |
Extract a float from a token
Extract floating point value of token
Type | Intent | Optional | 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 |
Extract an integer from a token
Extract integer value of token
Type | Intent | Optional | 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 |
Extract a string from a token
Extract string value of token, works for keypath, string, multiline string, literal, and mulitline literal tokens.
Type | Intent | Optional | 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 |
Get information about source
Extract information about the source
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(toml_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 |
Obtain the next token
Advance the lexer to the next token.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(toml_lexer), | intent(inout) | :: | lexer |
Instance of the lexer |
||
type(toml_token), | intent(inout) | :: | token |
Current lexeme |
type, extends(abstract_lexer) :: toml_lexer !> Name of the source file, used for error reporting character(len=:), allocatable :: filename !> Current internal position in the source chunk integer :: pos = 0 !> Current source chunk, for convenience stored as character array rather than string character(:, tfc), allocatable :: chunk !> Last scope of the lexer integer :: top = 0 !> Stack of scopes, used to identify the current state of the lexer type(stack_item), allocatable :: stack(:) !> Index in the buffer queue integer :: buffer = 0 !> Douple-ended queue for buffering tokens type(toml_context) :: context contains !> Obtain the next token procedure :: next !> Extract a string from a token procedure :: extract_string !> Extract an integer from a token procedure :: extract_integer !> Extract a float from a token procedure :: extract_float !> Extract a boolean from a token procedure :: extract_bool !> Extract a timestamp from a token procedure :: extract_datetime !> Get information about source procedure :: get_info end type toml_lexer