subroutine nfa_graph__print(self, uni, nfa_exit)
use, intrinsic :: iso_fortran_env, only: stderr=>error_unit
use :: forgex_segment_m, only: segment_t, SEG_INIT, operator(==)
implicit none
class(nfa_graph_t), intent(in) :: self
integer(int32), intent(in) :: uni
integer(int32), intent(in) :: nfa_exit
type(nfa_state_node_t) :: node
type(nfa_transition_t) :: transition
character(:), allocatable :: buf
integer(int32) :: i, j, k
type(segment_t), allocatable :: seglist(:)
do i = self%nfa_base, self%top
write(uni, '(a, i4, a)', advance='no') "state ", i, ": "
! node = self%graph(i)
if (i == nfa_exit) then
write(uni, '(a)') "<Accepted>"
cycle
end if
do j = 1, self%graph(i)%forward_top
if (.not. allocated(self%graph(i)%forward)) cycle
! transition = self%graph(i)%forward(j)
if (self%graph(i)%forward(j)%c%is_flagged_epsilon()) then
write(uni, '(a,a,a2,i0,a1)', advance='no') "(", "?", ", ", self%graph(i)%forward(j)%dst, ")"
end if
call self%graph(i)%forward(j)%c%cube2seg(seglist)
if (self%graph(i)%forward(j)%dst /= NFA_NULL_TRANSITION .and. allocated(seglist)) then
do k = 1, size(seglist, dim=1)
if (seglist(k) == SEG_INIT) cycle
buf = seglist(k)%print()
write(uni, '(a,a,a2,i0,a1)', advance='no') "(", trim(buf), ", ", self%graph(i)%forward(j)%dst, ")"
enddo
end if
end do
write(uni, '(a)') ""
end do
end subroutine nfa_graph__print