126module fpx_conditional
134 implicit none;
private
166 logical,
public :: active
167 logical,
public :: has_met
214 type(
context),
intent(in) :: ctx
215 type(
macro),
allocatable,
intent(inout) :: macros(:)
216 character(*),
intent(in) :: token
218 character(:),
allocatable :: expr
219 logical :: result, parent_active
224 message=
'Conditional nesting too deep', &
225 source=
trim(ctx%path)), &
226 ctx%content, ctx%line))
231 expr =
trim(adjustl(ctx%content(pos:)))
246 type(
context),
intent(in) :: ctx
247 type(
macro),
intent(in) :: macros(:)
248 character(*),
intent(in) :: token
250 character(:),
allocatable :: name
251 logical :: defined, parent_active
256 message=
'Conditional nesting too deep', &
257 source=
trim(ctx%path)), &
258 ctx%content, ctx%line))
263 name =
trim(adjustl(ctx%content(pos:)))
278 type(
context),
intent(in) :: ctx
279 type(
macro),
intent(in) :: macros(:)
280 character(*),
intent(in) :: token
282 character(:),
allocatable :: name
283 logical :: defined, parent_active
288 message=
'Conditional nesting too deep', &
289 source=
trim(ctx%path)), &
290 ctx%content, ctx%line))
295 name =
trim(adjustl(ctx%content(pos:)))
311 type(
context),
intent(in) :: ctx
312 type(
macro),
allocatable,
intent(inout) :: macros(:)
313 character(*),
intent(in) :: token
315 character(:),
allocatable :: expr
316 logical :: result, parent_active
321 message=
'Syntax error', &
323 source=
trim(ctx%path)), &
324 ctx%content, ctx%line))
329 expr =
trim(adjustl(ctx%content(pos:)))
347 type(
context),
intent(in) :: ctx
348 type(
macro),
intent(in) :: macros(:)
349 character(*),
intent(in) :: token
351 character(:),
allocatable :: name
352 logical :: defined, parent_active
357 message=
'Syntax error', &
359 source=
trim(ctx%path)), &
360 ctx%content, ctx%line))
365 name =
trim(adjustl(ctx%content(pos:)))
383 type(
context),
intent(in) :: ctx
384 type(
macro),
intent(in) :: macros(:)
385 character(*),
intent(in) :: token
387 character(:),
allocatable :: name
388 logical :: defined, parent_active
393 message=
'Syntax error', &
395 source=
trim(ctx%path)), &
396 ctx%content, ctx%line))
401 name =
trim(adjustl(ctx%content(pos:)))
418 type(
context),
intent(in) :: ctx
420 logical :: parent_active
424 message=
'Syntax error', &
426 source=
trim(ctx%path)), &
427 ctx%content, ctx%line))
446 type(
context),
intent(in) :: ctx
450 message=
'Syntax error', &
452 source=
trim(ctx%path)), &
453 ctx%content, ctx%line))
subroutine, public handle_ifndef(ctx, macros, token)
Process ifndef - test if a macro is NOT defined.
logical function, public is_active()
Determine whether the current source position is active.
subroutine, public handle_ifdef(ctx, macros, token)
Process ifdef - test if a macro is defined.
integer, public cond_depth
Current nesting depth of conditional directives (0 = outside any if).
subroutine, public handle_elif(ctx, macros, token)
Process elif - alternative branch after if/elif Only activates if no previous branch in the group was...
subroutine, public handle_elifndef(ctx, macros, token)
Process elifndef - test if a macro is not defined.
subroutine, public handle_else(ctx)
Process else - final fallback branch Activates only if no previous if/elif branch was true.
type(cond_state), dimension(max_cond_depth), public cond_stack
Global stack of conditional states (depth-limited).
subroutine, public handle_if(ctx, macros, token)
Process a if directive with constant expression evaluation Evaluates the expression after if using ev...
subroutine, public handle_elifdef(ctx, macros, token)
Process elifdef - test if a macro is defined.
subroutine, public handle_endif(ctx)
Process endif - end of conditional block Pops the top state from the stack. Reports error on unmatche...
integer, parameter, public max_cond_depth
Maximum nesting depth of conditional compilation directives.
logical function, public is_defined(name, macros, idx)
Determine whether a macro is currently defined.
pure character(len_trim(str)) function, public lowercase(str)
Convert string to lower case (respects contents of quotes).
Generic renderer for diagnostics and source excerpts.
Evaluates a preprocessor-style expression with macro substitution. Tokenizes the input expression,...
Locate the position of a substring.
Return the trimmed length of a string object.
Return the length of a string object.
Remove trailing blanks from a string object.
State associated with a single conditional nesting level.
Snapshot of a source location within the preprocessing stream.
Structured compiler diagnostic.
Diagnostic label identifying a region of source text.
Representation of a preprocessor macro.