Class BooleanExpressionEvaluator
- Namespace
- FlowOrchestrator.Core.Expressions
- Assembly
- FlowOrchestrator.Core.dll
Hand-rolled recursive-descent parser and evaluator for the limited boolean expression
grammar supported by the When clause on RunAfterCondition.
public sealed class BooleanExpressionEvaluator
- Inheritance
-
BooleanExpressionEvaluator
- Inherited Members
Remarks
Grammar (informal):
expr = orExpr
orExpr = andExpr ("||" andExpr)*
andExpr = notExpr ("&&" notExpr)*
notExpr = "!" notExpr | comparison
comparison = primary (("==" | "!=" | ">" | "<" | ">=" | "<=") primary)?
primary = "(" expr ")" | literal | lhsExpression
literal = number | string | "true" | "false" | "null"
lhsExpression = "@steps(...)" | "@triggerBody(...)" | "@triggerHeaders(...)"
The implementation is split across four internal files for readability:
FlowOrchestrator.Core.Expressions.Internal.BooleanExpressionLexer (lex), FlowOrchestrator.Core.Expressions.Internal.BooleanExpressionParser (parse),
BooleanExpressionAst.cs (AST + FlowOrchestrator.Core.Expressions.Internal.EvalContext), and
FlowOrchestrator.Core.Expressions.Internal.BooleanExpressionComparer (type unification + binary comparison).
Type rules: number-vs-number compares as decimal; string-vs-string compares ordinally; bool-vs-bool compares directly; null is only equal/non-equal to null; any other type combination throws FlowExpressionException.
Short-circuit semantics: && does not evaluate the RHS when the LHS is
false; || does not evaluate the RHS when the LHS is true.
Methods
EvaluateAsync(string, LhsResolverAsync)
Parses and evaluates expression, returning a trace that captures
both the boolean result and a human-readable rewrite with each LHS replaced by its
resolved value.
public ValueTask<WhenEvaluationTrace> EvaluateAsync(string expression, BooleanExpressionEvaluator.LhsResolverAsync resolver)
Parameters
expressionstringThe expression text from the manifest.
resolverBooleanExpressionEvaluator.LhsResolverAsyncA resolver invoked once per unique LHS token encountered during evaluation.
Returns
Exceptions
- FlowExpressionException
Thrown on parse errors or type-coercion failures.