This function checks whether the correct suffix is extracted for a given pattern.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | pattern | |||
character(len=*), | intent(in) | :: | expected_suffix | |||
character(len=:), | intent(inout), | allocatable | :: | resulting |
function is_valid__suffix(pattern, expected_suffix, resulting) result(res) use :: forgex_syntax_tree_optimize_m, only: extract_literal use :: forgex_utf8_m, only: len_utf8 implicit none character(*), intent(in) :: pattern, expected_suffix logical :: res character(:), allocatable, intent(inout) :: resulting character(:), allocatable :: unused_1, unused_2, unused_3 type(tree_t) :: tree call tree%build(pattern) ! resulting = get_suffix_literal(tree) call extract_literal(tree, unused_1, unused_2, resulting, unused_3) if (len_utf8(expected_suffix) == len_utf8(resulting)) then res = expected_suffix == resulting return end if res = .false. end function is_valid__suffix