compute_case Function

public function compute_case(source, views, opts) result(marks)

The letter case wanted for each token.

Arguments

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

the source

type(statement_view_t), intent(in) :: views(:)

the view of each item (see statement_views)

type(case_options_t), intent(in) :: opts

the case wanted for each category

Return Value type(case_marks_t)


Calls

proc~~compute_case~~CallsGraph proc~compute_case compute_case proc~kind_part kind_part proc~compute_case->proc~kind_part proc~names_case names_case proc~compute_case->proc~names_case proc~statement_case statement_case proc~compute_case->proc~statement_case proc~view_kind_of statement_view_t%view_kind_of proc~names_case->proc~view_kind_of proc~view_word statement_view_t%view_word proc~names_case->proc~view_word proc~view_closing statement_view_t%view_closing proc~statement_case->proc~view_closing proc~statement_case->proc~view_kind_of proc~statement_case->proc~view_word

Called by

proc~~compute_case~~CalledByGraph proc~compute_case compute_case proc~format_pass format_pass 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

function compute_case(source, views, opts) result(marks)
    !! The letter case wanted for each token.
    type(source_t), intent(in) :: source            !! the source
    type(statement_view_t), intent(in) :: views(:)  !! the view of each item (see [[statement_views]])
    type(case_options_t), intent(in) :: opts        !! the case wanted for each category
    type(case_marks_t) :: marks
    integer :: k, t, a, b

    allocate (marks%whole(source%tokens%n), marks%part(source%tokens%n))
    marks%whole = CASE_KEEP
    marks%part = CASE_KEEP
    do t = 1, source%tokens%n
        associate (tok => source%tokens%tok(t))
            select case (tok%kind)
            case (TK_DOTOP)
                marks%whole(t) = opts%operators
            case (TK_INT, TK_REAL)
                marks%whole(t) = opts%types          ! their only letters: an exponent and a kind
            end select
            if (opts%types /= CASE_KEEP .and. (tok%kind == TK_DOTOP .or. tok%kind == TK_STRING)) then
                call kind_part(source%text(tok%first:tok%last), tok%kind, a, b)
                if (b >= a) marks%part(t) = opts%types
            end if
        end associate
    end do
    do k = 1, source%stmts%n
        if (source%stmts%s(k)%kind /= SK_CODE) cycle
        if (opts%keywords /= CASE_KEEP) call statement_case(views(k), opts%keywords, marks%whole)
        if (opts%procedures /= CASE_KEEP .or. opts%constants /= CASE_KEEP .or. opts%types /= CASE_KEEP) &
            call names_case(views(k), opts, marks%whole)
    end do
end function compute_case