tree_graph__primary Subroutine

private pure recursive subroutine tree_graph__primary(self)

Type Bound

tree_t

Arguments

Type IntentOptional Attributes Name
class(tree_t), intent(inout) :: self

Source Code

   pure recursive subroutine tree_graph__primary(self)
      use :: forgex_utf8_m, only: ichar_utf8
      implicit none
      class(tree_t), intent(inout) :: self

      type(tree_node_t) :: node
      type(segment_t) :: seg
      character(:), allocatable :: chara

      select case (self%tape%current_token)
      case (tk_char)
         chara = self%tape%token_char
         seg = segment_t(ichar_utf8(chara), ichar_utf8(chara))
         node = make_atom(seg)
         call self%register_connector(node, terminal, terminal)
         call self%tape%get_token() 
      
      case (tk_lpar)
         call self%tape%get_token()
         call self%regex()
         if (self%tape%current_token /= tk_rpar) then
            error stop "primary: Close parenthesis is expected."
         end if
         call self%tape%get_token()

      case (tk_lsbracket)
         call self%char_class()
         if (self%tape%current_token /= tk_rsbracket) then
            error stop "primary: Close square bracket is expected."
         end if
         call self%tape%get_token()

      case (tk_backslash)
         call self%shorthand()
         call self%tape%get_token()
      
      case (tk_dot)
         node = make_atom(SEG_ANY)
         call self%register_connector(node, terminal, terminal)
         call self%tape%get_token()

      case (tk_caret)
         call self%caret_dollar()
         call self%tape%get_token()
         
      case (tk_dollar)
         call self%caret_dollar()
         call self%tape%get_token()
      
      case default
         error stop "primary: Pattern include some syntax error. "
      end select   

   end subroutine tree_graph__primary