Skip to main content

Crate hypervox_expr

Crate hypervox_expr 

Source
Expand description

Math expression parser, compiler, and CSE engine.

Parses string expressions (e.g. "sin(x)*cos(y)") into an AST (Node), applies constant folding (Node::pre_eval), common-subexpression elimination (Node::cse), and compiles to closures (Node::compile / Node::compile_multi) for fast repeated evaluation over N-dimensional grids. Variable names are resolved through the VarMap trait.

Macros§

define_ext_f0
Define a custom-constants enum implementing ExtF0 and FromStr.
define_ext_f1
Define custom single-argument functions implementing ExtF1 and FromStr.
define_ext_f2
Define custom two-argument functions implementing ExtF2 and FromStr.

Structs§

ArithIndexSet
A type around IndexSet providing BigUint-like arithmetic.
ArithRangeFrom
An infinite iterator over ArithIndexSet values starting from a given value.
ArithRangeIter
A range of ArithIndexSet values that can be iterated over.
CompiledExprMulti
Multi-level compiled expression with invariant groups and main expression.
IndexSetIter
An iterator over the slot indices contained in an IndexSet.
InvariantGroup
A group of dimension-invariant sub-expressions at a given nesting level.

Enums§

ArithIndexSetTryFromError
Error type for TryFrom conversions involving ArithIndexSet.
Error
Structured error type for expression parsing.
F0
Constants (PI, E).
F1
Single-argument math functions.
F2
Two-argument math functions (atan2, pow).
IndexSet
A compact bitset for tracking slot indices in CSE.
LexerErrorKind
Lexical analysis error details.
LexerToken
Token produced by the lexer and consumed by the Pratt parser.
NoExtF
Zero-variant placeholder type for when no external functions/constants are used.
Node
AST node representing a mathematical expression.
ParseErrorKind
Parsing error details.

Traits§

CondMulAdd
Fused multiply-add that respects the fma feature flag.
ExtF0
Trait for custom constants.
ExtF1
Trait for custom single-argument functions.
ExtF2
Trait for custom two-argument functions.
VarMap
Trait for resolving variable names in expressions. Implementors define variable aliases and the indexed-variable naming scheme.

Functions§

f0_list
Return a comma-separated list of available constant names.
f1_list
Return a comma-separated list of available single-argument function names.
f2_list
Return a comma-separated list of available two-argument function names.
parse
Parse an expression string into a Node AST.
parse_with_ext
Parse an expression string into a Node AST, with support for custom extension functions.
validate
Validate an expression string without producing a compiled result.
validate_with_ext
Validate an expression string without producing a compiled result, with support for custom extension functions.

Type Aliases§

CompiledExpr
A compiled expression closure: (vars, cse_cache) -> result.