view_closing Function

private pure function view_closing(v, j) result(c)

Index of the ) that closes the ( at code token j (counting only parentheses), or 0 if token j is not ( or it is not closed.

Type Bound

statement_view_t

Arguments

Type IntentOptional Attributes Name
class(statement_view_t), intent(in) :: v

the statement

integer, intent(in) :: j

index into v%code(:)

Return Value integer


Called by

proc~~view_closing~~CalledByGraph proc~view_closing statement_view_t%view_closing proc~classify_statement classify_statement proc~classify_statement->proc~view_closing proc~statement_case statement_case proc~statement_case->proc~view_closing proc~analyze_structure analyze_structure proc~analyze_structure->proc~classify_statement proc~compute_case compute_case proc~compute_case->proc~statement_case proc~format_pass format_pass proc~format_pass->proc~analyze_structure proc~format_pass->proc~compute_case 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

pure integer function view_closing(v, j) result(c)
    !! Index of the `)` that closes the `(` at code token `j` (counting only parentheses), or 0 if
    !! token `j` is not `(` or it is not closed.
    class(statement_view_t), intent(in) :: v   !! the statement
    integer, intent(in) :: j                   !! index into `v%code(:)`
    integer :: d
    if (.not. v%is(j, '(')) then
        c = 0
        return
    end if
    d = 0
    do c = j, v%n
        if (v%is(c, '(')) then
            d = d + 1
        else if (v%is(c, ')')) then
            d = d - 1
            if (d == 0) return
        end if
    end do
    c = 0
end function view_closing