destination Subroutine

private pure subroutine destination(automaton, curr, next, next_set)

This subroutine gets the next DFA nodes index from current index, and stores the result in next and next_set. If the DFA state is already registered, it returns the index, otherwise it returns DFA_INVALID_INDEX.

Arguments

Type IntentOptional Attributes Name
type(automaton_t), intent(in) :: automaton
integer(kind=int32), intent(in) :: curr
integer(kind=int32), intent(inout) :: next
type(nfa_state_set_t), intent(inout) :: next_set

Source Code

   pure subroutine destination(automaton, curr, next, next_set)
      implicit none
      type(automaton_t), intent(in) :: automaton
      integer(int32), intent(in) :: curr
      integer(int32), intent(inout) :: next
      type(nfa_state_set_t), intent(inout) :: next_set

      integer :: i

      next_set = compute_reachable_state(automaton, curr)

      ! すでに登録されたDFAがある場合はその添字を返し、ない場合は`DFA_INVALID_INDEX`を返す。
      !! If the DFA state is already registered, it returns the index,
      !! otherwise it returns `DFA_INVALID_INDEX`.
      next = DFA_INVALID_INDEX
      do i = 1, automaton%dfa%dfa_top-1
         if (equivalent_nfa_state_set(next_set, automaton%dfa%nodes(i)%nfa_set)) then
            next = i
            return
         end if
      end do
   end subroutine destination