generate_nfa_closure Subroutine

public pure recursive subroutine generate_nfa_closure(tree, idx, nfa, entry_i, exit_i)

Arguments

Type IntentOptional Attributes Name
type(tree_t), intent(in) :: tree
integer(kind=int32), intent(in) :: idx
type(nfa_graph_t), intent(inout) :: nfa
integer(kind=int32), intent(in) :: entry_i
integer(kind=int32), intent(in) :: exit_i

Source Code

   pure recursive subroutine generate_nfa_closure(tree, idx, nfa, entry_i, exit_i)
      implicit none
      type(tree_t), intent(in) :: tree
      type(nfa_graph_t), intent(inout) :: nfa
      integer(int32), intent(in) :: idx
      integer(int32), intent(in) :: entry_i, exit_i

      integer(int32) :: node1, node2

      call nfa%new_nfa_node()
      if (nfa%is_exceeded()) call nfa%reallocate()
      node1 = nfa%top

      call nfa%new_nfa_node()
      if (nfa%is_exceeded()) call nfa%reallocate()
      node2 = nfa%top

      call nfa%graph(entry_i)%add_transition(entry_i, node1, [SEG_EPSILON])
      call generate_nfa(tree, tree%nodes(idx)%left_i, nfa, node1, node2)

      call nfa%graph(node2)%add_transition(node2, node1, [SEG_EPSILON])
      call nfa%graph(node1)%add_transition(node1, exit_i, [SEG_EPSILON])

   end subroutine generate_nfa_closure