whole_lines Function

private pure function whole_lines(tokens, stmt)

True if stmt takes up whole lines on its own, ending with a line break, so that it can be moved.

Arguments

Type IntentOptional Attributes Name
type(token_list_t), intent(in) :: tokens

tokens of the source

type(statement_t), intent(in) :: stmt

the statement, a range of tokens

Return Value logical


Called by

proc~~whole_lines~~CalledByGraph proc~whole_lines whole_lines proc~sort_use sort_use proc~sort_use->proc~whole_lines proc~format_text format_text proc~format_text->proc~sort_use 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 logical function whole_lines(tokens, stmt)
    !! True if `stmt` takes up whole lines on its own, ending with a line break, so that it can
    !! be moved.
    type(token_list_t), intent(in) :: tokens   !! tokens of the source
    type(statement_t), intent(in) :: stmt      !! the statement, a range of `tokens`
    whole_lines = .false.
    if (tokens%tok(stmt%last)%kind /= TK_NEWLINE) return
    if (stmt%first > 1) then
        if (tokens%tok(stmt%first - 1)%kind /= TK_NEWLINE) return
    end if
    whole_lines = .not. any(tokens%tok(stmt%first:stmt%last)%kind == TK_PREPROC .or. &
                            tokens%tok(stmt%first:stmt%last)%kind == TK_BOM)
end function whole_lines