parseman 0.46.0 → 0.47.0
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.
- package/README.md +8 -3
- package/dist/analysis/choice-cost-render.d.ts +12 -4
- package/dist/analysis/choice-cost-render.d.ts.map +1 -1
- package/dist/analysis/choice-cost.d.ts +2 -2
- package/dist/analysis/choice-cost.d.ts.map +1 -1
- package/dist/analysis/commitment.d.ts +131 -0
- package/dist/analysis/commitment.d.ts.map +1 -0
- package/dist/analysis/diagnostics.cjs +9929 -7465
- package/dist/analysis/diagnostics.cjs.map +3 -4
- package/dist/analysis/diagnostics.d.ts +2 -2
- package/dist/analysis/diagnostics.js +9929 -7465
- package/dist/analysis/diagnostics.js.map +3 -4
- package/dist/analysis/duplication.d.ts.map +1 -1
- package/dist/analysis/fix.d.ts +3 -3
- package/dist/analysis/fix.d.ts.map +1 -1
- package/dist/analysis/format-number.d.ts +23 -0
- package/dist/analysis/format-number.d.ts.map +1 -0
- package/dist/analysis/gating.d.ts +39 -2
- package/dist/analysis/gating.d.ts.map +1 -1
- package/dist/analysis/rebuild.d.ts.map +1 -1
- package/dist/analysis/terminal.d.ts +5 -2
- package/dist/analysis/terminal.d.ts.map +1 -1
- package/dist/cli/index.cjs +10865 -8535
- package/dist/cli/index.cjs.map +3 -4
- package/dist/cli/index.js +10865 -8535
- package/dist/cli/index.js.map +3 -4
- package/dist/combinators/adjacency.d.ts +100 -0
- package/dist/combinators/adjacency.d.ts.map +1 -0
- package/dist/combinators/choice.d.ts.map +1 -1
- package/dist/combinators/completions.d.ts.map +1 -1
- package/dist/combinators/dispatch.d.ts +8 -1
- package/dist/combinators/dispatch.d.ts.map +1 -1
- package/dist/combinators/expect.d.ts.map +1 -1
- package/dist/combinators/first-set.d.ts.map +1 -1
- package/dist/combinators/gate.d.ts.map +1 -1
- package/dist/combinators/grammar.d.ts +22 -0
- package/dist/combinators/grammar.d.ts.map +1 -1
- package/dist/combinators/literal.d.ts +8 -0
- package/dist/combinators/literal.d.ts.map +1 -1
- package/dist/combinators/map.d.ts +0 -1
- package/dist/combinators/map.d.ts.map +1 -1
- package/dist/combinators/node.d.ts +13 -3
- package/dist/combinators/node.d.ts.map +1 -1
- package/dist/combinators/parser.d.ts +1 -1
- package/dist/combinators/parser.d.ts.map +1 -1
- package/dist/combinators/ref.d.ts.map +1 -1
- package/dist/combinators/regex.d.ts +1 -16
- package/dist/combinators/regex.d.ts.map +1 -1
- package/dist/combinators/repeat.d.ts +30 -2
- package/dist/combinators/repeat.d.ts.map +1 -1
- package/dist/combinators/scanTo.d.ts +71 -1
- package/dist/combinators/scanTo.d.ts.map +1 -1
- package/dist/combinators/sequence.d.ts.map +1 -1
- package/dist/combinators/token.d.ts.map +1 -1
- package/dist/combinators/trivia-boundary.d.ts +26 -0
- package/dist/combinators/trivia-boundary.d.ts.map +1 -0
- package/dist/combinators/trivia-skip.d.ts +40 -1
- package/dist/combinators/trivia-skip.d.ts.map +1 -1
- package/dist/combinators/withCtx.d.ts.map +1 -1
- package/dist/compiler/compile-linkable-table.d.ts +104 -0
- package/dist/compiler/compile-linkable-table.d.ts.map +1 -0
- package/dist/compiler/degradation.d.ts +0 -2
- package/dist/compiler/degradation.d.ts.map +1 -1
- package/dist/compiler/fields.d.ts +13 -0
- package/dist/compiler/fields.d.ts.map +1 -1
- package/dist/compiler/grammar-coverage-ids.d.ts +5 -5
- package/dist/compiler/grammar-coverage-ids.d.ts.map +1 -1
- package/dist/compiler/ir-serialize.d.ts.map +1 -1
- package/dist/compiler/linker.d.ts +47 -53
- package/dist/compiler/linker.d.ts.map +1 -1
- package/dist/compiler/token-alphabet.d.ts +81 -0
- package/dist/compiler/token-alphabet.d.ts.map +1 -0
- package/dist/compiler/token-dispatch.d.ts +95 -0
- package/dist/compiler/token-dispatch.d.ts.map +1 -0
- package/dist/compiler/token-scanner.d.ts +53 -0
- package/dist/compiler/token-scanner.d.ts.map +1 -0
- package/dist/compiler/value-usage.d.ts.map +1 -1
- package/dist/coverage.d.ts +1 -1
- package/dist/coverage.d.ts.map +1 -1
- package/dist/cst/capture-buffer.d.ts +35 -0
- package/dist/cst/capture-buffer.d.ts.map +1 -1
- package/dist/cst/reflection-attach.d.ts +8 -0
- package/dist/cst/reflection-attach.d.ts.map +1 -0
- package/dist/cst/reflection-symbols.d.ts +10 -0
- package/dist/cst/reflection-symbols.d.ts.map +1 -0
- package/dist/cst/reflection.d.ts +2 -4
- package/dist/cst/reflection.d.ts.map +1 -1
- package/dist/cst/root-trivia-scope.d.ts +26 -0
- package/dist/cst/root-trivia-scope.d.ts.map +1 -0
- package/dist/cst/trivia-charscan.d.ts +18 -0
- package/dist/cst/trivia-charscan.d.ts.map +1 -0
- package/dist/cst/trivia-kinds.d.ts +19 -0
- package/dist/cst/trivia-kinds.d.ts.map +1 -1
- package/dist/functional/doc.d.ts.map +1 -1
- package/dist/functional/run-tabled.d.ts +12 -0
- package/dist/functional/run-tabled.d.ts.map +1 -0
- package/dist/functional/run.d.ts +25 -42
- package/dist/functional/run.d.ts.map +1 -1
- package/dist/grammar-metadata.d.ts +3 -0
- package/dist/grammar-metadata.d.ts.map +1 -0
- package/dist/index.cjs +9224 -7203
- package/dist/index.cjs.map +3 -4
- package/dist/index.d.ts +18 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9219 -7198
- package/dist/index.js.map +3 -4
- package/dist/language-service/index.cjs +311 -121
- package/dist/language-service/index.cjs.map +3 -4
- package/dist/language-service/index.js +311 -121
- package/dist/language-service/index.js.map +3 -4
- package/dist/oracle/index.cjs.map +0 -1
- package/dist/oracle/index.js.map +0 -1
- package/dist/parse-context.d.ts +49 -0
- package/dist/parse-context.d.ts.map +1 -0
- package/dist/plugin/evaluator.d.ts +40 -1
- package/dist/plugin/evaluator.d.ts.map +1 -1
- package/dist/plugin/index.cjs +11146 -9593
- package/dist/plugin/index.cjs.map +3 -4
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +11146 -9593
- package/dist/plugin/index.js.map +3 -4
- package/dist/regex/classes.d.ts +28 -0
- package/dist/regex/classes.d.ts.map +1 -1
- package/dist/regex/first-set.d.ts +14 -0
- package/dist/regex/first-set.d.ts.map +1 -1
- package/dist/run/index.cjs +136 -51
- package/dist/run/index.cjs.map +2 -3
- package/dist/run/index.js +136 -51
- package/dist/run/index.js.map +2 -3
- package/dist/spec/index.cjs +2898 -1623
- package/dist/spec/index.cjs.map +3 -4
- package/dist/spec/index.js +2898 -1623
- package/dist/spec/index.js.map +3 -4
- package/dist/spec/model.d.ts +8 -0
- package/dist/spec/model.d.ts.map +1 -1
- package/dist/table/assemble.d.ts +307 -0
- package/dist/table/assemble.d.ts.map +1 -0
- package/dist/table/cell.d.ts +42 -0
- package/dist/table/cell.d.ts.map +1 -0
- package/dist/table/child-slots.d.ts +30 -0
- package/dist/table/child-slots.d.ts.map +1 -0
- package/dist/table/compile-rule-map.d.ts +136 -0
- package/dist/table/compile-rule-map.d.ts.map +1 -0
- package/dist/table/compile.d.ts +56 -0
- package/dist/table/compile.d.ts.map +1 -0
- package/dist/table/duplication-hook.d.ts +32 -0
- package/dist/table/duplication-hook.d.ts.map +1 -0
- package/dist/table/emit-assembly.d.ts +139 -0
- package/dist/table/emit-assembly.d.ts.map +1 -0
- package/dist/table/emit.d.ts +113 -0
- package/dist/table/emit.d.ts.map +1 -0
- package/dist/table/encode-baseline.d.ts +16 -0
- package/dist/table/encode-baseline.d.ts.map +1 -0
- package/dist/table/encode.d.ts +71 -0
- package/dist/table/encode.d.ts.map +1 -0
- package/dist/table/exec-baseline.d.ts +9 -0
- package/dist/table/exec-baseline.d.ts.map +1 -0
- package/dist/table/exec.d.ts +72 -0
- package/dist/table/exec.d.ts.map +1 -0
- package/dist/table/fold.d.ts +25 -0
- package/dist/table/fold.d.ts.map +1 -0
- package/dist/table/index.cjs +11375 -0
- package/dist/table/index.cjs.map +6 -0
- package/dist/table/index.d.ts +100 -0
- package/dist/table/index.d.ts.map +1 -0
- package/dist/table/index.js +11352 -0
- package/dist/table/index.js.map +6 -0
- package/dist/table/inspect.d.ts +17 -0
- package/dist/table/inspect.d.ts.map +1 -0
- package/dist/table/ops.d.ts +446 -0
- package/dist/table/ops.d.ts.map +1 -0
- package/dist/table/program.d.ts +493 -0
- package/dist/table/program.d.ts.map +1 -0
- package/dist/table/run-support.d.ts +38 -0
- package/dist/table/run-support.d.ts.map +1 -0
- package/dist/{compiler/scannable-run.d.ts → table/scan-shapes.d.ts} +14 -13
- package/dist/table/scan-shapes.d.ts.map +1 -0
- package/dist/table/site-labels.d.ts +58 -0
- package/dist/table/site-labels.d.ts.map +1 -0
- package/dist/table/stamp.d.ts +70 -0
- package/dist/table/stamp.d.ts.map +1 -0
- package/dist/types.d.ts +80 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +25 -2
- package/src/analysis/choice-cost-gate.ts +359 -0
- package/src/analysis/choice-cost-render.ts +293 -0
- package/src/analysis/choice-cost.ts +1008 -0
- package/src/analysis/commitment.ts +557 -0
- package/src/analysis/corpus.ts +130 -0
- package/src/analysis/diagnose-render.ts +625 -0
- package/src/analysis/diagnose.ts +317 -0
- package/src/analysis/diagnostics.ts +33 -0
- package/src/analysis/duplication.ts +1955 -0
- package/src/analysis/fix-render.ts +217 -0
- package/src/analysis/fix.ts +669 -0
- package/src/analysis/format-number.ts +31 -0
- package/src/analysis/gating.ts +792 -0
- package/src/analysis/grammar.ts +72 -0
- package/src/analysis/rebuild.ts +287 -0
- package/src/analysis/terminal.ts +336 -0
- package/src/cli/index.ts +413 -0
- package/src/combinators/adjacency.ts +171 -0
- package/src/combinators/attempt.ts +41 -0
- package/src/combinators/case-fold.ts +90 -0
- package/src/combinators/choice.ts +466 -0
- package/src/combinators/completions.ts +64 -0
- package/src/combinators/dispatch.ts +358 -0
- package/src/combinators/expect.ts +159 -0
- package/src/combinators/first-set.ts +322 -0
- package/src/combinators/gate.ts +50 -0
- package/src/combinators/grammar.ts +272 -0
- package/src/combinators/keywords.ts +145 -0
- package/src/combinators/literal.ts +102 -0
- package/src/combinators/map.ts +106 -0
- package/src/combinators/node.ts +345 -0
- package/src/combinators/not.ts +55 -0
- package/src/combinators/parser.ts +266 -0
- package/src/combinators/peek.ts +63 -0
- package/src/combinators/probe.ts +25 -0
- package/src/combinators/ref.ts +109 -0
- package/src/combinators/regex.ts +170 -0
- package/src/combinators/repeat.ts +561 -0
- package/src/combinators/scanTo.ts +393 -0
- package/src/combinators/sequence.ts +221 -0
- package/src/combinators/token.ts +120 -0
- package/src/combinators/trivia-boundary.ts +48 -0
- package/src/combinators/trivia-skip.ts +821 -0
- package/src/combinators/withCtx.ts +45 -0
- package/src/compiler/build-arity.ts +330 -0
- package/src/compiler/compile-linkable-table.ts +209 -0
- package/src/compiler/degradation.ts +266 -0
- package/src/compiler/fields.ts +191 -0
- package/src/compiler/grammar-coverage-ids.ts +129 -0
- package/src/compiler/ir-serialize.ts +615 -0
- package/src/compiler/linker.ts +954 -0
- package/src/compiler/token-alphabet.ts +209 -0
- package/src/compiler/token-dispatch.ts +353 -0
- package/src/compiler/token-scanner.ts +318 -0
- package/src/compiler/value-usage.ts +147 -0
- package/src/coverage.ts +383 -0
- package/src/cst/capture-buffer.ts +297 -0
- package/src/cst/host-mode.ts +69 -0
- package/src/cst/reflection-attach.ts +11 -0
- package/src/cst/reflection-symbols.ts +9 -0
- package/src/cst/reflection.ts +149 -0
- package/src/cst/relative-spans.ts +207 -0
- package/src/cst/root-trivia-scope.ts +30 -0
- package/src/cst/trivia-charscan.ts +312 -0
- package/src/cst/trivia-entries.ts +285 -0
- package/src/cst/trivia-index.ts +131 -0
- package/src/cst/trivia-kinds.ts +358 -0
- package/src/cst/types.ts +76 -0
- package/src/cst/walk.ts +101 -0
- package/src/functional/doc.ts +959 -0
- package/src/functional/run-tabled.ts +153 -0
- package/src/functional/run.ts +558 -0
- package/src/grammar-metadata.ts +2 -0
- package/src/index.ts +189 -0
- package/src/language-service/index.ts +221 -0
- package/src/line-index.ts +131 -0
- package/src/oracle/digest.ts +620 -0
- package/src/oracle/index.ts +55 -0
- package/src/parse-context.ts +91 -0
- package/src/plugin/direct-builder-static.ts +102 -0
- package/src/plugin/evaluator.ts +1505 -0
- package/src/plugin/free-identifiers.ts +338 -0
- package/src/plugin/index.ts +2281 -0
- package/src/plugin/reducer-resolver.ts +606 -0
- package/src/recovery/scan.ts +155 -0
- package/src/regex/classes.ts +183 -0
- package/src/regex/first-set.ts +316 -0
- package/src/run/index.ts +31 -0
- package/src/spec/ebnf.ts +128 -0
- package/src/spec/index.ts +54 -0
- package/src/spec/model.ts +636 -0
- package/src/spec/railroad-lib.ts +559 -0
- package/src/spec/railroad.ts +256 -0
- package/src/table/assemble.ts +2994 -0
- package/src/table/cell.ts +42 -0
- package/src/table/child-slots.ts +113 -0
- package/src/table/compile-rule-map.ts +336 -0
- package/src/table/compile.ts +244 -0
- package/src/table/duplication-hook.ts +89 -0
- package/src/table/emit-assembly.ts +1766 -0
- package/src/table/emit.ts +418 -0
- package/src/table/encode-baseline.ts +340 -0
- package/src/table/encode.ts +1569 -0
- package/src/table/exec-baseline.ts +537 -0
- package/src/table/exec.ts +1672 -0
- package/src/table/fold.ts +38 -0
- package/src/table/index.ts +108 -0
- package/src/table/inspect.ts +52 -0
- package/src/table/ops.ts +459 -0
- package/src/table/program.ts +855 -0
- package/src/table/run-support.ts +66 -0
- package/src/table/scan-shapes.ts +1578 -0
- package/src/table/site-labels.ts +228 -0
- package/src/table/stamp.ts +229 -0
- package/src/types.ts +563 -0
- package/src/version.ts +16 -0
- package/dist/compiler/codegen.d.ts +0 -334
- package/dist/compiler/codegen.d.ts.map +0 -1
- package/dist/compiler/inline-build.d.ts +0 -11
- package/dist/compiler/inline-build.d.ts.map +0 -1
- package/dist/compiler/inline-callback.d.ts +0 -21
- package/dist/compiler/inline-callback.d.ts.map +0 -1
- package/dist/compiler/line-index.d.ts +0 -2
- package/dist/compiler/line-index.d.ts.map +0 -1
- package/dist/compiler/module-hoist.d.ts +0 -106
- package/dist/compiler/module-hoist.d.ts.map +0 -1
- package/dist/compiler/scannable-run.d.ts.map +0 -1
- package/dist/compiler/scannable-terminal.d.ts +0 -23
- package/dist/compiler/scannable-terminal.d.ts.map +0 -1
- package/dist/compiler/trivia-fast-path.d.ts +0 -38
- package/dist/compiler/trivia-fast-path.d.ts.map +0 -1
package/dist/spec/model.d.ts
CHANGED
|
@@ -128,6 +128,14 @@ export type SpecOptions = {
|
|
|
128
128
|
regexDisplay?: (source: string, flags: string) => string | undefined;
|
|
129
129
|
};
|
|
130
130
|
export type GrammarInput = Record<string, Combinator<unknown>> | Combinator<unknown>;
|
|
131
|
+
/**
|
|
132
|
+
* The fixed string(s) a regex matches — the terminal its author actually wrote —
|
|
133
|
+
* or `undefined` when the pattern has real structure. Handles the three shapes
|
|
134
|
+
* that spell a keyword: a bare literal, a literal guarded by a trailing word
|
|
135
|
+
* boundary (`word()` / `keywords()` and every hand-written copy of them), and a
|
|
136
|
+
* `\b…\b`-anchored word.
|
|
137
|
+
*/
|
|
138
|
+
export declare function fixedStringsOfRegex(source: string): string[] | undefined;
|
|
131
139
|
/**
|
|
132
140
|
* Build the notation-agnostic spec model from a `rules()` grammar (or a single
|
|
133
141
|
* combinator). Following every referenced named rule keeps the closure complete;
|
package/dist/spec/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/spec/model.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/spec/model.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,aAAa,CAAA;AASxD,qEAAqE;AACrE,MAAM,MAAM,QAAQ,GAChB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC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AAErB,6CAA6C;AAC7C,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,QAAQ,CAAA;IACd,4EAA4E;IAC5E,MAAM,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,WAAW,EAAE,UAAU,EAAE,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB;;;;;;;;;;OAUG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAA;IAC7B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACxB,+EAA+E;IAC/E,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAClC;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAA;CACrE,CAAA;AAED,MAAM,MAAM,YAAY,GACpB,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,GACnC,UAAU,CAAC,OAAO,CAAC,CAAA;AA2IvB;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAqBxE;AA4TD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,GAAE,WAAgB,GAAG,SAAS,CA4C1F"}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE ASSEMBLER — the table, LINKED into closures instead of interpreted.
|
|
3
|
+
*
|
|
4
|
+
* This is ledger row G5 as stated: *"build the grammar reference at run start,
|
|
5
|
+
* making the swaps on rules / sub-rules (leaves) at that point, then run with NO
|
|
6
|
+
* logic branching for that option input"*. `exec.ts` builds the same table and
|
|
7
|
+
* then interprets it: one `switch (code[ip])` over 29 opcodes, executed ONCE PER
|
|
8
|
+
* ROW — 497,360 rows for `benchmark.less` (`bench/jess/g5-rows.ts`) — each
|
|
9
|
+
* re-reading its opcode and re-decoding its operands from the `Int32Array`, and
|
|
10
|
+
* re-testing the same per-parse options. That is the per-node branching the
|
|
11
|
+
* design exists to remove.
|
|
12
|
+
*
|
|
13
|
+
* ## The shape
|
|
14
|
+
*
|
|
15
|
+
* Assembly walks the reachable table ONCE and lowers each site to a PIECE: a
|
|
16
|
+
* closure with its operands already captured as `const`s and its children bound
|
|
17
|
+
* as DIRECT references to their own pieces. At parse time there is no opcode
|
|
18
|
+
* read, no operand decode and no switch — a piece is called, and it calls the
|
|
19
|
+
* pieces it holds.
|
|
20
|
+
*
|
|
21
|
+
* The numbers that make this obviously the right trade, measured not assumed:
|
|
22
|
+
*
|
|
23
|
+
* 2,241 distinct reachable sites in the less table (`bench/jess/g5-sites.ts`)
|
|
24
|
+
* 497,360 rows executed for one parse of `benchmark.less`
|
|
25
|
+
*
|
|
26
|
+
* Pieces are GRAMMAR-sized; rows are INPUT-sized. Assembly allocates ~2.2k
|
|
27
|
+
* closures once per process and removes a dispatch plus an operand decode from
|
|
28
|
+
* ~497k executions — a 222x ratio. Assembly cost is paid once and is not the
|
|
29
|
+
* metric; it is measured anyway (`bench/jess/g5-ms.ts`, `bench/jess/g5-profile.ts`).
|
|
30
|
+
*
|
|
31
|
+
* ## Why this is not "just tuning the switch"
|
|
32
|
+
*
|
|
33
|
+
* A 29-case switch on an `Int32Array` load is a jump table whose successor V8
|
|
34
|
+
* cannot know. The interpreter loop is ONE basic block with 29 merge edges, so
|
|
35
|
+
* TurboFan cannot specialise any arm against its caller and every operand stays
|
|
36
|
+
* an untyped load. Measured on this branch: `exec` reaches TURBOFAN and is
|
|
37
|
+
* deoptimised back to MAGLEV repeatedly — 100 deopt events in a 20-parse run.
|
|
38
|
+
* The design was not paying dispatch overhead, it was opting its whole hot path
|
|
39
|
+
* out of the optimising compiler.
|
|
40
|
+
*
|
|
41
|
+
* A piece is created once and its call sites see one shape, so they stay
|
|
42
|
+
* monomorphic and TurboFan can inline them. That is the structural win, and it is
|
|
43
|
+
* why the target is codegen's number rather than a fraction of the gap.
|
|
44
|
+
*
|
|
45
|
+
* ## Why this keeps the artifact small
|
|
46
|
+
*
|
|
47
|
+
* The pieces ship ONCE, here, shared by every grammar and every variant. What a
|
|
48
|
+
* bundle carries is still the table — DATA. Codegen's 2.10 MB is recognition
|
|
49
|
+
* machinery inlined bespoke per rule; this stays at the table's 0.56 MB because
|
|
50
|
+
* the machinery is one copy in the runtime and the variation lives in the
|
|
51
|
+
* ASSEMBLY, not in duplicated piece bodies.
|
|
52
|
+
*
|
|
53
|
+
* ## Options are consumed by SELECTION, not by testing
|
|
54
|
+
*
|
|
55
|
+
* The piece set is a SUPERSET; an option set reaches a subset of it. Assembly
|
|
56
|
+
* walks from the entry rule and instantiates only what it touches, so a piece an
|
|
57
|
+
* option excludes is never allocated, never linked and costs zero at run — not a
|
|
58
|
+
* cheap branch, zero. Where a decision is knowable from the option set
|
|
59
|
+
* (`hostCst` below), assembly picks the piece rather than emitting one that
|
|
60
|
+
* tests. `scripts/check-invariants.mjs` enforces that no piece body reads a
|
|
61
|
+
* config field; see `CONFIG_FIELDS` there.
|
|
62
|
+
*
|
|
63
|
+
* Semantics are `exec.ts`'s, case for case. That file remains the reference and
|
|
64
|
+
* the three-way identity sweep gates this against it.
|
|
65
|
+
*/
|
|
66
|
+
import type { Combinator, ParseContext } from '../types.ts';
|
|
67
|
+
/**
|
|
68
|
+
* THE COMPLETIONS PROBE, at the terminal fail sites and nowhere else.
|
|
69
|
+
*
|
|
70
|
+
* `failAt` (combinators/probe.ts) is called from exactly three places in the
|
|
71
|
+
* interpreter — `literal.ts`, `regex.ts`, `keywords.ts` — and codegen emits its
|
|
72
|
+
* mirror (`probeUpdate`) at the same leaf-fail sites. The table recorded
|
|
73
|
+
* NOTHING, so `completionsAt` on a table artifact saw only the top-level
|
|
74
|
+
* failure: a swallowed item failure inside a `sepBy` (`'{'` at offset 1 in a
|
|
75
|
+
* `{ decl; }` grammar) never reached the probe and the item's opener vanished
|
|
76
|
+
* from the completion set.
|
|
77
|
+
*
|
|
78
|
+
* Dormant unless `completionsAt` set `_probe`, so an ordinary parse pays one
|
|
79
|
+
* property read per terminal miss — the same price codegen pays.
|
|
80
|
+
*/
|
|
81
|
+
import { type CompactProgram, type ResolvedTable, type TableProgram, type TableRule } from './program.ts';
|
|
82
|
+
/**
|
|
83
|
+
* THE PIECE SIGNATURE — uniform, narrow, and the same for every one of the 29
|
|
84
|
+
* lowerings.
|
|
85
|
+
*
|
|
86
|
+
* Three arguments and one return, so every call site in the assembled graph sees
|
|
87
|
+
* one shape and stays monomorphic. A wider or varying signature (an out-param
|
|
88
|
+
* object, a per-op return shape) reintroduces the polymorphism this design
|
|
89
|
+
* exists to remove, and it would show up as exactly the megamorphic call sites
|
|
90
|
+
* `exec`'s switch already was.
|
|
91
|
+
*
|
|
92
|
+
* The end position travels in the assembly-scope `EC.e` slot, as it does in
|
|
93
|
+
* `exec.ts` and in codegen's `_pfEnd`, rather than in the return value — a
|
|
94
|
+
* `{ value, end }` pair would be an allocation per row.
|
|
95
|
+
*/
|
|
96
|
+
type Piece = (input: string, pos: number, ctx: ParseContext) => unknown;
|
|
97
|
+
/**
|
|
98
|
+
* The option set an assembly is specialised for.
|
|
99
|
+
*
|
|
100
|
+
* These are the facts `run()` fixes BEFORE the entry is called and that never
|
|
101
|
+
* change during a parse, so they are resolved by choosing a piece rather than by
|
|
102
|
+
* a test inside one. Anything that varies DURING a parse (position, the capture
|
|
103
|
+
* sinks a `node()` opens and closes, the error sink's contents) is runtime and
|
|
104
|
+
* stays where it is.
|
|
105
|
+
*/
|
|
106
|
+
export type RunCfg = {
|
|
107
|
+
/** Is this parse's host a CST-output host? Fixes `OP_NODE`'s whole shape. */
|
|
108
|
+
readonly hostCst: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Does the structural host consume the semantic `children` array? `false`
|
|
111
|
+
* selects raw-only node collectors. Collapse forces this back to true at the
|
|
112
|
+
* run boundary because its predicate consumes both child views.
|
|
113
|
+
*/
|
|
114
|
+
readonly hostReadsChildren?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Structural node types whose host consumes trivia. Evaluated while an
|
|
117
|
+
* assembly is built, once per node site, never from the node execution path.
|
|
118
|
+
* Absent means the backwards-compatible default: capture every structural
|
|
119
|
+
* node's trivia.
|
|
120
|
+
*/
|
|
121
|
+
readonly hostCaptureTrivia?: ((type: string) => boolean) | undefined;
|
|
122
|
+
/** `ctx.trackLines` — decides whether the trivia leaf swap is legal at all. */
|
|
123
|
+
readonly trackLines: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* `ctx._tolerant` — is THIS parse allowed to recover?
|
|
126
|
+
*
|
|
127
|
+
* FIXED FOR THE LIFETIME OF A PARSE, which is what makes it legal here rather
|
|
128
|
+
* than a per-piece test. Every writer of `ctx._tolerant` sets it BEFORE the
|
|
129
|
+
* parse begins and never during — `compile.ts:119` (`parseWithErrors`),
|
|
130
|
+
* `functional/run.ts:399`, `functional/doc.ts:29`, `combinators/completions.ts:40`.
|
|
131
|
+
* The single mid-parse mutation is `recovery/scan.ts:36`, which CLEARS it for
|
|
132
|
+
* the duration of a sentinel probe and restores it in `finally`; a sentinel is
|
|
133
|
+
* a `firstSetSentinel` char-class combinator (or an `orSentinel` of two), never
|
|
134
|
+
* an assembled rule, so no piece runs under the cleared value. Even if one did,
|
|
135
|
+
* the selection would be the RIGHT one: a probe must not recover, and it would
|
|
136
|
+
* get the strict assembly.
|
|
137
|
+
*
|
|
138
|
+
* Contrast `cstCaptureActive`, which a previous lane proposed for the same
|
|
139
|
+
* treatment and which is per-NODE state — keying on that would have been
|
|
140
|
+
* incorrect, not merely redundant.
|
|
141
|
+
*/
|
|
142
|
+
readonly tolerant: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* `ctx._grammarCoverage` — is THIS parse counting grammar coverage?
|
|
145
|
+
*
|
|
146
|
+
* FIXED FOR THE LIFETIME OF A PARSE, checked the same way `tolerant` was. There
|
|
147
|
+
* are exactly two writers — `createGrammarInstrumentationContext` (coverage.ts),
|
|
148
|
+
* which builds the field into a FRESH context object before any parse, and
|
|
149
|
+
* `functional/run.ts:403`, which installs it on the context it is about to run
|
|
150
|
+
* — and no reader anywhere mutates or clears it, mid-parse or otherwise.
|
|
151
|
+
* `createParseContext` initialises it to `undefined` once, at construction.
|
|
152
|
+
*
|
|
153
|
+
* So it is per-PARSE, unlike `ctx._cstBuf`, which a previous lane proposed
|
|
154
|
+
* keying on and which `beginCstNodeCapture`/`endCstNodeCapture` replace per
|
|
155
|
+
* NODE — that selection would have been incorrect, not merely redundant.
|
|
156
|
+
*
|
|
157
|
+
* An ordinary table has no `OP_COV` rows at all, so this bit selects a DIFFERENT
|
|
158
|
+
* assembly only for a table encoded with a coverage plan. For every other table
|
|
159
|
+
* the two assemblies are identical work and the extra bit costs one cache slot.
|
|
160
|
+
*/
|
|
161
|
+
readonly coverage: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* `ctx._probe !== undefined` — is THIS parse feeding a completions probe?
|
|
164
|
+
*
|
|
165
|
+
* FIXED FOR THE LIFETIME OF A PARSE, on exactly the evidence `tolerant` is
|
|
166
|
+
* held to. The two writers both install it BEFORE the parse begins and never
|
|
167
|
+
* during — `combinators/grammar.ts:213` (built in `run()`'s prologue when
|
|
168
|
+
* `recover` is set) and `combinators/completions.ts:38`. The single mid-parse
|
|
169
|
+
* mutation is `recovery/scan.ts:29`, which CLEARS it for the duration of a
|
|
170
|
+
* sentinel probe and restores it in `finally`; a sentinel is a
|
|
171
|
+
* `firstSetSentinel` char-class combinator, never an assembled rule, so no
|
|
172
|
+
* piece runs under the cleared value. Even if one did the selection would be
|
|
173
|
+
* the RIGHT one — a sentinel probe must fail fast, and it would get the
|
|
174
|
+
* strict assembly.
|
|
175
|
+
*
|
|
176
|
+
* It is here for `OP_GATE`, which is the only piece that reads it on a
|
|
177
|
+
* SUCCESS path. The six leaf sites read it after their own `return`, on the
|
|
178
|
+
* failure path only, and are deliberately left alone: selecting a second body
|
|
179
|
+
* per literal length to remove a failure-path test would double the runtime's
|
|
180
|
+
* literal bodies to buy nothing measurable.
|
|
181
|
+
*/
|
|
182
|
+
readonly probe: boolean;
|
|
183
|
+
};
|
|
184
|
+
/** The cfg key an assembly is cached under. */
|
|
185
|
+
export declare function cfgKey(c: RunCfg): number;
|
|
186
|
+
export type Assembly = {
|
|
187
|
+
/** One entry piece per rule name, already linked. */
|
|
188
|
+
readonly pieces: Readonly<Record<string, Piece>>;
|
|
189
|
+
readonly end: () => number;
|
|
190
|
+
/**
|
|
191
|
+
* Per-parse reset. What `exec.ts`'s `begin` DECIDED here (`trackLines`, the
|
|
192
|
+
* host mode) is exactly what assembly resolved, so all that is left is
|
|
193
|
+
* clearing the installed scanner and latching the host value.
|
|
194
|
+
*/
|
|
195
|
+
readonly begin: (ctx: ParseContext) => void;
|
|
196
|
+
/** Close an invocation and restore a suspended re-entrant frame, if any. */
|
|
197
|
+
readonly finish: () => void;
|
|
198
|
+
readonly scanSkip: readonly (readonly Combinator<unknown>[])[];
|
|
199
|
+
/**
|
|
200
|
+
* The sites this option set actually REACHED. A strict subset of the table's
|
|
201
|
+
* reachable set whenever an option excludes anything, and the assertion
|
|
202
|
+
* `test/unit/table-assemble.test.ts` makes on that.
|
|
203
|
+
*/
|
|
204
|
+
readonly reached: ReadonlySet<number>;
|
|
205
|
+
/**
|
|
206
|
+
* WHY THIS ASSEMBLY IS RUNNING CLOSURES, when it is.
|
|
207
|
+
*
|
|
208
|
+
* `undefined` means the emitted engine (`emit-assembly.ts`) built this
|
|
209
|
+
* assembly. A string names the construct it refused. It is a field rather
|
|
210
|
+
* than a log line because a grammar that quietly drops to the closure path
|
|
211
|
+
* is a permanently slow path nobody would ever find — the same failure
|
|
212
|
+
* `encode.ts:1208-1213` refuses to allow for `OP_LIVE`.
|
|
213
|
+
*/
|
|
214
|
+
readonly emitRefusal: string | undefined;
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Link one resolved table, for one option set, into a graph of closures.
|
|
218
|
+
*
|
|
219
|
+
* ONE walk. Each site is lowered at most once and memoised by its code offset,
|
|
220
|
+
* so a subtree shared by two parents is one piece with two references to it.
|
|
221
|
+
*/
|
|
222
|
+
export declare function assemble(t: ResolvedTable, prog: TableProgram, cfg: RunCfg): Assembly;
|
|
223
|
+
/**
|
|
224
|
+
* Assemblies for one resolved table, one per option set, built on demand.
|
|
225
|
+
*
|
|
226
|
+
* The option set is not known when the rule map is created — `ctx.build`,
|
|
227
|
+
* `ctx.trackLines` and `ctx._tolerant` arrive with the parse — so the entry
|
|
228
|
+
* computes the scalar key and takes the assembly for it, building it the first
|
|
229
|
+
* time that combination is seen. That is the "assembled at run start" half of G5:
|
|
230
|
+
* only the option combinations a process actually uses, each holding the pieces
|
|
231
|
+
* its options reach. A process that never parses tolerantly never builds, and
|
|
232
|
+
* never runs, a single recovery piece.
|
|
233
|
+
*/
|
|
234
|
+
export declare class AssemblyCache {
|
|
235
|
+
private readonly t;
|
|
236
|
+
private readonly prog;
|
|
237
|
+
private readonly byCfg;
|
|
238
|
+
/**
|
|
239
|
+
* Monomorphic predicate inline cache. An assembly depends on the predicate
|
|
240
|
+
* FUNCTION and the scalar cfg key, not on the host object that carries it, so
|
|
241
|
+
* retaining the host would add neither correctness nor reuse. Stable parsing
|
|
242
|
+
* is one identity comparison plus an array index; replacing the predicate
|
|
243
|
+
* replaces this specialisation without retaining either host.
|
|
244
|
+
*/
|
|
245
|
+
private hostPredicate;
|
|
246
|
+
private hostAssemblies;
|
|
247
|
+
constructor(prog: TableProgram, resolved?: ResolvedTable);
|
|
248
|
+
for(cfg: RunCfg): Assembly;
|
|
249
|
+
/**
|
|
250
|
+
* The assembly for the option set this `ctx` implies.
|
|
251
|
+
*
|
|
252
|
+
* ─── WHY THIS IS NOT A VIOLATION OF "NO OPTION READS AT PARSE TIME" ─────────
|
|
253
|
+
*
|
|
254
|
+
* The rule that shaped 0.47 is that consulting an option PER RULE or PER
|
|
255
|
+
* COMBINATOR is a fail, and the reason it is a fail is that such a consult
|
|
256
|
+
* scales with the input. This one does not, and the previous defence of it —
|
|
257
|
+
* "cheap, allocation-free, only once" — was the wrong argument, because
|
|
258
|
+
* cheapness is not the criterion. The right argument is that the consult is
|
|
259
|
+
* IRREDUCIBLE, and it is worth stating precisely so nobody re-opens it:
|
|
260
|
+
*
|
|
261
|
+
* A table entry has the artifact signature `(input, pos, ctx)`, shared with
|
|
262
|
+
* codegen. All scalar option bits live on that `ctx`, and every one of them is
|
|
263
|
+
* supplied PER CALL by the caller — `run()` takes `tolerant`, `build` and
|
|
264
|
+
* `instrumentation` as options on an artifact it was handed;
|
|
265
|
+
* `combinators/grammar.ts` sets `trackLines` on scope entry;
|
|
266
|
+
* `completionsAt` installs `_probe`. So the option set is not knowable
|
|
267
|
+
* before the call, and a selection that cannot happen before the call must
|
|
268
|
+
* happen at it.
|
|
269
|
+
*
|
|
270
|
+
* That is not a hole in G5, it is G5's own first clause: "quickly building the
|
|
271
|
+
* grammar reference ON RUN START, making some swaps on rules or sub-rules, and
|
|
272
|
+
* then the run actually runs with no logic branching for that option input"
|
|
273
|
+
* (`notes/TABLE-DRIVER.md`). This IS the run-start step. What the criterion
|
|
274
|
+
* forbids is the second sentence, and past this call there is no option read
|
|
275
|
+
* anywhere — `scripts/check-invariants.mjs` INV-6 decides that mechanically.
|
|
276
|
+
*
|
|
277
|
+
* MEASURED, not asserted: exactly ONE call per entry invocation, including
|
|
278
|
+
* `benchmark.less` at 106,802 bytes. Eliminating it would require binding the
|
|
279
|
+
* option set to the ARTIFACT rather than to the CALL, which is a change to the
|
|
280
|
+
* public run API (the map would have to hand back a cfg-keyed family and
|
|
281
|
+
* `run()` index it), not a change to this file.
|
|
282
|
+
*
|
|
283
|
+
* It allocates nothing: the key is packed from the ctx's own bits by `cfgKeyOf`,
|
|
284
|
+
* which takes them as arguments precisely so no `RunCfg` need exist here — that
|
|
285
|
+
* object is built only on the miss that builds an assembly. A host trivia
|
|
286
|
+
* predicate additionally selects its identity-specialised inline cache
|
|
287
|
+
* because a function cannot be represented by a scalar bit.
|
|
288
|
+
*
|
|
289
|
+
* DO NOT CACHE THE RESULT ACROSS CALLS. Keying it on anything but the `ctx`'s
|
|
290
|
+
* own option bits is how `tableRules` handed a strict parse the PREVIOUS
|
|
291
|
+
* parse's tolerant assembly (`test/unit/table-assemble.test.ts`).
|
|
292
|
+
*/
|
|
293
|
+
forCtx(ctx: ParseContext): Assembly;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* The ASSEMBLED rule map — the same artifact contract as `tableRules`, run
|
|
297
|
+
* through linked closures instead of the bytecode interpreter.
|
|
298
|
+
*
|
|
299
|
+
* THE ONE config read is HERE, at the boundary, once per entry invocation:
|
|
300
|
+
* `AssemblyCache.forCtx` turns the `ctx` into a scalar option set and takes the
|
|
301
|
+
* assembly built for it. Everything past that point is pieces, and no piece body
|
|
302
|
+
* reads an option — `scripts/check-invariants.mjs` INV-6 asserts it. `forCtx`
|
|
303
|
+
* carries the argument for why that read is irreducible rather than merely cheap.
|
|
304
|
+
*/
|
|
305
|
+
export declare function tableRules(source: TableProgram | CompactProgram, artifactMetadata?: Readonly<Record<symbol, unknown>>): Record<string, TableRule>;
|
|
306
|
+
export {};
|
|
307
|
+
//# sourceMappingURL=assemble.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assemble.d.ts","sourceRoot":"","sources":["../../src/table/assemble.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAs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
/**
|
|
2
|
+
* THE PROTOCOL THE THREE ENGINES SHARE — the failure sentinel and the
|
|
3
|
+
* end-position out-parameter.
|
|
4
|
+
*
|
|
5
|
+
* `exec.ts`, `assemble.ts` and `emit-assembly.ts` each ran a private copy of
|
|
6
|
+
* both: three `Symbol('pm.fail')` calls and three `let END = 0` closure slots.
|
|
7
|
+
* That was sound while an assembly picked ONE engine and ran it for the whole
|
|
8
|
+
* parse, which is what every shipped configuration does.
|
|
9
|
+
*
|
|
10
|
+
* It stops being sound the moment two engines are live in one parse. A piece
|
|
11
|
+
* from engine A returning A's `FAIL` to a caller in engine B is a VALUE to B —
|
|
12
|
+
* `!== FAIL` is true — so a failed match reads as a successful one carrying a
|
|
13
|
+
* symbol, and the parse continues from a position nobody wrote. Neither a type
|
|
14
|
+
* nor a test would catch it: the sentinels have the same description, and the
|
|
15
|
+
* three-way identity sweep only ever exercised one engine per process.
|
|
16
|
+
*
|
|
17
|
+
* So both halves move here:
|
|
18
|
+
*
|
|
19
|
+
* - `FAIL` is ONE symbol, module-level, imported by every engine. There is no
|
|
20
|
+
* per-assembly variation possible in a sentinel, so there is no reason for it
|
|
21
|
+
* to be per-assembly state.
|
|
22
|
+
* - `EndCell` is per-ASSEMBLY, not per-module. Two assemblies for two grammars
|
|
23
|
+
* may be live in one process and must not share a slot; the engines *within*
|
|
24
|
+
* one assembly must. `assemble()` mints one and hands it to whichever engines
|
|
25
|
+
* that assembly builds.
|
|
26
|
+
*
|
|
27
|
+
* A one-property object rather than an `Int32Array`: the store is monomorphic
|
|
28
|
+
* either way, and `e` reads in emitted text as `EC.e`, which is the same shape
|
|
29
|
+
* the closure engine writes.
|
|
30
|
+
*/
|
|
31
|
+
/** The failure sentinel. ONE per process, shared by every engine. */
|
|
32
|
+
export declare const FAIL: unique symbol;
|
|
33
|
+
export type Fail = typeof FAIL;
|
|
34
|
+
/**
|
|
35
|
+
* The end-position out-parameter — `_pfEnd` in emitted text, `END` in the
|
|
36
|
+
* closure walk and the driver. One per assembly.
|
|
37
|
+
*/
|
|
38
|
+
export type EndCell = {
|
|
39
|
+
e: number;
|
|
40
|
+
};
|
|
41
|
+
export declare const newEndCell: () => EndCell;
|
|
42
|
+
//# sourceMappingURL=cell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cell.d.ts","sourceRoot":"","sources":["../../src/table/cell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,qEAAqE;AACrE,eAAO,MAAM,IAAI,EAAE,OAAO,MAA0B,CAAA;AACpD,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAA;AAE9B;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG;IAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnC,eAAO,MAAM,UAAU,QAAO,OAAqB,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE EDGE TABLE. Which operand slots of an instruction are CHILD instructions.
|
|
3
|
+
*
|
|
4
|
+
* This is one fact about the operand layout, and it was written twice: once in
|
|
5
|
+
* `site-labels.ts` over the 35 opcodes `emit-assembly.ts` lowers, once fused into
|
|
6
|
+
* `inspect.ts`'s `reachableIps` traversal over all 40. The two agreed slot-for-slot
|
|
7
|
+
* on every opcode both covered — which is the problem, not the reassurance. Adding
|
|
8
|
+
* an opcode meant editing two switches in two files, and NOTHING failed if you
|
|
9
|
+
* edited one. `site-labels.ts`'s own header names that failure mode, then guards
|
|
10
|
+
* only against it happening WITHIN that file.
|
|
11
|
+
*
|
|
12
|
+
* The subset was never load-bearing. The five opcodes it omitted — COV, GREEDY,
|
|
13
|
+
* REJECT, ARMGATE, WITHCTX — are exactly the five `emit-assembly.ts` has no case
|
|
14
|
+
* for, so any program containing one throws `Unemittable` from the default arm and
|
|
15
|
+
* the whole assembly falls back to closures. Walking into their subtrees can
|
|
16
|
+
* therefore only affect a result that is about to be discarded. (Verified: none of
|
|
17
|
+
* the five is so much as imported by `emit-assembly.ts`. Its one consumer of these
|
|
18
|
+
* edges, the `fd`/`er` sink census, is computed before the lowering that throws.)
|
|
19
|
+
*
|
|
20
|
+
* `code` is `ArrayLike<number>` because the two callers hold different
|
|
21
|
+
* representations of the same stream — `TableProgram.code` is a `readonly number[]`,
|
|
22
|
+
* `ResolvedTable.code` is an `Int32Array`.
|
|
23
|
+
*
|
|
24
|
+
* Returns false for an opcode this table does not know, so each caller keeps its own
|
|
25
|
+
* answer to that: `inspect.ts` throws (a program it cannot decode is a bug it must
|
|
26
|
+
* report), `site-labels.ts` ignores it (an unwalked site resolves to `TOP` via
|
|
27
|
+
* `labelAt`, and the enclosing assembly is unemittable anyway).
|
|
28
|
+
*/
|
|
29
|
+
export declare function childSlots(code: ArrayLike<number>, ip: number, out: number[]): boolean;
|
|
30
|
+
//# sourceMappingURL=child-slots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"child-slots.d.ts","sourceRoot":"","sources":["../../src/table/child-slots.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CA4EtF"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { Combinator } from '../types.ts';
|
|
2
|
+
import type { HostMode } from '../cst/host-mode.ts';
|
|
3
|
+
import { type GrammarReflection } from '../cst/reflection.ts';
|
|
4
|
+
import type { TableProgram, TableRule } from './program.ts';
|
|
5
|
+
import { type GrammarCoverageDefinition } from '../compiler/grammar-coverage-ids.ts';
|
|
6
|
+
import { type DuplicationOption } from './duplication-hook.ts';
|
|
7
|
+
/**
|
|
8
|
+
* `compileRuleMap()` FOR THE TABLE LOWERING — the counterpart that did not exist.
|
|
9
|
+
*
|
|
10
|
+
* `compile` covered `compile()`, the SINGLE-ROOT entry point, which the
|
|
11
|
+
* plugin uses only for standalone combinators (`plugin/index.ts:1693`, `:1870`).
|
|
12
|
+
* The main path — every `rules()` grammar — goes through `compileRuleMap`, and
|
|
13
|
+
* with no table counterpart there was nothing for the macro build to point at.
|
|
14
|
+
* This is that function, and it is the EASY direction: `encodeTable` takes a
|
|
15
|
+
* named rule map natively, so nothing here adapts a shape. `compile` is the
|
|
16
|
+
* one that adapts (it wraps a root as `{ Entry: root }`).
|
|
17
|
+
*
|
|
18
|
+
* ── THE CONTRACT IT MATCHES ──────────────────────────────────────────────────
|
|
19
|
+
* `compileRuleMap` returns ONE `replacement` string: a self-contained expression
|
|
20
|
+
* that the plugin splices over the whole `rules(factory)` call-expression
|
|
21
|
+
* (`plugin/index.ts:1753`, and as an initialiser at `:1941`), evaluating ONCE to
|
|
22
|
+
* the `{ name: fn, … }` map. `keys` is the entry list, for the caller to check
|
|
23
|
+
* against the source's own keys. `hostMode` / `hostBranchElided` are what the
|
|
24
|
+
* macro stamps the emitted map with. `reflection` is per-grammar CST node
|
|
25
|
+
* reflection. It returns `null`, all-or-nothing, when the map cannot be inlined.
|
|
26
|
+
*
|
|
27
|
+
* Every one of those is reproduced here, with ONE stated divergence, the same
|
|
28
|
+
* one `compile` documents: the expression references `tableRules` and is
|
|
29
|
+
* therefore NOT self-contained. That reference is the entire reason a table
|
|
30
|
+
* artifact is small; inlining the driver per grammar rebuilds exactly the size
|
|
31
|
+
* this lowering exists to remove. The consumer owns the import.
|
|
32
|
+
*
|
|
33
|
+
* ── WHY `emitTableModule` WAS NOT ENOUGH ─────────────────────────────────────
|
|
34
|
+
* It emits a whole rule map as one module — `import` line, `export const` — and
|
|
35
|
+
* the plugin has no module to write; it has an expression slot inside an
|
|
36
|
+
* existing file. `emitTableExpression` was the right emitter and needed one
|
|
37
|
+
* thing: `entry: null`, meaning "the map itself" rather than one rule out of it.
|
|
38
|
+
* That is a two-line change to an existing emitter, not a new one.
|
|
39
|
+
*/
|
|
40
|
+
export type TableRuleMapOptions = {
|
|
41
|
+
/** Grammar-level ambient trivia, as `rules({ trivia }, …)` declares it. */
|
|
42
|
+
readonly trivia?: Combinator<unknown>;
|
|
43
|
+
/** Grammar-level ambient scan-skip, as `rules({ scanSkip }, …)` declares it. */
|
|
44
|
+
readonly scanSkip?: Combinator<unknown>[];
|
|
45
|
+
readonly recovery?: boolean;
|
|
46
|
+
readonly hostMode?: HostMode;
|
|
47
|
+
readonly trackLines?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* GRAMMAR-COVERAGE COUNTERS. This is the MACRO's path — `plugin/index.ts` passes
|
|
50
|
+
* `coverage: grammarCoverage` here for every `rules()` grammar — so this is what
|
|
51
|
+
* makes `{ grammarCoverage: true }` a working build under the table lowering.
|
|
52
|
+
*
|
|
53
|
+
* COUNTERS ONLY, per the owner ruling recorded in `notes/RELEASE-0.48-TARGET.md`
|
|
54
|
+
* §1; `_grammarTrace` parity is 0.48 work. The plugin's coverage path needs the
|
|
55
|
+
* DEFINITIONS STAMP and the HITS, and both are here.
|
|
56
|
+
*/
|
|
57
|
+
readonly coverage?: boolean;
|
|
58
|
+
/** Identifier the emitted expression expects `tableRules` to be bound to. */
|
|
59
|
+
readonly runtimeRef?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Reducer sources in `prog.fns` order, for a caller that holds them OUT OF
|
|
62
|
+
* BAND — the same escape `compile(combinator, mapFnSources?)` provides.
|
|
63
|
+
*
|
|
64
|
+
* The encoder captures a source per callback from the def (`fnSrc` /
|
|
65
|
+
* `buildSrc` / `predSrc` / `gateSrcs`), which the macro evaluator sets and a
|
|
66
|
+
* runtime-built combinator does not have. Supplying them here is what lets a
|
|
67
|
+
* grammar constructed at runtime still PRINT; it does not override captured
|
|
68
|
+
* ones, it fills in for a pool that has none.
|
|
69
|
+
*/
|
|
70
|
+
readonly fnSources?: readonly string[];
|
|
71
|
+
/**
|
|
72
|
+
* WHY THIS REFUSED, filled in on the `null` return.
|
|
73
|
+
*
|
|
74
|
+
* `null` means "leave this grammar interpreted", which is ~79 ms against ~14 ms
|
|
75
|
+
* on `benchmark.less` — a ~5x regression that produces no test failure and no
|
|
76
|
+
* warning content beyond "couldn't be inlined". The reasons exist inside the
|
|
77
|
+
* encoder (`prog.runtimeOnly`) and simply had no way out; this is that way out,
|
|
78
|
+
* so the plugin's warning can name the construct instead of the outcome.
|
|
79
|
+
*
|
|
80
|
+
* An out-parameter rather than a changed return type: every existing caller
|
|
81
|
+
* checks for `null` and that contract is unchanged.
|
|
82
|
+
*/
|
|
83
|
+
readonly refusals?: string[];
|
|
84
|
+
/**
|
|
85
|
+
* The structural duplication diagnostic. Ran inside the source lowering; it runs
|
|
86
|
+
* here for the same reason, so a build that asked for it keeps getting it.
|
|
87
|
+
*/
|
|
88
|
+
readonly duplication?: DuplicationOption;
|
|
89
|
+
};
|
|
90
|
+
export type CompiledRuleMapTable = {
|
|
91
|
+
/** Every entry this saw, in order — same use as `compileRuleMap`'s `keys`. */
|
|
92
|
+
keys: string[];
|
|
93
|
+
/** The expression that replaces the whole `rules(factory)` call. */
|
|
94
|
+
replacement: string;
|
|
95
|
+
/** Re-emit the same table call with construction-time artifact metadata. */
|
|
96
|
+
replacementWithMetadata(metadataSource: string): string;
|
|
97
|
+
hostMode: HostMode;
|
|
98
|
+
hostBranchElided: boolean;
|
|
99
|
+
reflection: GrammarReflection;
|
|
100
|
+
/**
|
|
101
|
+
* The RUNNABLE map, which the source lowering has no counterpart for — it
|
|
102
|
+
* hands back text and nothing else, because its artifact only exists once the
|
|
103
|
+
* emitted source is evaluated. A table exists as data before it is printed, so
|
|
104
|
+
* the same call that produces the replacement can also hand back the parser.
|
|
105
|
+
* That is what makes a differential against the interpreter possible without
|
|
106
|
+
* `eval`, and it is why the table-vs-interpreter test can compare `expected`
|
|
107
|
+
* sets rather than only accept/reject.
|
|
108
|
+
*/
|
|
109
|
+
rules: Record<string, TableRule>;
|
|
110
|
+
/** The encoded program, for a caller that wants to fold or inspect it. */
|
|
111
|
+
prog: TableProgram;
|
|
112
|
+
/**
|
|
113
|
+
* The coverage DENOMINATOR — every id this map can hit — present only under
|
|
114
|
+
* `{ coverage: true }`. Same field and same meaning as `compileRuleMap`'s, so
|
|
115
|
+
* the plugin's stamp site needs no branch on which lowering produced it.
|
|
116
|
+
*/
|
|
117
|
+
coverageDefinitions?: readonly GrammarCoverageDefinition[];
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* ENCODE FOR RUNNING, with no printability requirement.
|
|
121
|
+
*
|
|
122
|
+
* `compileRuleMap` refuses a map whose author callbacks have no captured SOURCE,
|
|
123
|
+
* because PRINTING one would emit `() => {}` and the parse would return the wrong tree.
|
|
124
|
+
* That gate is right for the macro, which prints, and wrong for every caller that only
|
|
125
|
+
* ever RUNS the result: a grammar built at runtime has live callbacks and no sources by
|
|
126
|
+
* construction, and `encodeTableProgram` parks the live function in the pool where the
|
|
127
|
+
* driver calls it perfectly well.
|
|
128
|
+
*
|
|
129
|
+
* Conflating the two is the single defect this project has now hit three times — a
|
|
130
|
+
* runtime `compose()`, `linkable()`, and the fuse — each presenting as "this grammar
|
|
131
|
+
* cannot be compiled" for a grammar that runs. The split lives here, once, so the next
|
|
132
|
+
* caller inherits the right answer instead of rediscovering it.
|
|
133
|
+
*/
|
|
134
|
+
export declare function compileRuleMapRunnable(ruleMap: ReadonlyArray<readonly [string, Combinator<unknown>]>, opts?: TableRuleMapOptions): Omit<CompiledRuleMapTable, 'replacement' | 'replacementWithMetadata'> | null;
|
|
135
|
+
export declare function compileRuleMap(ruleMap: ReadonlyArray<readonly [string, Combinator<unknown>]>, opts?: TableRuleMapOptions): CompiledRuleMapTable | null;
|
|
136
|
+
//# sourceMappingURL=compile-rule-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-rule-map.d.ts","sourceRoot":"","sources":["../../src/table/compile-rule-map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE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,EAAE,MAAM,CAAA;IACnB,4EAA4E;IAC5E,uBAAuB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAAA;IACvD,QAAQ,EAAE,QAAQ,CAAA;IAClB,gBAAgB,EAAE,OAAO,CAAA;IACzB,UAAU,EAAE,iBAAiB,CAAA;IAC7B;;;;;;;;OAQG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAChC,0EAA0E;IAC1E,IAAI,EAAE,YAAY,CAAA;IAClB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,SAAS,yBAAyB,EAAE,CAAA;CAC3D,CAAA;AA2ED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAC9D,IAAI,GAAE,mBAAwB,GAC7B,IAAI,CAAC,oBAAoB,EAAE,aAAa,GAAG,yBAAyB,CAAC,GAAG,IAAI,CAc9E;AAmCD,wBAAgB,cAAc,CAC5B,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAC9D,IAAI,GAAE,mBAAwB,GAC7B,oBAAoB,GAAG,IAAI,CAkE7B"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Combinator, CompiledParser } from '../types.ts';
|
|
2
|
+
import type { HostMode } from '../cst/host-mode.ts';
|
|
3
|
+
import { type DuplicationOption } from './duplication-hook.ts';
|
|
4
|
+
/**
|
|
5
|
+
* THE CONTRACT DIVERGENCE, stated rather than hidden.
|
|
6
|
+
*
|
|
7
|
+
* `CompiledParser.inlineExpression` is documented as a self-contained IIFE with
|
|
8
|
+
* "no external references". A table artifact cannot honour that clause and stay
|
|
9
|
+
* a table: the shared driver being EXTERNAL is the entire reason the artifact is
|
|
10
|
+
* 0.56 MB instead of source lowering's 2.10 MB. Inlining the driver per grammar
|
|
11
|
+
* reproduces exactly the size this lowering exists to avoid.
|
|
12
|
+
*
|
|
13
|
+
* So the expression references `tableRules`, and the consumer is responsible for
|
|
14
|
+
* having imported it. That is a real change to what an inliner must do, and it
|
|
15
|
+
* is the reason this is a lowering swap rather than a rename.
|
|
16
|
+
*
|
|
17
|
+
* It is NOT null. Returning null would be the quiet failure: `plugin/index.ts`
|
|
18
|
+
* warns and SKIPS on null, leaving the grammar interpreted — 79 ms against 14 ms
|
|
19
|
+
* on `benchmark.less`, a ~5x regression that no test would have reported.
|
|
20
|
+
*/
|
|
21
|
+
export type TableCompileOptions = {
|
|
22
|
+
readonly hostMode?: HostMode;
|
|
23
|
+
readonly trackLines?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* ACCEPTED AND IGNORED — recovery is ALWAYS lowered (see `TableSettings.recovery`).
|
|
26
|
+
* Kept so this stays a drop-in for `compile(g, …, { recovery: true })`.
|
|
27
|
+
*/
|
|
28
|
+
readonly recovery?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* GRAMMAR-COVERAGE COUNTERS, lowered as `OP_COV` rows plus the definition pool
|
|
31
|
+
* (`TableProgram.cov`). Same ids as the source lowering, because both mint them
|
|
32
|
+
* from the same `buildGrammarPlan` walk over the same combinator graph.
|
|
33
|
+
*
|
|
34
|
+
* COUNTERS ONLY — owner ruling. `_grammarTrace`'s six phases are emitted at
|
|
35
|
+
* ~40 fine-grained sites by codegen and are deferred to 0.48
|
|
36
|
+
* (`notes/RELEASE-0.48-TARGET.md` §1). A table entry rejects a context carrying
|
|
37
|
+
* a trace sink before parsing: silently returning an empty trace would look
|
|
38
|
+
* exactly like a real trace whose grammar sites were never visited. The
|
|
39
|
+
* plugin's coverage path reads `_grammarCoverage` and the definitions stamp,
|
|
40
|
+
* neither of which is trace.
|
|
41
|
+
*
|
|
42
|
+
* The remaining options below are accepted for signature compatibility with
|
|
43
|
+
* `compile()`. Any that the table lowering cannot honour THROWS rather than
|
|
44
|
+
* being ignored — a compile that silently drops the instrumentation its caller
|
|
45
|
+
* asked for is the failure class this project keeps finding, and coverage that
|
|
46
|
+
* silently reports nothing is worse than a build error that says why.
|
|
47
|
+
*/
|
|
48
|
+
readonly coverage?: boolean;
|
|
49
|
+
readonly duplication?: DuplicationOption;
|
|
50
|
+
/** Identifier the emitted expression expects to find `tableRules` under. */
|
|
51
|
+
readonly runtimeRef?: string;
|
|
52
|
+
/** Source text per `prog.fns` entry, for a module/expression that must be printable. */
|
|
53
|
+
readonly fnSources?: readonly string[];
|
|
54
|
+
};
|
|
55
|
+
export declare function compile<T>(combinator: Combinator<T>, mapFnSources?: readonly string[], opts?: TableCompileOptions): CompiledParser<T>;
|
|
56
|
+
//# sourceMappingURL=compile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/table/compile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAyC,MAAM,aAAa,CAAA;AACpG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAOnD,OAAO,EAA4B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAiDxF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;IAC7B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAIxC,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,wFAAwF;IACxF,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CACvC,CAAA;AAED,wBAAgB,OAAO,CAAC,CAAC,EACvB,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,EAChC,IAAI,GAAE,mBAAwB,GAC7B,cAAc,CAAC,CAAC,CAAC,CAmBnB"}
|