This function checks whether the correct prefix is extracted for a given pattern.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | pattern | |||
character(len=*), | intent(in) | :: | expected_prefix |
function is_valid__prefix(pattern, expected_prefix) result(res) use :: forgex_syntax_tree_optimize_m, only: get_prefix_literal use :: forgex_utf8_m, only: len_utf8 implicit none character(*), intent(in) :: pattern, expected_prefix logical :: res character(:), allocatable :: resulting type(tree_t) :: tree call tree%build(pattern) resulting = get_prefix_literal(tree) if (len_utf8(expected_prefix) == len_utf8(resulting)) then res = expected_prefix == resulting return end if res = .false. end function is_valid__prefix