Skip to content

Evaluator & Integration ​

ExpressionEvaluator owns variables, functions, and evaluation of either source text or a pre-built AST / ParsedExpression.

Minimal host wiring ​

csharp
using JASE.Expressions;

var eval = new ExpressionEvaluator();
eval.SetVariable("threshold", 10);
eval.SetVariable("quantity", 14);

bool ok = eval.Evaluate<bool>("quantity > threshold");

For hot paths, parse once and reuse:

csharp
ParsedExpression parsed = /* parse via Tokenizer + Parser, or evaluator helpers */;
object result = eval.Evaluate(parsed);
// or
CompiledExpression compiled = parsed.Compile(eval);
object again = compiled.Evaluate(eval);

Variables and functions ​

APIPurpose
SetVariable(name, value, type?)Bind a symbol for evaluation
SetFunction(name, …)Register callable functions
TryGetVariable / TryGetFunctionInspect the symbol table

Functions must be registered before tokenization when the tokenizer needs to recognize them as calls (see Syntax).

Integration tips ​

  • One evaluator per evaluation scope (request, rule batch, or tenant) if variables mutate — avoid cross-talk
  • Log the source expression and variable snapshot when diagnosing production failures
  • Do not treat the evaluator as a sandbox for untrusted code execution of arbitrary host APIs — only expose the functions you register
  • Database and other Suite packages may depend on Expressions internally; referencing JASE.Expressions directly is for your rules surface