next_state_dense_dfa Function

private pure function next_state_dense_dfa(automaton, curr_i, symbol) result(dst_i)

This function returns the index of the destination DFA state from the index of the current automaton DFA state array and the input symbol.

Arguments

Type IntentOptional Attributes Name
type(automaton_t), intent(in) :: automaton
integer(kind=int32), intent(in) :: curr_i
character(len=*), intent(in) :: symbol

Return Value integer(kind=int32)


Source Code

   pure function next_state_dense_dfa(automaton, curr_i, symbol) result(dst_i)
      use :: forgex_segment_m, only: symbol_to_segment, operator(.in.)
      implicit none
      type(automaton_t), intent(in) :: automaton
      integer(int32), intent(in) :: curr_i
      character(*), intent(in) :: symbol

      type(dfa_state_node_t) :: d_node
      type(dfa_transition_t) :: d_tra

      integer(int32) :: dst_i, j

      d_node = automaton%dfa%nodes(curr_i)
      dst_i = DFA_INVALID_INDEX
      do j = 1, d_node%get_tra_top()
         d_tra = d_node%transition(j)
         if (symbol_to_segment(symbol) .in. d_tra%c) then
            dst_i = d_tra%dst
            return
         end if
      end do
   end function next_state_dense_dfa