protected_items Function

public function protected_items(src, tokens, stmts) result(keep)

True for each item that must be written exactly as it is: statements with a !& comment, and everything from a !&< line to the next !&> line, both included.

Arguments

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

source text

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

tokens of src

type(statement_list_t), intent(in) :: stmts

items of tokens

Return Value logical, allocatable, (:)


Calls

proc~~protected_items~~CallsGraph proc~protected_items protected_items proc~directive directive proc~protected_items->proc~directive proc~token_text token_text proc~directive->proc~token_text

Called by

proc~~protected_items~~CalledByGraph proc~protected_items protected_items proc~parse_source parse_source proc~parse_source->proc~protected_items 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

function protected_items(src, tokens, stmts) result(keep)
    !! True for each item that must be written exactly as it is: statements with a `!&` comment, and
    !! everything from a `!&<` line to the next `!&>` line, both included.
    character(len=*), intent(in) :: src              !! source text
    type(token_list_t), intent(in) :: tokens         !! tokens of `src`
    type(statement_list_t), intent(in) :: stmts      !! items of `tokens`
    logical, allocatable :: keep(:)
    logical :: off
    integer :: k, j, d

    allocate (keep(stmts%n))
    off = .false.
    do k = 1, stmts%n
        keep(k) = off
        do j = stmts%s(k)%first, stmts%s(k)%last
            if (tokens%tok(j)%kind /= TK_COMMENT) cycle
            d = directive(src, tokens%tok(j))
            if (stmts%s(k)%kind == SK_COMMENT .and. d == DIR_OFF) then
                off = .true.
                keep(k) = .true.
            else if (stmts%s(k)%kind == SK_COMMENT .and. d == DIR_ON) then
                off = .false.
                keep(k) = .true.
            else if (stmts%s(k)%kind == SK_CODE .and. d == DIR_KEEP) then
                keep(k) = .true.
            end if
        end do
    end do
end function protected_items