Full-featured conditional compilation (if / ifdef / else / endif) for the fpx preprocessor This module implements standard-conforming conditional compilation with support for:
The state is maintained in a global stack (cond_stack) with cond_depth tracking nesting. The function is_active() is used throughout the preprocessor to decide whether a line should be emitted or skipped.
Data Types | |
| type | cond_state |
| State of a single conditional block. More... | |
| integer, public cond_depth = 0 |
Current nesting depth of conditional directives (0 = outside any if).
Definition at line 103 of file conditional.f90.
| type(cond_state), dimension(max_cond_depth), public cond_stack |
Global stack of conditional states (depth-limited).
Definition at line 99 of file conditional.f90.
| subroutine, public handle_elif | ( | type(context), intent(in) | ctx, |
| type(macro), dimension(:), intent(in) | macros, | ||
| character(*), intent(in) | token ) |
Process elif – alternative branch after if/elif Only activates if no previous branch in the group was taken.
| [in] | ctx | Context source line containing the directive |
| [in] | macros | Current macro table |
| [in] | token | Usually 'elif' |
Remarks
Definition at line 232 of file conditional.f90.
| subroutine, public handle_elifdef | ( | type(context), intent(in) | ctx, |
| type(macro), dimension(:), intent(in) | macros, | ||
| character(*), intent(in) | token ) |
Process elifdef – test if a macro is defined.
| [in] | ctx | Context source line containing the directive |
| [in] | macros | Current macro table |
| [in] | token | Usually 'elifdef' |
Remarks
Definition at line 269 of file conditional.f90.
| subroutine, public handle_elifndef | ( | type(context), intent(in) | ctx, |
| type(macro), dimension(:), intent(in) | macros, | ||
| character(*), intent(in) | token ) |
Process elifndef – test if a macro is not defined.
| [in] | ctx | Context source line containing the directive |
| [in] | macros | Current macro table |
| [in] | token | Usually 'elifndef' |
Remarks
Definition at line 306 of file conditional.f90.
| subroutine, public handle_else | ( | type(context), intent(in) | ctx | ) |
Process else – final fallback branch Activates only if no previous if/elif branch was true.
| [in] | ctx | Context (for error messages) |
Remarks
Definition at line 342 of file conditional.f90.
| subroutine, public handle_endif | ( | type(context), intent(in) | ctx | ) |
Process endif – end of conditional block Pops the top state from the stack. Reports error on unmatched endif.
| [in] | ctx | Context (for error messages) |
Remarks
Definition at line 371 of file conditional.f90.
| subroutine, public handle_if | ( | type(context), intent(in) | ctx, |
| type(macro), dimension(:), intent(in) | macros, | ||
| character(*), intent(in) | token ) |
Process a if directive with constant expression evaluation Evaluates the expression after if using evaluate_expression() and pushes a new state onto the conditional stack.
| [in] | ctx | Context source line containing the directive |
| [in] | macros | Current macro table |
| [in] | token | Usually 'if' |
Remarks
Definition at line 132 of file conditional.f90.
| subroutine, public handle_ifdef | ( | type(context), intent(in) | ctx, |
| type(macro), dimension(:), intent(in) | macros, | ||
| character(*), intent(in) | token ) |
Process ifdef – test if a macro is defined.
| [in] | ctx | Context source line containing the directive |
| [in] | macros | Current macro table |
| [in] | token | Usually 'ifdef' |
Remarks
Definition at line 165 of file conditional.f90.
| subroutine, public handle_ifndef | ( | type(context), intent(in) | ctx, |
| type(macro), dimension(:), intent(in) | macros, | ||
| character(*), intent(in) | token ) |
Process ifndef – test if a macro is NOT defined.
| [in] | ctx | Context source line containing the directive |
| [in] | macros | Current macro table |
| [in] | token | Usually 'ifndef' |
Remarks
Definition at line 198 of file conditional.f90.
| logical function, public is_active |
Determine if current line is inside an active conditional block.
Remarks
Definition at line 112 of file conditional.f90.