Evaluation-time host abstraction for the formula evaluator.

The host is the only thing evaluate talks to. Every cell read goes through FormulaHost.readNumber; the evaluator itself contains no graph, no resolver, no coercion table. This is the public surface that the eventual Rust evaluator port must satisfy — both implementations consume the same Ast and produce the same FormulaResult, differing only in how the host resolves cell IDs to numeric values.

Error semantics. A host may return a FormulaError for any failure: missing cell, non-numeric upstream value, propagated upstream error, or backing-store-specific I/O failure. The evaluator treats unresolved-ref specially inside range aggregations (skipped silently to match spreadsheet idiom) and surfaces every other error category by short-circuiting evaluation and returning an error FormulaResult. Outside range contexts every error short-circuits.

A1 keys. The cellId argument is the A1 reference string ("A1", "BC42") produced from the AST's CellRef via cellRefToA1. The host is responsible for any further translation into its backing-store identifier.

interface FormulaHost {
    readNumber(cellId: string): number | FormulaError;
}

Methods

Methods

  • Resolve and coerce the numeric value of a cell.

    Parameters

    • cellId: string

      A1 reference string identifying the cell.

    Returns number | FormulaError

    A finite number on success; otherwise a tagged FormulaError describing the failure.