rumil_expressions library
Formula evaluator built on Rumil.
Classes
- BinaryOp
-
Binary operator application, e.g.
a + borx == y. - BoolLit
-
Boolean literal:
trueorfalse. - Conditional
-
Ternary conditional, e.g.
x > 0 ? x : -x. - Environment
- Evaluation environment with variables and functions.
- Expr
- An expression node.
- FunctionCall
-
Function call, e.g.
sqrt(x)ormin(a, b). - NumberLit
-
Numeric literal, e.g.
42or3.14. - StringLit
-
String literal, e.g.
"hello". - UnaryOp
-
Unary operator application, e.g.
-xor!flag. - Variable
-
Variable reference, e.g.
xorprice.
Properties
-
builtinFunctions
→ Map<
String, Object Function(List< Object> )> -
Built-in functions available via Environment.standard.
final
Functions
-
applyBinaryOp(
String op, Object? l, Object? r) → Object - Evaluate a binary operator on two values.
-
applyUnaryOp(
String op, Object? value) → Object - Evaluate a unary operator.
-
asBool(
Object? v, String ctx) → bool -
Cast
vto bool or throw with context message. -
asNum(
Object? v, String ctx) → num -
Cast
vto num or throw with context message. -
compareValues(
Object? a, Object? b) → int - Compare two values of the same type.
-
eval(
Expr ast, [Environment env = const Environment()]) → Object - Evaluate a pre-parsed AST.
-
evaluate(
String expression, [Environment env = const Environment()]) → Object - Parse and evaluate an expression string.
-
parse(
String expression) → Result< ParseError, Expr> - Parse an expression string into an AST.
-
typeName(
Object? v) → String - Human-readable type name for error messages.
Exceptions / Errors
- EvalException
- Error thrown during expression evaluation.