lex_number Subroutine

private subroutine lex_number(src, i, j, kind)

Integer or real literal starting at i (a digit, or . followed by a digit).

Arguments

Type IntentOptional 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

TK_INT or TK_REAL


Calls

proc~~lex_number~~CallsGraph proc~lex_number lex_number proc~digits_end digits_end proc~lex_number->proc~digits_end proc~dotop_at dotop_at proc~lex_number->proc~dotop_at proc~is_digit is_digit proc~lex_number->proc~is_digit proc~is_name_char is_name_char proc~lex_number->proc~is_name_char proc~lower_char lower_char proc~lex_number->proc~lower_char proc~name_end name_end proc~lex_number->proc~name_end proc~peek peek proc~lex_number->proc~peek proc~digits_end->proc~is_digit proc~digits_end->proc~peek proc~dotop_at->proc~peek proc~is_letter is_letter proc~dotop_at->proc~is_letter proc~is_name_char->proc~is_digit proc~is_name_char->proc~is_letter proc~name_end->proc~is_name_char proc~name_end->proc~peek

Called by

proc~~lex_number~~CalledByGraph proc~lex_number lex_number proc~tokenize tokenize proc~tokenize->proc~lex_number proc~format_text format_text proc~format_text->proc~tokenize proc~convert_relational convert_relational proc~format_text->proc~convert_relational proc~format_pass format_pass proc~format_text->proc~format_pass proc~limit_diagnostics limit_diagnostics proc~format_text->proc~limit_diagnostics proc~long_code_lines long_code_lines proc~format_text->proc~long_code_lines proc~sort_use sort_use proc~format_text->proc~sort_use proc~split_long_lines split_long_lines proc~format_text->proc~split_long_lines proc~relayout relayout proc~format_text->proc~relayout proc~parse_source parse_source proc~parse_source->proc~tokenize proc~same_code same_code proc~same_code->proc~tokenize proc~code_signature code_signature proc~same_code->proc~code_signature proc~code_signature->proc~parse_source proc~convert_relational->proc~parse_source proc~format_pass->proc~parse_source proc~limit_diagnostics->proc~parse_source proc~long_code_lines->proc~parse_source proc~process_text process_text proc~process_text->proc~format_text proc~sort_use->proc~parse_source proc~split_long_lines->proc~parse_source proc~process_file process_file proc~process_file->proc~process_text proc~process_stdin process_stdin proc~process_stdin->proc~process_text proc~relayout->proc~format_pass proc~run run proc~run->proc~process_file proc~run->proc~process_stdin

Source Code

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