/** * Validation for `` — a column computed from its own row. * * Three things have to be true before a formula can run, and all three are * knowable from the config alone, so all three are refused by `check` rather * than by the run: * * 1. it says WHAT to compute — `expr=` is there and parses; * 2. every NAME in it is a sequence, not a typo; * 3. every one of those is declared ABOVE it, because a formula is built in * declaration order out of columns that already exist. * * Rule 3 borrows TDC240 from `running` and `stat` on purpose — same rule, same * fix, and a third code for it would lengthen the error reference without * telling a reader anything new. * * Rule 2 is the one that matters most in practice. An unknown name in an `if=` * is a bare WORD and the branch quietly stops firing; in a formula the same * typo reaches arithmetic, and `Heigth * 2` is NaN. Left to the run that prints * as a refusal on row one — after `check` has already called the config valid, * which is the failure this project keeps closing. */ import jsep from 'jsep'; import type { Diagnostic } from '../errors/index.js'; import type { OpenCloseElementContext, SelfClosingElementContext } from '../generated/TDCParser.js'; /** Everything a formula cannot do without, and the names it is allowed to read. */ export declare function checkGenFormula(gen: OpenCloseElementContext | SelfClosingElementContext, declaredAbove: readonly string[], diagnostics: Diagnostic[], /** The sequence this formula belongs to — the one name `prev()` may add. */ ownName?: string): void; /** * Every NAME the expression reads. * * A formula has no bare-word case to protect: `if="Gender == Male"` needs * `Male` to stay a word, but nothing is compared here — the whole expression is * arithmetic whose answer is printed. So every identifier is a column * reference, and one that is not a column is a typo rather than a word. * * The one exception is the branches of a ternary, which is how a formula writes * a LABEL — `expr="BMI > 25 ? over : normal"`. Those two are words on purpose, * so they are skipped, exactly as the right-hand side of a comparison is. */ export declare function identifiersOf(node: jsep.Expression): string[]; /** * Does this expression call `prev()` at all? * * A formula that does reads the row before its own, so it is built in row order * over the whole run — a whole column, like a running total. Text that does not * parse answers no: TDC294 already reports it, and one wrong config deserves one * diagnostic. */ export declare function callsPrev(expr: string): boolean; //# sourceMappingURL=formula.d.ts.map