import type { ParseContext } from '../types.ts'; /** Lazy per-node capture state — arrays materialized on first push. */ export type CstCaptureBuf = { /** Table-host specialisation: collect source-order raw entries without the * duplicate semantic children view. Selected once for the enclosing node. */ rawOnly?: true | undefined; /** Direct reducer proved `rawChildren` unobservable. Preserve only the source-order * COUNT needed by trivia insertion/rollback; never retain raw entry values. */ noRaw?: true | undefined; rawLen?: number | undefined; single?: unknown | undefined; ch?: unknown[] | undefined; rawSingle?: unknown | undefined; raw?: unknown[] | undefined; tl?: number[] | undefined; }; export declare function cstCaptureActive(ctx: ParseContext): boolean; export type CstNodeCaptureSaved = { ch: ParseContext['_cstChildren']; lv: ParseContext['_cstLeaves']; raw: ParseContext['_cstRawChildren']; tl: ParseContext['_cstTriviaLog']; cap: boolean | undefined; buf: CstCaptureBuf | undefined; }; export declare function beginCstNodeCapture(ctx: ParseContext): CstNodeCaptureSaved; export declare function finishCstBuf(buf: CstCaptureBuf | undefined): { children: unknown[]; rawChildren: unknown[]; triviaLog: number[]; }; export declare function endCstNodeCapture(ctx: ParseContext, saved: CstNodeCaptureSaved): { children: unknown[]; rawChildren: unknown[]; triviaLog: number[]; }; export declare function pushCstLeaf(ctx: ParseContext, leaf: unknown): void; /** Record a built sub-node into the active collector (children vs rawChildren may differ). */ export declare function pushCstChild(ctx: ParseContext, built: unknown, rawEntry: unknown): void; export declare function cstRawLen(ctx: ParseContext): number; export declare function cstLeavesLen(ctx: ParseContext): number; export declare function cstTlLen(ctx: ParseContext): number; export type CstRollbackMark = { raw: number; tlog: number; leaves: number; fields: number; errors: number; }; export declare function saveCstMark(ctx: ParseContext): CstRollbackMark; /** * Demote everything captured since `childrenLen` from the STRUCTURAL `children` * array to `rawChildren` only — it stays in the tree, it stops being a child. * * This is the one mechanism behind the rule that a list-producing combinator * contributes the items of the list and NOTHING ELSE. `sepBy`'s separator is * matched by a real combinator, so it pushes through the same nine push sites * every terminal does; there is no separate channel to route it into at match * time. Demoting after the fact is the cheapest correct answer: it reuses the * mark the loop already took for rollback, truncates one array, and leaves * `rawChildren` — the source-order record — untouched, so the separator is * still recoverable WITHOUT re-reading source bytes. * * `raw` is deliberately NOT truncated. That asymmetry is the whole point, and it * is the same asymmetry trivia already has: consumed, absent from `children`, * still reachable. */ export declare function demoteCapturedToRaw(ctx: ParseContext, childrenLen: number): void; export declare function rollbackCstCapture(ctx: ParseContext, mark: CstRollbackMark): void; /** * The same rollback, taking the five marks as SCALARS. * * `saveCstMark` allocates a five-field object, and the table driver took one per * choice attempt and per repetition item — on `benchmark.less` that is 5.0% * (`saveCstMark`) plus 2.1% (`saveTriviaMark`, which allocates this one AND a * seven-field wrapper) of the whole parse. The compiled engine holds the same * five numbers in scalar locals and allocates nothing, which is the only * difference; a caller that keeps them in locals can now do the same. * * `rollbackCstCapture` stays as the object-taking entry point because the * interpreter's call sites genuinely carry a mark around. */ export declare function rollbackCstCaptureAt(ctx: ParseContext, raw: number, tlog: number, leaves: number, fields: number | undefined, errors: number | undefined): void; export declare function pushCstTriviaEntry(ctx: ParseContext, start: number, end: number, kindIndex?: number): void; export declare function pushTriviaLogEntry(ctx: ParseContext, start: number, end: number, kindIndex?: number): void; export declare function cstDeferredTriviaActive(ctx: ParseContext): boolean; //# sourceMappingURL=capture-buffer.d.ts.map