dfa_state_node__add_transition Subroutine

private pure subroutine dfa_state_node__add_transition(self, tra)

This subroutine processes to add the given transition to the list which dfa_state_node_t has.

Type Bound

dfa_state_node_t

Arguments

Type IntentOptional Attributes Name
class(dfa_state_node_t), intent(inout) :: self
type(dfa_transition_t), intent(in) :: tra

Source Code

   pure subroutine dfa_state_node__add_transition (self, tra)
      implicit none
      class(dfa_state_node_t), intent(inout) :: self
      type(dfa_transition_t), intent(in) :: tra

      integer :: j

      if (.not. self%initialized .or. .not. allocated(self%transition)) then
         call self%realloc_f()
      end if

      !== At this point, self%transition is definitely already assigned. ==!

      if (self%get_tra_top() == DFA_NOT_INIT_TRAENSITION_TOP) then
         error stop "ERROR: Invalid counting transitions"
      end if

      if (.not. allocated(self%transition)) then
         error stop "ERROR: Transition array not allocated."
      end if

      call self%increment_tra_top()
      j = self%get_tra_top()

      if (j >= size(self%transition, dim=1)) then
         call self%realloc_f()
      end if

      self%transition(j) = tra
   end subroutine dfa_state_node__add_transition