This subroutine updates the NFA state transitions by disjoining the segments.
It breaks down overlapping segments into non-overlapping segments, and creates new transitions accordingly.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(nfa_transition_t), | intent(inout) | :: | transition | |||
type(segment_t), | intent(in) | :: | seg_list(:) |
pure subroutine disjoin_nfa_each_transition(transition, seg_list) use :: forgex_segment_disjoin_m implicit none type(nfa_transition_t), intent(inout) :: transition type(segment_t), intent(in) :: seg_list(:) type(segment_t), allocatable :: tmp(:) integer :: k, m, n, siz if (.not. allocated(transition%c)) return siz = size(seg_list, dim=1) allocate(tmp(siz)) block logical :: flag(siz) n = 0 ! to count valid disjoined segments. do k = 1, transition%c_top flag(:) = is_overlap_to_seg_list(transition%c(k), seg_list, siz) do m = 1, siz if (flag(m)) then n = n + 1 tmp(n) = seg_list(m) end if end do end do end block if (size(transition%c, dim=1) < n) then deallocate(transition%c) allocate(transition%c(n)) end if ! Deep copy the result into the arguemnt's component do k = 1, n transition%c(k) = tmp(k) end do call update_c_top(transition) deallocate(tmp) end subroutine disjoin_nfa_each_transition