kind_part Subroutine

public pure subroutine kind_part(text, kind, a, b)

Where the kind is in the text of a token of kind kind: text(a:b), or b < a if it has none. For a logical constant it is the suffix (_lk in .true._lk), for a string the prefix (ck in ck_'a'). Numbers have letters only in their exponent and kind, so they are cased whole.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: text

the token's text

integer, intent(in) :: kind

its kind (TK_*)

integer, intent(out) :: a

the range of the kind in text

integer, intent(out) :: b

the range of the kind in text


Called by

proc~~kind_part~~CalledByGraph proc~kind_part kind_part proc~compute_case compute_case proc~compute_case->proc~kind_part proc~emit_body emit_body proc~emit_body->proc~kind_part proc~emit_continuation emit_continuation proc~emit_continuation->proc~emit_body proc~emit_statement emit_statement proc~emit_statement->proc~emit_body proc~emit_statement->proc~emit_continuation proc~format_pass format_pass proc~format_pass->proc~compute_case proc~layout layout proc~format_pass->proc~layout proc~format_text format_text proc~format_text->proc~format_pass proc~relayout relayout proc~format_text->proc~relayout proc~layout->proc~emit_statement proc~relayout->proc~format_pass proc~process_text process_text proc~process_text->proc~format_text proc~process_file process_file proc~process_file->proc~process_text proc~process_stdin process_stdin proc~process_stdin->proc~process_text proc~run run proc~run->proc~process_file proc~run->proc~process_stdin

Source Code

pure subroutine kind_part(text, kind, a, b)
    !! Where the kind is in the text of a token of kind `kind`: `text(a:b)`, or `b < a` if it has none.
    !! For a logical constant it is the suffix (`_lk` in `.true._lk`), for a string the prefix (`ck` in
    !! `ck_'a'`). Numbers have letters only in their exponent and kind, so they are cased whole.
    character(len=*), intent(in) :: text   !! the token's text
    integer, intent(in) :: kind            !! its kind (`TK_*`)
    integer, intent(out) :: a, b           !! the range of the kind in `text`
    integer :: p
    a = 1
    b = 0
    select case (kind)
    case (TK_DOTOP)
        p = index(text, '.', back=.true.)
        if (p > 1 .and. p < len(text)) then
            if (text(p + 1:p + 1) == '_') then
                a = p + 2
                b = len(text)
            end if
        end if
    case (TK_STRING)
        p = scan(text, '"'//"'")
        if (p > 2) then
            if (text(p - 1:p - 1) == '_') b = p - 2
        end if
    end select
end subroutine kind_part