fypp_kind Function

private pure function fypp_kind(text) result(kind)

Kind of a preprocessor line (lowercase text) as a fypp block directive: one of the FY_* constants.

Arguments

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

text of the preprocessor token, in lowercase

Return Value integer


Called by

proc~~fypp_kind~~CalledByGraph proc~fypp_kind fypp_kind proc~fypp_depths fypp_depths proc~fypp_depths->proc~fypp_kind 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

pure integer function fypp_kind(text) result(kind)
    !! Kind of a preprocessor line (lowercase text) as a fypp block directive: one of the FY_*
    !! constants.
    character(len=*), intent(in) :: text   !! text of the preprocessor token, in lowercase
    integer :: i, j

    kind = FY_OTHER
    if (len(text) < 3) return
    if (text(1:2) /= '#:') return
    i = 3
    do while (i <= len(text))
        if (text(i:i) /= ' ' .and. text(i:i) /= achar(9)) exit
        i = i + 1
    end do
    j = i
    do while (j <= len(text))
        if (text(j:j) < 'a' .or. text(j:j) > 'z') exit
        j = j + 1
    end do
    select case (text(i:j - 1))
    case ('if', 'for', 'def', 'block', 'call', 'mute')
        kind = FY_OPEN
    case ('elif', 'else', 'nextarg')
        kind = FY_MIDDLE
    case ('endif', 'endfor', 'enddef', 'endblock', 'endcall', 'endmute')
        kind = FY_CLOSE
    end select
end function fypp_kind