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.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | text |
the token's text |
||
| integer, | intent(in) | :: | kind |
its kind ( |
||
| integer, | intent(out) | :: | a |
the range of the kind in |
||
| integer, | intent(out) | :: | b |
the range of the kind in |
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