parseman 0.61.0 → 0.61.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,50 @@
1
+ import { type RunOptions, type RunResult } from '../functional/run.ts';
2
+ import { type CompactProgram, type TableProgram } from '../table/program.ts';
3
+ import { type BacktrackCounts } from '../table/backtrack-probe.ts';
4
+ export type { BacktrackCounts } from '../table/backtrack-probe.ts';
5
+ export type BacktrackEngine = 'interpreter' | 'closure';
6
+ export type BacktrackMeasurement = {
7
+ readonly result: RunResult;
8
+ readonly counts: BacktrackCounts;
9
+ };
10
+ export type BacktrackProbe = {
11
+ /** The engine probed parses run on. */
12
+ readonly engine: {
13
+ readonly ran: BacktrackEngine | 'emitted';
14
+ };
15
+ /**
16
+ * Parse `input` from rule `entry`, plainly and probed, count the probed parse and
17
+ * return the plain parse's result. Throws if the two parses differ in outcome, value
18
+ * or where they stopped.
19
+ *
20
+ * Both parses get the same `options.state`, the plain one first. A grammar that
21
+ * writes state (a `gate()` that mutates it, say) sees the first parse's writes in the
22
+ * second, so the measure either throws or counts a different parse, possibly with
23
+ * fewer rewinds. Measure such a grammar only if resetting its state makes no difference.
24
+ */
25
+ measure(entry: string, input: string, options?: RunOptions): BacktrackMeasurement;
26
+ };
27
+ type Grammar = Readonly<Record<string, unknown>> | TableProgram | CompactProgram;
28
+ /**
29
+ * Probe a grammar on one engine.
30
+ *
31
+ * `grammar` is a rule map of combinators (a `rules()` or `compose()` result), or a
32
+ * table program for the closure engine. A rule map runs on the table through
33
+ * `compileRuleMapRunnable`, the lowering `compile()` uses.
34
+ *
35
+ * The emitted engine is not offered here: it needs code built from source, which
36
+ * at runtime only `compile()` may do (`docs/design/runtime-and-size-contract.md`,
37
+ * rule 1). Tests and benches reach it through `backtrackProbeAssembled` with a
38
+ * build-time module (`bench/emitted-assembly.ts`). It counts what the closure
39
+ * engine counts, because both run the same rewritten program.
40
+ */
41
+ export declare function backtrackProbe(grammar: Grammar, engine?: BacktrackEngine): BacktrackProbe;
42
+ /**
43
+ * For tests and benches, not `parseman/diagnostics`: the probe on the emitted
44
+ * engine. `assemble` hands the rewritten program back with a pre-compiled
45
+ * assembly for `probeCfg(program)`, built as a module the way a macro build ships
46
+ * one. Nothing here turns a string into code, and a program with no assembly is
47
+ * refused, because the assembler would.
48
+ */
49
+ export declare function backtrackProbeAssembled(grammar: Grammar, assemble: (probed: TableProgram) => Promise<TableProgram>): Promise<BacktrackProbe>;
50
+ //# sourceMappingURL=backtrack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backtrack.d.ts","sourceRoot":"","sources":["../../src/analysis/backtrack.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAO,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAG3E,OAAO,EAAiB,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAE3F,OAAO,EACqD,KAAK,eAAe,EAC/E,MAAM,6BAA6B,CAAA;AAGpC,YAAY,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAElE,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,SAAS,CAAA;AAEvD,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;IAC1B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;CACjC,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,uCAAuC;IACvC,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,eAAe,GAAG,SAAS,CAAA;KAAE,CAAA;IAC9D;;;;;;;;;OASG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,oBAAoB,CAAA;CAClF,CAAA;AA8BD,KAAK,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,YAAY,GAAG,cAAc,CAAA;AAUhF;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,GAAE,eAA2B,GAAG,cAAc,CAqBpG;AAED;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,YAAY,CAAC,GACxD,OAAO,CAAC,cAAc,CAAC,CAuBzB"}
@@ -23,5 +23,8 @@ export type { DiagnoseRenderOptions } from './diagnose-render.ts';
23
23
  export { measureChoiceCost, armFirstSets } from './corpus.ts';
24
24
  export type { CorpusSample, CorpusSite, ChoiceCorpusCost, ArmCorpusCost } from './corpus.ts';
25
25
  export { rebuildCombinator } from './rebuild.ts';
26
+ export type { RebuildOptions } from './rebuild.ts';
27
+ export { backtrackProbe } from './backtrack.ts';
28
+ export type { BacktrackProbe, BacktrackEngine, BacktrackMeasurement, BacktrackCounts } from './backtrack.ts';
26
29
  export type { RebuildResult, FrozenSubtree } from './rebuild.ts';
27
30
  //# sourceMappingURL=diagnostics.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/analysis/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACtD,YAAY,EACV,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EACxE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,iBAAiB,GACjD,MAAM,UAAU,CAAA;AAEjB,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACjE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEvD,OAAO,EAAE,eAAe,EAAE,cAAc,E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