find_semicolon Function

private pure function find_semicolon(src, tokens, i, lend) result(semi)

A ; in i:lend that is followed by more code on the line, or 0.

Arguments

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

source text

type(token_list_t), intent(in) :: tokens

tokens of src

integer, intent(in) :: i

tokens to search, up to the end of the line

integer, intent(in) :: lend

tokens to search, up to the end of the line

Return Value integer


Called by

proc~~find_semicolon~~CalledByGraph proc~find_semicolon find_semicolon proc~split_statements split_statements proc~split_statements->proc~find_semicolon proc~parse_source parse_source proc~parse_source->proc~split_statements proc~code_signature code_signature proc~code_signature->proc~parse_source proc~convert_relational convert_relational proc~convert_relational->proc~parse_source proc~format_pass format_pass proc~format_pass->proc~parse_source proc~limit_diagnostics limit_diagnostics proc~limit_diagnostics->proc~parse_source proc~long_code_lines long_code_lines proc~long_code_lines->proc~parse_source proc~sort_use sort_use proc~sort_use->proc~parse_source proc~split_long_lines split_long_lines proc~split_long_lines->proc~parse_source proc~format_text format_text proc~format_text->proc~convert_relational proc~format_text->proc~format_pass proc~format_text->proc~limit_diagnostics proc~format_text->proc~long_code_lines proc~format_text->proc~sort_use proc~format_text->proc~split_long_lines proc~relayout relayout proc~format_text->proc~relayout proc~relayout->proc~format_pass proc~same_code same_code proc~same_code->proc~code_signature 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 integer function find_semicolon(src, tokens, i, lend) result(semi)
    !! A `;` in `i:lend` that is followed by more code on the line, or 0.
    character(len=*), intent(in) :: src        !! source text
    type(token_list_t), intent(in) :: tokens   !! tokens of `src`
    integer, intent(in) :: i, lend             !! tokens to search, up to the end of the line
    integer :: k, m
    do k = i, lend
        if (tokens%tok(k)%kind /= TK_OP) cycle
        if (src(tokens%tok(k)%first:tokens%tok(k)%last) /= ';') cycle
        do m = k + 1, lend
            select case (tokens%tok(m)%kind)
            case (TK_SPACE, TK_NEWLINE, TK_COMMENT)
                cycle
            case default
                semi = k
                return
            end select
        end do
    end do
    semi = 0
end function find_semicolon