Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(tree_t), | intent(inout) | :: | self |
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) if (self%tape%current_token == tk_lpar) then self%paren_balance = self%paren_balance +1 end if call self%tape%get_token() call self%regex() ! If regex fails, return immediately. if (.not. self%is_valid) return ! If not a right parenthesis, throw an error. if (self%tape%current_token /= tk_rpar) then self%code = SYNTAX_ERR_PARENTHESIS_MISSING self%is_valid = .false. return end if call self%tape%get_token() case (tk_lsbracket) call self%char_class() if (.not. self%is_valid) then return end if if (self%tape%current_token /= tk_rsbracket) then self%code = SYNTAX_ERR_BRACKET_MISSING self%is_valid = .false. return end if call self%tape%get_token() case (tk_backslash) call self%shorthand() if (.not. self%is_valid) then return end if 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 (tk_rsbracket) self%code = SYNTAX_ERR_BRACKET_UNEXPECTED self%is_valid = .false. return case (tk_rpar) self%code = SYNTAX_ERR_PARENTHESIS_UNEXPECTED self%is_valid = .false. return ! Unescaped closing curly brace is allowed. case (tk_rcurlybrace) 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_lcurlybrace) self%code = SYNTAX_ERR_INVALID_TIMES self%is_valid = .false. return case (tk_star) self%code = SYNTAX_ERR_STAR_INCOMPLETE self%is_valid = .false. return case (tk_plus) self%code = SYNTAX_ERR_PLUS_INCOMPLETE self%is_valid = .false. return case (tk_question) self%code = SYNTAX_ERR_QUESTION_INCOMPLETE self%is_valid = .false. return case default self%code = SYNTAX_ERR_THIS_SHOULD_NOT_HAPPEN self%is_valid = .false. return end select end subroutine tree_graph__primary