Integer or real literal starting at i (a digit, or . followed by a digit).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | src |
source text |
||
| integer, | intent(in) | :: | i |
first byte of the literal |
||
| integer, | intent(out) | :: | j |
last byte of the literal, including any kind suffix |
||
| integer, | intent(out) | :: | kind |
|
subroutine lex_number(src, i, j, kind) !! Integer or real literal starting at `i` (a digit, or `.` followed by a digit). character(len=*), intent(in) :: src !! source text integer, intent(in) :: i !! first byte of the literal integer, intent(out) :: j !! last byte of the literal, including any kind suffix integer, intent(out) :: kind !! `TK_INT` or `TK_REAL` integer :: k character :: c kind = TK_INT j = digits_end(src, i) if (peek(src, j + 1) == '.' .and. .not. dotop_at(src, j + 1)) then kind = TK_REAL j = digits_end(src, j + 2) end if c = lower_char(peek(src, j + 1)) if (c == 'e' .or. c == 'd' .or. c == 'q') then k = j + 2 if (peek(src, k) == '+' .or. peek(src, k) == '-') k = k + 1 if (is_digit(peek(src, k))) then kind = TK_REAL j = digits_end(src, k) end if end if if (peek(src, j + 1) == '_' .and. is_name_char(peek(src, j + 2))) j = name_end(src, j + 2) end subroutine lex_number