Theforgex_syntax_tree_m
module defines parsing and
the tree_node_t
derived-type for building syntax-tree.
The regular expression parsing performed by this module is done using recursive descent parsing.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=UTF8_CHAR_SIZE), | public, | parameter | :: | EMPTY | = | char(0) | |
type(tree_node_t), | public, | parameter | :: | terminal | = | tree_node_t(op=op_not_init, left_i=TERMINAL_INDEX, right_i=TERMINAL_INDEX, parent_i=INVALID_INDEX, own_i=INVALID_INDEX, min_repeat=INVALID_REPEAT_VAL, max_repeat=INVALID_REPEAT_VAL) |
This type holds the input pattern string and manages the index of the character it is currently focused.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer(kind=int32), | public | :: | current_token | ||||
integer(kind=int32), | public | :: | idx | = | 0 | ||
character(len=:), | public, | allocatable | :: | str | |||
character(len=UTF8_CHAR_SIZE), | public | :: | token_char | = | EMPTY |
procedure, public :: get_token |
This type is used to construct a concrete syntax tree, later converted to NFA.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(segment_t), | public, | allocatable | :: | c(:) | |||
logical, | public | :: | is_registered | = | .false. | ||
integer(kind=int32), | public | :: | left_i | = | INVALID_INDEX | ||
integer(kind=int32), | public | :: | max_repeat | ||||
integer(kind=int32), | public | :: | min_repeat | ||||
integer(kind=int32), | public | :: | op | = | op_not_init | ||
integer(kind=int32), | public | :: | own_i | = | INVALID_INDEX | ||
integer(kind=int32), | public | :: | parent_i | = | INVALID_INDEX | ||
integer(kind=int32), | public | :: | right_i | = | INVALID_INDEX |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(segment_t), | intent(in) | :: | segment |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int32), | intent(in) | :: | min | |||
integer(kind=int32), | intent(in) | :: | max |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int32), | intent(in) | :: | op |
This subroutine deallocate the syntax tree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tree_node_t), | intent(inout), | allocatable | :: | tree(:) |
Get the currently focused character (1 to 4 bytes) from the entire string inside
the type_t
derived-type, and store the enumerator's numeric value in the
current_token
component.
This is a type-bound procedure of tape_t
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(tape_t), | intent(inout) | :: | self | |||
logical, | intent(in), | optional | :: | class_flag |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tree_node_t), | intent(inout), | allocatable | :: | tree(:) | ||
integer, | intent(inout) | :: | alloc_count |