fypp_depths Function

private function fypp_depths(source) result(fypp)

The number of fypp blocks around each item of source. The directives are counted wherever they are, also inside a continued statement; a directive line itself is at the level outside its block, like else and end statements.

Arguments

Type IntentOptional Attributes Name
type(source_t), intent(in) :: source

the source

Return Value integer, allocatable, (:)


Calls

proc~~fypp_depths~~CallsGraph proc~fypp_depths fypp_depths proc~fypp_kind fypp_kind proc~fypp_depths->proc~fypp_kind proc~token_lower token_lower proc~fypp_depths->proc~token_lower proc~make_lowercase make_lowercase proc~token_lower->proc~make_lowercase

Called by

proc~~fypp_depths~~CalledByGraph proc~fypp_depths fypp_depths proc~analyze_structure analyze_structure proc~analyze_structure->proc~fypp_depths proc~format_pass format_pass proc~format_pass->proc~analyze_structure proc~format_text format_text proc~format_text->proc~format_pass proc~relayout relayout proc~format_text->proc~relayout proc~relayout->proc~format_pass 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 fypp_depths(source) result(fypp)
    !! The number of fypp blocks around each item of `source`. The directives are counted wherever
    !! they are, also inside a continued statement; a directive line itself is at the level outside
    !! its block, like `else` and `end` statements.
    type(source_t), intent(in) :: source   !! the source
    integer, allocatable :: fypp(:)
    integer :: k, j, d

    allocate (fypp(source%stmts%n))
    d = 0
    do k = 1, source%stmts%n
        fypp(k) = d
        do j = source%stmts%s(k)%first, source%stmts%s(k)%last
            if (source%tokens%tok(j)%kind /= TK_PREPROC) cycle
            select case (fypp_kind(token_lower(source%text, source%tokens%tok(j))))
            case (FY_OPEN)
                d = d + 1
            case (FY_MIDDLE)
                if (source%stmts%s(k)%kind == SK_PREPROC) fypp(k) = max(0, d - 1)
            case (FY_CLOSE)
                d = max(0, d - 1)
                if (source%stmts%s(k)%kind == SK_PREPROC) fypp(k) = d
            end select
        end do
    end do
end function fypp_depths