cla__do_debug_subc Subroutine

private subroutine cla__do_debug_subc(cla)

Processes the debug command, reads a subcommand, and calls the corresponding procedure.

Type Bound

cla_t

Arguments

Type IntentOptional Attributes Name
class(cla_t), intent(inout) :: cla

Source Code

   subroutine cla__do_debug_subc(cla)
      use :: forgex_cli_debug_m
      implicit none
      class(cla_t), intent(inout) :: cla
      integer :: pattern_offset

      pattern_offset = 3

      call cla%init_debug()
      call cla%read_subc()
      if (cla%sub_cmd%get_name() == '') then
         call print_help_debug
      end if

      call cla%get_patterns(pattern_offset)

      ! Handle errors when a pattern does not exist.
      if (.not. allocated(cla%patterns)) then
         select case (cla%sub_cmd%get_name())
         case (SUBC_AST)
            call print_help_debug_ast
         case (SUBC_THOMPSON)
            call print_help_debug_thompson
         case default
            call print_help_debug
         end select
      end if

      if (size(cla%patterns) > 1) then
         write(stderr, '(a, i0, a)') "Only single pattern is expected, but ", size(cla%patterns), " were given."
         stop
      end if


      select case (cla%sub_cmd%get_name())
      case (SUBC_AST)
         call do_debug_ast(cla%flags, cla%patterns(1)%p)

      case (SUBC_THOMPSON)
         call do_debug_thompson(cla%flags, cla%patterns(1)%p)

      end select

   end subroutine cla__do_debug_subc