import { type CellAddress, type CellRefFlags, type RangeAddress } from './refs.js'; /** Binary operators, by category: arithmetic, concat, and comparison. */ export type BinaryOperator = '+' | '-' | '*' | '/' | '%' | '^' | '&' | '=' | '<>' | '<' | '>' | '<=' | '>='; /** Prefix operators. */ export type UnaryOperator = '-' | '+'; export interface NumberLiteralNode { type: 'number'; value: number; } export interface StringLiteralNode { type: 'string'; value: string; } export interface BooleanLiteralNode { type: 'boolean'; value: boolean; } export interface ReferenceNode extends CellRefFlags { type: 'ref'; address: CellAddress; } export interface RangeNode { type: 'range'; range: RangeAddress; /** `$`-absoluteness of the start (`A1`) corner. */ startFlags: CellRefFlags; /** `$`-absoluteness of the end (`C3`) corner. */ endFlags: CellRefFlags; } export interface UnaryNode { type: 'unary'; operator: UnaryOperator; operand: FormulaAst; } export interface BinaryNode { type: 'binary'; operator: BinaryOperator; left: FormulaAst; right: FormulaAst; } export interface CallNode { type: 'call'; name: string; args: FormulaAst[]; } /** A node in the formula AST. */ export type FormulaAst = NumberLiteralNode | StringLiteralNode | BooleanLiteralNode | ReferenceNode | RangeNode | UnaryNode | BinaryNode | CallNode; /** The cells and ranges a formula reads, for dependency tracking + highlighting. */ export interface RefList { cells: CellAddress[]; ranges: RangeAddress[]; } /** * Parse formula text into an AST. A leading `=` (the spreadsheet convention) is * tolerated and stripped. Throws {@link ParseError} (with a character position) * on malformed input. */ export declare function parseFormula(input: string): FormulaAst; /** * Collect every cell and range a formula reads, for the dependency graph (F3) * and reference highlighting (F4). Duplicates are preserved (the caller dedupes * as needed). */ export declare function formulaReferences(ast: FormulaAst): RefList; /** * Serialize an AST back to canonical formula source, including the leading `=`. * References emit their `$` absolute markers; the minimum parentheses needed to * round-trip the operator precedence are kept. Pure. */ export declare function stringifyFormula(ast: FormulaAst): string; /** * Return a copy of the AST with every **relative** reference shifted by * (`dRow`, `dCol`); axes marked absolute with `$` are left untouched. Fill and * intra-grid paste use this to relocate a formula. Because each reference still * resolves to a concrete absolute address (decision DT1), the evaluator and the * dependency graph need no knowledge of relative-ness. Pure. */ export declare function offsetReferences(ast: FormulaAst, dRow: number, dCol: number): FormulaAst;