67 implicit none;
private
93 logical,
public :: active
94 logical,
public :: has_met
133 type(
context),
intent(in) :: ctx
134 type(
macro),
intent(in) :: macros(:)
135 character(*),
intent(in) :: token
137 character(:),
allocatable :: expr
138 logical :: result, parent_active
143 message=
'Conditional nesting too deep', &
144 source=
trim(ctx%path)), &
145 ctx%content, ctx%line))
150 expr =
trim(adjustl(ctx%content(pos:)))
166 type(
context),
intent(in) :: ctx
167 type(
macro),
intent(in) :: macros(:)
168 character(*),
intent(in) :: token
170 character(:),
allocatable :: name
171 logical :: defined, parent_active
176 message=
'Conditional nesting too deep', &
177 source=
trim(ctx%path)), &
178 ctx%content, ctx%line))
183 name =
trim(adjustl(ctx%content(pos:)))
199 type(
context),
intent(in) :: ctx
200 type(
macro),
intent(in) :: macros(:)
201 character(*),
intent(in) :: token
203 character(:),
allocatable :: name
204 logical :: defined, parent_active
209 message=
'Conditional nesting too deep', &
210 source=
trim(ctx%path)), &
211 ctx%content, ctx%line))
216 name =
trim(adjustl(ctx%content(pos:)))
233 type(
context),
intent(in) :: ctx
234 type(
macro),
intent(in) :: macros(:)
235 character(*),
intent(in) :: token
237 character(:),
allocatable :: expr
238 logical :: result, parent_active
243 message=
'Synthax error', &
245 source=
trim(ctx%path)), &
246 ctx%content, ctx%line))
251 expr =
trim(adjustl(ctx%content(pos:)))
270 type(
context),
intent(in) :: ctx
271 type(
macro),
intent(in) :: macros(:)
272 character(*),
intent(in) :: token
274 character(:),
allocatable :: name
275 logical :: defined, parent_active
280 message=
'Synthax error', &
282 source=
trim(ctx%path)), &
283 ctx%content, ctx%line))
288 name =
trim(adjustl(ctx%content(pos:)))
307 type(
context),
intent(in) :: ctx
308 type(
macro),
intent(in) :: macros(:)
309 character(*),
intent(in) :: token
311 character(:),
allocatable :: name
312 logical :: defined, parent_active
317 message=
'Synthax error', &
319 source=
trim(ctx%path)), &
320 ctx%content, ctx%line))
325 name =
trim(adjustl(ctx%content(pos:)))
343 type(
context),
intent(in) :: ctx
345 logical :: parent_active
349 message=
'Synthax error', &
351 source=
trim(ctx%path)), &
352 ctx%content, ctx%line))
372 type(
context),
intent(in) :: ctx
376 message=
'Synthax error', &
378 source=
trim(ctx%path)), &
379 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 if current line is inside an active conditional block.
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 for conditional statements, set to 50 to prevent overly complex logic.
logical function, public is_defined(name, macros, idx)
Check if a macro with given name exists in table.
pure character(len_trim(str)) function, public lowercase(str)
Convert string to lower case (respects contents of quotes).
Interface to render diagnostic messages and labels.
Return the trimmed length of a string.
Return the length of a string.
Return the trimmed string.
State of a single conditional block.
Source location and content snapshot for precise diagnostics Instances of this type are created for e...
Definition of diagnostic message.
Represents text as a sequence of ASCII code units. The derived type wraps an allocatable character ar...
Derived type representing a single preprocessor macro Extends string with macro-specific fields: rep...