Sheety::CodeGenerator
Inherits Sheety::AST < Reference < Object
Generates Crystal code from Excel formula AST
The generated code is designed to be used in procs that:
- Read cell values from Croupier's k/v store
- Calculate the formula result
- Return the result as a string for storage
Instance methods
Render the concrete fetch expression for a reference parameter, suitable for a task's call site. Mirrors the concrete CellRef/RangeRef rendering.
Generate Crystal code for an AST node
Generate a parameterized expression where each reference leaf (CellRef, RangeRef, NamedRef) is replaced by a positional parameter (p0, p1, ...). Two formulas with the same structure but different cells produce identical parameterized expressions. Used to build shared helper bodies.
The Crystal parameter declaration (name + type) for a reference parameter, used in the shared helper's signature.
The ordered list of reference leaves in the AST (CellRef / RangeRef /
NamedRef), in the same left-to-right depth-first order the parameterized
generator assigns parameter indices. Each entry carries enough info to
build the concrete fetch call for a given cell's call site. The optional
sheet is used to resolve bare references (those without an explicit
sheet prefix), mirroring how the concrete generator and dependency
extractor resolve them.
A stable structural key for a formula. Two formulas whose ASTs differ only in concrete cell/range/named references share the same key; differences in operators, function names, arity, or literal values produce different keys. Used to group formulas for shared-helper extraction. Returns a hex SHA1 of the canonical structural string.