/** * xlsx FORMULAS — the typed AST. * * OWNERSHIP (DESIGN-P3.md): the formula/ directory belongs to the FORMULA * agent. It imports only from `../internal.js` (and sibling formula * files) — never from `../index.js`, `../styles.js`, `../structure.js` * or `../streaming.js`. * * Coordinate model (normative): the AST stores ABSOLUTE 1-based * coordinates (col/row numbers) plus per-axis `$` flags, regardless of * whether the source text was A1 or R1C1. R1C1 input is resolved against * the parse anchor; R1C1 output re-derives offsets against the serialize * anchor. A1↔R1C1 conversion is therefore parse(style A) → serialize * (style B) with the same anchor, and needs no AST transformation. * * The AST is plain data (interfaces, no classes) so it is trivially * serializable and structurally comparable in tests. */ /** * One corner of a reference: absolute 1-based coordinates + `$` flags. * `colAbsolute`/`rowAbsolute` mirror `$B$7`; in R1C1 output a * non-absolute axis serializes as a bracketed offset from the anchor. */ export interface CellCoord { readonly col: number; readonly row: number; readonly colAbsolute: boolean; readonly rowAbsolute: boolean; } /** * A sheet qualifier: `Sheet1!`, the 3-D span `Sheet1:Sheet3!`, or an * external-workbook-indexed `[2]Sheet1!`. Quoting (`'My Sheet'!`) is a * serialization concern, not stored. */ export interface SheetPrefix { readonly sheet: string; /** Set for 3-D references ('Sheet1:Sheet3'!A1). */ readonly endSheet?: string; /** External workbook index from `[N]` prefixes; undefined = same book. */ readonly workbookIndex?: number; } /** `42`, `3.14`, `1E-5`. */ export interface NumberLiteralNode { readonly kind: 'number'; readonly value: number; } /** `"text"` (stored decoded: `""` escapes resolved). */ export interface StringLiteralNode { readonly kind: 'string'; readonly value: string; } /** `TRUE` / `FALSE`. */ export interface BooleanLiteralNode { readonly kind: 'boolean'; readonly value: boolean; } /** Excel error literals. */ export type ErrorLiteralValue = '#NULL!' | '#DIV/0!' | '#VALUE!' | '#REF!' | '#NAME?' | '#NUM!' | '#N/A' | '#GETTING_DATA' | '#SPILL!' | '#CALC!'; /** `#DIV/0!`, `#REF!`, … */ export interface ErrorLiteralNode { readonly kind: 'error'; readonly value: ErrorLiteralValue; } /** An array constant `{1,2;"a",TRUE}` — rows of scalar literals. */ export interface ArrayLiteralNode { readonly kind: 'array'; readonly rows: ReadonlyArray>; } /** A single-cell reference `B7`, `$B$7`, `Sheet1!A1`, `Sheet1:Sheet3!A1`. */ export interface CellRefNode { readonly kind: 'cell'; readonly sheet?: SheetPrefix; readonly ref: CellCoord; } /** A rectangular range `A1:C3` (both corners cell coords). */ export interface RangeRefNode { readonly kind: 'range'; readonly sheet?: SheetPrefix; readonly start: CellCoord; readonly end: CellCoord; } /** A whole-column range `A:C`, `$A:$C`. */ export interface ColRangeRefNode { readonly kind: 'col-range'; readonly sheet?: SheetPrefix; readonly startCol: number; readonly endCol: number; readonly startAbsolute: boolean; readonly endAbsolute: boolean; } /** A whole-row range `1:3`, `$1:$3`. */ export interface RowRangeRefNode { readonly kind: 'row-range'; readonly sheet?: SheetPrefix; readonly startRow: number; readonly endRow: number; readonly startAbsolute: boolean; readonly endAbsolute: boolean; } /** A defined-name reference `TaxRate`, `Sheet1!LocalName`. */ export interface NameRefNode { readonly kind: 'name'; readonly sheet?: SheetPrefix; readonly name: string; } /** Structured-reference item selectors. */ export type StructuredItem = '#All' | '#Data' | '#Headers' | '#Totals' | '#This Row'; /** * A structured table reference: * `Table1[Revenue]`, `Table1[[#Headers],[Qty]]`, `[@Revenue]`, * `Table1[[Qty]:[Revenue]]`, `Table1[#All]`. */ export interface StructuredRefNode { readonly kind: 'structured'; /** Table name; undefined for in-table shorthand (`[@Col]`, `[Col]`). */ readonly table?: string; /** Item selectors, in source order. `'#This Row'` also covers `@`. */ readonly items: readonly StructuredItem[]; /** First (or only) column name; undefined for pure item refs (`[#All]`). */ readonly startColumn?: string; /** Set for column spans `[[A]:[B]]`. */ readonly endColumn?: string; } /** A function call. `name` is canonical WITHOUT the `_xlfn.` prefix. */ export interface CallNode { readonly kind: 'call'; readonly name: string; readonly args: readonly FormulaNode[]; } /** An omitted argument slot: the hole in `SUM(1,,2)` or `IF(A1,,B1)`. */ export interface EmptyArgNode { readonly kind: 'empty'; } /** Binary operators, tightest-binding last in this doc for reference: * range ':', intersection ' ', union ',' (reference operators), then * '^', '*','/', '+','-', '&', comparisons. */ export type BinaryOperator = ':' | ' ' | ',' | '^' | '*' | '/' | '+' | '-' | '&' | '=' | '<>' | '<' | '<=' | '>' | '>='; /** * A binary operation. Reference operators (':', ' ', ',') appear here * only when an operand is not a plain cell ref (e.g. `INDEX(...):B5`, * `(A1:A3 B2:C2)`); the common `A1:B2` parses directly to * {@link RangeRefNode}. The union operator ',' only exists inside * parentheses (elsewhere ',' separates arguments). */ export interface BinaryNode { readonly kind: 'binary'; readonly op: BinaryOperator; readonly left: FormulaNode; readonly right: FormulaNode; } /** Unary prefix `-A1`, `+3`. */ export interface UnaryNode { readonly kind: 'unary'; readonly op: '-' | '+'; readonly operand: FormulaNode; } /** Postfix percent `10%`. */ export interface PercentNode { readonly kind: 'percent'; readonly operand: FormulaNode; } /** * Explicit parentheses `(A1+1)*2`. Preserved as a node so serialization * reproduces the author's grouping exactly (canonical text never adds or * removes parens beyond what the source had — L1-style fidelity for * formula text). */ export interface GroupNode { readonly kind: 'group'; readonly inner: FormulaNode; } /** Any formula AST node. */ export type FormulaNode = NumberLiteralNode | StringLiteralNode | BooleanLiteralNode | ErrorLiteralNode | ArrayLiteralNode | CellRefNode | RangeRefNode | ColRangeRefNode | RowRangeRefNode | NameRefNode | StructuredRefNode | CallNode | EmptyArgNode | BinaryNode | UnaryNode | PercentNode | GroupNode; /** * Function names that Excel stores with an `_xlfn.` prefix in the XML * (functions added after the original OOXML function set was frozen). * The parser strips the prefix (AST names are always clean); the * serializer re-adds it for exactly this set. Case-insensitive lookup — * entries are uppercase. * * The set is data, not behavior: extending it for a newly shipped Excel * function is a one-line change here. */ export declare const XLFN_FUNCTIONS: ReadonlySet; /** * Functions whose storage form carries the additional `_xlws.` segment: * Excel writes `_xlfn._xlws.SORT(...)`, not `_xlfn.SORT(...)`. Always a * subset of {@link XLFN_FUNCTIONS}. Internal to formula/ (deliberately * not re-exported by the public barrel) — the parser strips the segment, * the serializer re-adds it in storage (`xlfn: true`) mode. */ export declare const XLWS_FUNCTIONS: ReadonlySet; //# sourceMappingURL=ast.d.ts.map