import type { FoldedProgram, TableProgram } from './program.ts'; import { type RunCfg } from './assemble.ts'; /** * THE OPTION SETS A BUILD PRE-COMPILES, by default. * * `hostCst` and `trackLines` are ENCODE settings (`TableSettings`), so a program * already fixes them — a table encoded for `hostMode: 'ast'` has no CST rows to * select. `tolerant` is a per-CALL option (`run({ tolerant })`), so both answers * are live for one artifact and both are emitted. * * `coverage` is never emitted: `emitAssemblySource` refuses a coverage assembly * outright, so there is nothing to pre-compile and the closure engine is the * correct answer. `probe` (`completionsAt`) is not emitted by default either — * it is a language-service path, cold, and doubling every artifact for it is a * cost with no reader. Both fall to the closure engine, which is OBSERVABLE on * `Assembly.emitRefusal` rather than silent. * * Overgeneration is deliberate: an emitted variant nobody selects costs bytes * and zero runtime. */ export declare function defaultAssemblyCfgs(prog: TableProgram): RunCfg[]; export type EmitOptions = { /** Name of the exported binding. */ readonly name?: string; /** * Optional experimental emitted factories — see `defaultAssemblyCfgs`. * * The normal compiler and macro both emit `a:[]`: that is the canonical * compact closure artifact and it never reaches the `Function` constructor. * Supplying factories here is a low-level serialization experiment, not a * second normal compilation path; it is not used by the macro plugin. */ readonly assemblies?: readonly RunCfg[]; /** * Sources for the author callbacks, in `prog.fns` order. A build has these * from the module it is lowering; pass `undefined` to emit a placeholder and * measure only the machinery. */ readonly fnSources?: readonly string[]; /** Import specifier for the shared driver. */ readonly runtime?: string; /** * NAME of the driver export to import from `runtime`, defaulting to the * shipped one. * * `runtime` alone was not enough to say which engine a module binds, and that * gap was load-bearing: `parseman/table` exports the ASSEMBLER as `tableRules` * while `src/table/exec.ts` exports the reference INTERPRETER under a name * that used to be identical. Pointing `runtime` at `exec.ts` therefore emitted * a module that read as the shipped artifact and ran the reference engine. * The reference export is now `execRules`, and a differential that wants it * has to SAY so here — which is the whole point of separating the names. */ readonly runtimeRef?: string; }; export declare function emitTableModule(prog: TableProgram, opts?: EmitOptions): string; export type ExpressionEmitOptions = EmitOptions & { /** * Which rule the expression evaluates to, or `null` for THE WHOLE RULE MAP. * * `null` is what a `rules()` call site needs: its initialiser evaluates to the * `{ name: fn, … }` object, exactly what `tableRules(…)` already returns, so * the map form is the expression WITHOUT the trailing index — not a second * emitter. `compileRuleMap`'s replacement has the same shape and the same * splice point, which is what makes the two lowerings interchangeable there. */ readonly entry?: string | null; /** Static metadata object passed to `tableRules` as its second argument. */ readonly metadataSource?: string; }; /** * The table as an EXPRESSION rather than a module — for an inliner that replaces * a grammar's initialiser in place. * * It references `tableRules` by name instead of carrying the driver, so it is * not self-contained. That is deliberate and it is not a cost: the reference * resolves to `parseman/table`, a package the consumer already depends on for * `run()`. The alternative — inlining the driver per grammar — is precisely the * 2.10 MB that this lowering exists to replace with 0.56 MB. * * The caller owns the import. `emitTableModule` writes its own; an inliner * splicing this into existing source must ensure the binding is in scope. */ export declare function emitTableExpression(prog: TableProgram, opts?: ExpressionEmitOptions): string; export type FoldedEmitOptions = EmitOptions & { /** * Exported binding per variant name. A variant with no entry is still carried * in the table and simply not given a name of its own. */ readonly names?: Readonly>; }; /** * Print a FOLDED program: one base table, plus the row edits per variant. * * This is G4's deliverable. The four `trackLines` x `hostMode` artifacts a * dialect ships stop being four near-copies of one table and become one table * and three short lists of `(offset, word)` pairs — which is what the measured * difference between them actually is. The reducer pool, the const pool, the * char classes, the expected sets, the dispatch tables and the rule index are * printed ONCE, because they are byte-identical in every variant. * * The base's own `l`/`h` scalars are NOT printed: every variant, base included, * carries its own on its delta, so no variant inherits the base's line-tracking * or host mode by accident. */ export declare function emitFoldedModule(folded: FoldedProgram, opts?: FoldedEmitOptions): string; /** * The part of the emitted module that is MACHINERY — the table, excluding the * author's reducers, which every lowering must emit alike. This is the number * that is comparable to codegen's per-rule cost. */ export declare function emitTableOnly(prog: TableProgram): string; //# sourceMappingURL=emit.d.ts.map