Expand description
Arithmetic / logical expression language for grammar arguments.
Every numeric argument position in the grammar (extrusion heights, split
sizes, scale factors, roof parameters, …) accepts an expression instead of
a bare literal. Expressions are evaluated at derivation time against the
current shape’s EvalCtx — its scope extents, split position, depth,
bound rule parameters, and grammar attributes — so one rule adapts to
every scope it is applied to.
Extrude(rand(8, 14))
Split(Y) { FloorH: Ground | ~1: Upper } // FloorH = const/attr
Scale(scope.x * 0.5, 1, 1)
when(split.i == 0): CornerBay | else: MidBayDesign notes:
- Floats only. Booleans are CGA-style floats: comparisons yield
1.0/0.0, and any non-zero value is truthy. This keeps one value type through parameters, attributes, and genetics. - Deterministic randomness.
rand(..)draws from the per-shape RNG stream supplied by the interpreter, so the same seed derives the same model. Short-circuit&&/||skip RHS draws by design — divergence is data-driven and reproducible. - Hard failure over silent nonsense. Division by zero, non-finite
results, unknown identifiers, and bad function domains all return
ShapeErrorrather than propagating NaNs into scope math.
Structs§
- EvalCtx
- Per-shape evaluation context.
Enums§
- BinOp
- Binary operators, lowest section = lowest precedence.
- Expr
- An argument expression, evaluated per shape at derivation time.
- Func
- Built-in functions.
- UnaryOp
- Unary operators.
- Var
- Built-in read-only variables.
Constants§
- MAX_
EXPR_ DEPTH - Maximum parenthesis/recursion depth inside one expression. Bounds nom’s
recursion during parsing (a
((((…))))bomb would otherwise overflow the stack long before node counting runs). - MAX_
EXPR_ NODES - Maximum number of AST nodes in a single expression (DoS hardening).
Checked after parsing via
Expr::node_count; grammar-level integration rejects any argument expression exceeding this.
Functions§
- parse_
expr - nom-style entry point: parses one expression, leaving trailing input.
Enforces
MAX_EXPR_NODESbefore returning. - parse_
expr_ str - Whole-string entry point: the entire input must be one expression.