Loading...
Searching...
No Matches
evaluate_expression

Definition

Evaluates a preprocessor-style expression with macro substitution. Tokenizes the input expression, expands macros where appropriate, parses it according to operator precedence, and computes the integer result. Returns .true. if evaluation succeeded and the result is non-zero.

Examples

integer :: value
call add(macros, 'SIZE', '64')
if (evaluate_expression('SIZE >= 32', macros, value)) then
print *, value ! 1
end if

Constructors

Constructor

logical function evaluate(expr, macros, val)
Parameters
[in]expr
Expression string to evaluate
[in,out]macrosArray of defined macros for substitution and defined() checks
[out]val(optional) integer result of the evaluation
Returns
.true. if the expression evaluated successfully to non-zero, .false. otherwise

Constructor

logical function evaluate(expr, macros, ctx, val)
Parameters
[in]expr
Expression string to evaluate
[in,out]macrosArray of defined macros for substitution and defined() checks
[in]ctxCurrent context
[out]val
(optional) integer result of the evaluation
Returns
.true. if the expression evaluated successfully to non-zero, .false. otherwise

Definition at line 171 of file operators.f90.


The documentation for this interface was generated from the following file:

Methods

◆ evaluate_expression_default()

logical function evaluate_expression_default ( character(*), intent(in) expr,
type(macro), dimension(:), intent(inout), allocatable macros,
integer, intent(out), optional val )

Evaluates a preprocessor-style expression with macro substitution. Tokenizes the input expression, expands macros where appropriate, parses it according to operator precedence, and computes the integer result. Returns .true. if evaluation succeeded and the result is non-zero.

Parameters
[in]exprExpression string to evaluate
[in,out]macrosArray of defined macros for substitution and defined() checks
[out]val(optional) integer result of the evaluation
Returns
.true. if the expression evaluated successfully to non-zero, .false. otherwise

Definition at line 189 of file operators.f90.

◆ evaluate_expression_with_context()

logical function evaluate_expression_with_context ( character(*), intent(in) expr,
type(macro), dimension(:), intent(inout), allocatable macros,
type(context), intent(in) ctx,
integer, intent(out), optional val )

Evaluates a preprocessor-style expression with macro substitution. Tokenizes the input expression, expands macros where appropriate, parses it according to operator precedence, and computes the integer result. Returns .true. if evaluation succeeded and the result is non-zero.

Parameters
[in]exprExpression string to evaluate
[in,out]macrosArray of defined macros for substitution and defined() checks
[in]ctxContext
[out]val(optional) integer result of the evaluation
Returns
.true. if the expression evaluated successfully to non-zero, .false. otherwise

Definition at line 212 of file operators.f90.