export type Node = | { k: 'num'; v: number } | { k: 'str'; v: string } | { k: 'bool'; v: boolean } | { k: 'null' } | { k: 'path'; v: string[] } | { k: 'unary'; op: '-' | 'NOT'; v: Node } | { k: 'binary'; op: BinaryOp; l: Node; r: Node } | { k: 'call'; name: string; args: Node[] }; export type BinaryOp = | '+' | '-' | '*' | '/' | '&' | '=' | '!=' | '>' | '<' | '>=' | '<=' | 'AND' | 'OR'; export class FormulaError extends Error { readonly position: number; constructor(message: string, position = -1) { super(position >= 0 ? `${message} (at character ${position + 1})` : message); this.name = 'FormulaError'; this.position = position; } }