Kind of a preprocessor line (lowercase text): PP_IF, PP_ELSE (#elif, #else), PP_ENDIF
or PP_OTHER.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | text |
text of the preprocessor token, in lowercase |
pure integer function conditional_kind(text) result(kind) !! Kind of a preprocessor line (lowercase text): `PP_IF`, `PP_ELSE` (`#elif`, `#else`), `PP_ENDIF` !! or `PP_OTHER`. character(len=*), intent(in) :: text !! text of the preprocessor token, in lowercase character(len=:), allocatable :: directive integer :: i, j kind = PP_OTHER i = 2 ! after '#' if (len(text) < 2 .or. text(1:1) /= '#') return if (text(2:2) == ':') i = 3 ! fypp 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 directive = text(i:j - 1) select case (directive) case ('if', 'ifdef', 'ifndef') kind = PP_IF case ('elif', 'else') kind = PP_ELSE case ('endif') kind = PP_ENDIF end select end function conditional_kind