automaton__destination Subroutine

private pure subroutine automaton__destination(self, curr, symbol, next, next_set)

This subroutine gets the next DFA nodes index from current index and symbol, and stores the result in next and next_set.

Type Bound

automaton_t

Arguments

Type IntentOptional Attributes Name
class(automaton_t), intent(in) :: self
integer(kind=int32), intent(in) :: curr
character(len=*), intent(in) :: symbol
integer(kind=int32), intent(inout) :: next
type(nfa_state_set_t), intent(inout) :: next_set

Source Code

   pure subroutine automaton__destination(self, curr, symbol, next, next_set)
      implicit none
      class(automaton_t),    intent(in) :: self
      integer(int32),        intent(in) :: curr
      character(*),          intent(in) :: symbol
      integer(int32),        intent(inout) :: next
      type(nfa_state_set_t), intent(inout) :: next_set

      integer :: i

      ! Get a set of NFAs for which current state can transition, excluding epsilon-transitions.
      next_set = self%get_reachable(curr, symbol)

      ! Initialize the next value
      next = DFA_INVALID_INDEX

      ! Scan the entire DFA nodes.
      do i = 1, self%dfa%dfa_top-1

         ! If there is an existing node corresponding to the NFA state set,
         ! return the index of that node.
         if (equivalent_nfa_state_set(next_set, self%dfa%nodes(i)%nfa_set)) then
            next = i
            return
         end if

      end do
   end subroutine automaton__destination