Expand description
Pest-backed parser with full source-side expression support.
Two public entry points:
parse_quantityturns a user input like"10 kg*m/s^2","5 m + 3 ft", or"sqrt(9 m^2)"into aQuantityby parsing it into an [Expr] AST and evaluating under a defaultEvalContext. This is a thin wrapper aroundparse_and_eval.parse_unit_nametakes a bare unit expression like"m/s"or"kg*m/s^2"and resolves it to a composedUnit. Target-side parsing stays pure โ no math, no identifiers beyond unit names.
Grammar lives in grammar.pest. Expression grammar
is documented there; the AST walker lives in crate::expr and the
tree walker / evaluator lives in crate::eval.
Structsยง
Enumsยง
Constantsยง
Functionsยง
- check_
affine_ ๐composition - Check that neither operand is affine before composing.
- parse_
and_ eval - Parse an expression and evaluate it under a caller-provided context.
- parse_
quantity - Parse a full quantity string and evaluate it under a default context.
- parse_
unit_ name - Parse a bare unit expression (e.g.
"m/s","kg*m/s^2"). - resolve_
unit_ ๐expr - Recursively resolve a pest
unit_exprparse tree into a composedUnit.