Get the currently focused character (1 to 4 bytes) from the entire string inside
the type_t
derived-type, and store the enumerator's numeric value in the
current_token
component.
This is a type-bound procedure of tape_t
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(tape_t), | intent(inout) | :: | self | |||
logical, | intent(in), | optional | :: | class_flag |
pure subroutine get_token(self, class_flag) use :: forgex_utf8_m, only: idxutf8 implicit none class(tape_t), intent(inout) :: self logical, optional, intent(in) :: class_flag character(UTF8_CHAR_SIZE) :: c integer(int32) :: ib, ie ib = self%idx if (ib > len(self%str)) then self%current_token = tk_end self%token_char = '' else ie = idxutf8(self%str, ib) c = self%str(ib:ie) if (present(class_flag)) then if (class_flag) then select case (trim(c)) case (SYMBOL_RSBK) self%current_token = tk_rsbracket case (SYMBOL_HYPN) self%current_token = tk_hyphen self%token_char = c case default self%current_token = tk_char self%token_char = c end select end if else select case(trim(c)) case (SYMBOL_VBAR) self%current_token = tk_union case (SYMBOL_LPAR) self%current_token = tk_lpar case (SYMBOL_RPAR) self%current_token = tk_rpar case (SYMBOL_STAR) self%current_token = tk_star case (SYMBOL_PLUS) self%current_token = tk_plus case (SYMBOL_QUES) self%current_token = tk_question case (SYMBOL_BSLH) self%current_token = tk_backslash ib = ie +1 ie = idxutf8(self%str, ib) self%token_char = self%str(ib:ie) case (SYMBOL_LSBK) self%current_token = tk_lsbracket case (SYMBOL_RSBK) self%current_token = tk_rsbracket case (SYMBOL_LCRB) self%current_token = tk_lcurlybrace case (SYMBOL_RCRB) self%current_token = tk_rcurlybrace case (SYMBOL_DOT) self%current_token = tk_dot case (SYMBOL_CRET) self%current_token = tk_caret case (SYMBOL_DOLL) self%current_token = tk_dollar case default self%current_token = tk_char self%token_char = c end select end if self%idx = ie + 1 end if end subroutine get_token