/** * The rule-map envelope both table drivers share. * * Everything here is about what a table ENTRY has to look like to `run()` and to * the linker's public wrappers — trivia metadata, host-mode stamps, the * `_lineStarts` seeding, the ambient `scanSkip` install and the failure-to- * `ParseResult` conversion. None of it is recognition, and having two copies of * it (one in `exec.ts`, one in `assemble.ts`) would be two places for a * divergence the three-way identity sweep would then have to catch. * * The drivers supply only what differs: how a rule RUNS. */ import type { Combinator, ParseContext } from '../types.ts'; import { type ResolvedTable, type TableProgram, type TableRule } from './program.ts'; /** * Did something inside CUT? * * Read through a call so TypeScript does not narrow `_fc` to `false` from the * assignment that precedes each speculative attempt — the driver mutates it and * the checker cannot see that. Lives here rather than in a driver because the * ENVELOPE reads it too, and a third copy would be a third place to drift. */ export declare function committed(c: ParseContext): boolean; /** * The ENTRY result's span, line-annotated when the table tracks lines. * * Codegen annotates the root result the moment `ctx.lineTracking` is on — both * the success span and the failure span (`_spanLines(_ctx, …)`), and so does the * interpreter's `parser({ trackLines: true })` scope. The table's envelope built * a bare `{ start, end }` regardless, so a tracked table parse handed back a * result with no `startLine`/`endColumn` at all while paying for the tracking. * * The binary search over `_lineStarts` now lives in `run-support.ts`. The * private copy that sat here was justified by "not worth giving the hot node * piece a cross-module call"; the EMITTED engine needs the same answer, the * node piece no longer calls this copy at all, and a THIRD copy is how a * reported column drifts between two engines that are gated against each other * precisely so that it cannot. */ import { spanLines } from './run-support.ts'; export { spanLines }; /** * What a driver must provide per parse, in the order the entry needs it. * * `run` returns the driver's own FAIL sentinel for a failed parse. The sentinel * is module-private on each side, so it is never compared here — `runRule` * answers with `undefined` for failure instead, and the caller's sentinel never * leaves its module. */ export type RuleRunner = { /** * Run rule `ri` and return its end position, or −1 on failure. * * Returning the position rather than the value keeps the driver's FAIL * sentinel private; the value is fetched separately only on success. */ readonly runRule: (ri: number, input: string, pos: number, ctx: ParseContext) => number; /** The value the last successful `runRule` produced. */ readonly lastValue: () => unknown; /** The ambient `scanSkip` set for rule `ri`, if the program declares one. */ readonly scanSkipFor: (ri: number, ctx: ParseContext) => readonly Combinator[] | undefined; }; /** * Wrap a driver's per-rule run into the map an artifact exports. * * The entries have the SAME signature as codegen rule functions, so `run()`, the * linker's public wrappers and every consumer are unchanged. */ export declare function stampRuleMap(prog: TableProgram, d: RuleRunner, artifactMetadata?: Readonly>, resolved?: ResolvedTable): Record; //# sourceMappingURL=stamp.d.ts.map