import { FErr } from './value.js'; /** * One coordinate of a cell reference. `abs` records whether the axis was `$` * anchored — an unanchored axis shifts by the cell's offset from the rule's * origin when a conditional-format expression is evaluated per cell. */ export interface Axis { /** 0-indexed row or column. */ readonly index: number; /** Whether the axis carried a `$` anchor (stays put under the per-cell shift). */ readonly abs: boolean; } /** A single-cell reference: its column and row {@link Axis}es. */ export interface CellRef { readonly col: Axis; readonly row: Axis; } /** The formula syntax tree — a discriminated union over the node kind `k`. */ export type Ast = { readonly k: 'num'; readonly v: number; } | { readonly k: 'str'; readonly v: string; } | { readonly k: 'bool'; readonly v: boolean; } | { readonly k: 'err'; readonly v: FErr; } | { readonly k: 'cell'; readonly ref: CellRef; readonly sheet?: string; } | { readonly k: 'range'; readonly a: CellRef; readonly b: CellRef; readonly sheet?: string; } | { readonly k: 'name'; readonly name: string; } | { readonly k: 'array'; readonly rows: ReadonlyArray>; } | { readonly k: 'unary'; readonly op: '-' | '+'; readonly x: Ast; } | { readonly k: 'pct'; readonly x: Ast; } | { readonly k: 'bin'; readonly op: BinOp; readonly a: Ast; readonly b: Ast; } | { readonly k: 'call'; readonly name: string; readonly args: ReadonlyArray; }; /** The binary operators the parser recognises (see {@link Ast} `bin` nodes). */ export type BinOp = '+' | '-' | '*' | '/' | '^' | '&' | '=' | '<>' | '<' | '>' | '<=' | '>='; /** Thrown when the token stream is not a well-formed formula. */ export declare class ParseError extends Error { } /** * Parse a formula string into an {@link Ast}. Callers (the CF compiler) catch * the throw and treat a parse failure as "rule does not apply" — a formula using * a construct we do not model never misrenders, it just no-ops. * * @param src The formula source. * @returns The parsed syntax tree. * @throws ParseError on a malformed formula (or {@link LexError} from tokenizing). */ export declare function parse(src: string): Ast;