Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tree_node_t), | intent(in) | :: | tree(:) | |||
integer(kind=int32), | intent(in) | :: | idx | |||
character(len=:), | intent(inout), | allocatable | :: | literal | ||
logical, | intent(inout) | :: | res |
pure recursive subroutine get_entire_literal_internal(tree, idx, literal, res) use :: forgex_syntax_tree_node_m implicit none type(tree_node_t), intent(in) :: tree(:) integer(int32), intent(in) :: idx character(:), allocatable, intent(inout) :: literal logical, intent(inout) :: res type(tree_node_t) :: node integer :: i node = tree(idx) if (node%op == op_concat) then call get_entire_literal_internal(tree, node%left_i, literal, res) if (literal == '') return if (res) then call get_entire_literal_internal(tree, node%right_i, literal, res) else literal = '' end if if (literal == '') return else if (node%op == op_repeat) then if (node%max_repeat == node%min_repeat) then do i = 1, node%min_repeat call get_entire_literal_internal(tree, node%left_i, literal, res) end do else res = .false. literal = '' end if else if (is_literal_tree_node(node)) then ! This size function is safe because is_literal_function returns false ! if the node%c is not allocated. if (size(node%c, dim=1) == 1) then if (node%c(1)%min == node%c(1)%max) then literal = literal//char_utf8(node%c(1)%min) res = .true. return end if end if res = .false. literal = '' else res = .false. literal = '' end if end subroutine get_entire_literal_internal