parseman 0.45.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-gate.d.ts +158 -0
- package/dist/analysis/choice-cost-gate.d.ts.map +1 -0
- package/dist/analysis/choice-cost-render.d.ts +96 -0
- package/dist/analysis/choice-cost-render.d.ts.map +1 -0
- package/dist/analysis/choice-cost.d.ts +383 -0
- package/dist/analysis/choice-cost.d.ts.map +1 -0
- package/dist/analysis/commitment.d.ts +131 -0
- package/dist/analysis/commitment.d.ts.map +1 -0
- package/dist/analysis/corpus.d.ts +73 -0
- package/dist/analysis/corpus.d.ts.map +1 -0
- package/dist/analysis/diagnose-render.d.ts +65 -0
- package/dist/analysis/diagnose-render.d.ts.map +1 -0
- package/dist/analysis/diagnose.d.ts +15 -0
- package/dist/analysis/diagnose.d.ts.map +1 -1
- package/dist/analysis/diagnostics.cjs +13736 -0
- package/dist/analysis/diagnostics.cjs.map +6 -0
- package/dist/analysis/diagnostics.d.ts +27 -0
- package/dist/analysis/diagnostics.d.ts.map +1 -0
- package/dist/analysis/diagnostics.js +13713 -0
- package/dist/analysis/diagnostics.js.map +6 -0
- package/dist/analysis/duplication.d.ts.map +1 -1
- package/dist/analysis/fix-render.d.ts +43 -0
- package/dist/analysis/fix-render.d.ts.map +1 -0
- package/dist/analysis/fix.d.ts +172 -0
- package/dist/analysis/fix.d.ts.map +1 -0
- 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 +47 -2
- package/dist/analysis/gating.d.ts.map +1 -1
- package/dist/analysis/rebuild.d.ts +61 -0
- package/dist/analysis/rebuild.d.ts.map +1 -0
- package/dist/analysis/terminal.d.ts +145 -0
- package/dist/analysis/terminal.d.ts.map +1 -0
- package/dist/cli/index.cjs +14837 -0
- package/dist/cli/index.cjs.map +6 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +14814 -0
- package/dist/cli/index.js.map +6 -0
- 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/build-arity.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 +79 -47
- 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 +10499 -7478
- package/dist/index.cjs.map +3 -4
- package/dist/index.d.ts +24 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10499 -7478
- 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 +41 -2
- package/dist/plugin/evaluator.d.ts.map +1 -1
- package/dist/plugin/free-identifiers.d.ts +23 -0
- package/dist/plugin/free-identifiers.d.ts.map +1 -0
- package/dist/plugin/index.cjs +11381 -9442
- package/dist/plugin/index.cjs.map +3 -4
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +11381 -9442
- package/dist/plugin/index.js.map +3 -4
- package/dist/plugin/reducer-resolver.d.ts +17 -1
- package/dist/plugin/reducer-resolver.d.ts.map +1 -1
- 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 -1622
- package/dist/spec/index.cjs.map +3 -4
- package/dist/spec/index.js +2898 -1622
- 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 +41 -3
- 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/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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TableProgram } from './program.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Walk the REACHABLE instructions of a program.
|
|
4
|
+
*
|
|
5
|
+
* A histogram over the raw word stream is not this: operands are ordinary
|
|
6
|
+
* numbers and collide with opcode values, so counting words would report
|
|
7
|
+
* confident nonsense. Reachability from the rule entries, decoding each
|
|
8
|
+
* instruction's declared width, is the only correct read.
|
|
9
|
+
*/
|
|
10
|
+
export declare function reachableOps(prog: TableProgram): Map<number, number>;
|
|
11
|
+
/**
|
|
12
|
+
* The reachable INSTRUCTION OFFSETS, which is what any per-row question needs —
|
|
13
|
+
* an opcode histogram cannot answer "which functions sit behind this row".
|
|
14
|
+
*/
|
|
15
|
+
export declare function reachableIps(prog: TableProgram): Set<number>;
|
|
16
|
+
export declare function opHistogram(prog: TableProgram): Record<string, number>;
|
|
17
|
+
//# sourceMappingURL=inspect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../src/table/inspect.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAQpE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC,CAmB5D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAItE"}
|
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opcodes for the TABLE lowering (design ledger row G5).
|
|
3
|
+
*
|
|
4
|
+
* The premise, stated so it can be falsified: today every rule's recognizer is
|
|
5
|
+
* INLINED BESPOKE into its own emitted function, so an artifact pays the full
|
|
6
|
+
* cost of the recognition machinery once PER RULE (measured: ~4.9 kB for a
|
|
7
|
+
* `node()` rule; ~186 B for each additional call site). Emitting a rule as a
|
|
8
|
+
* TABLE ROW interpreted by one shared driver moves that machinery out of the
|
|
9
|
+
* artifact and into the runtime, where it is emitted ONCE for all grammars and
|
|
10
|
+
* all variants.
|
|
11
|
+
*
|
|
12
|
+
* The instruction stream is a flat `number[]`: `code[ip]` is the opcode and the
|
|
13
|
+
* operands follow it inline. Child instructions are referenced by ABSOLUTE code
|
|
14
|
+
* offset, never by nesting, so the driver is a plain recursive read — no node
|
|
15
|
+
* objects, no closures, no per-combinator allocation.
|
|
16
|
+
*
|
|
17
|
+
* Operand layouts are documented per opcode below and are the contract between
|
|
18
|
+
* `encode.ts` and `exec.ts`. Nothing else may read the stream.
|
|
19
|
+
*/
|
|
20
|
+
/** `LIT k` — `k` indexes a string in the const pool. */
|
|
21
|
+
export declare const OP_LIT = 1;
|
|
22
|
+
/** `RX k` — `k` indexes a STICKY `RegExp` in the const pool. */
|
|
23
|
+
export declare const OP_RX = 2;
|
|
24
|
+
/** `SEQ n c1 … cn` — n child offsets; value is the array of their values. */
|
|
25
|
+
export declare const OP_SEQ = 3;
|
|
26
|
+
/** `SEQV n c1 … cn` — `SEQ` with `valueUnused`: terms run, no tuple is built. */
|
|
27
|
+
export declare const OP_SEQV = 4;
|
|
28
|
+
/**
|
|
29
|
+
* `CHOICE d n fx c1 … cn` — `d` indexes a dispatch table (or −1 for ordered
|
|
30
|
+
* try); `fx` indexes the choice's OWN expected set.
|
|
31
|
+
*
|
|
32
|
+
* Both shipped engines report the UNION of the arms' expectations when a choice
|
|
33
|
+
* fails. The driver reported whatever the last attempted arm left behind — or,
|
|
34
|
+
* on a dispatch miss with no arm claiming the lead character, NOTHING, so a user
|
|
35
|
+
* got an error naming nothing at all.
|
|
36
|
+
*/
|
|
37
|
+
export declare const OP_CHOICE = 5;
|
|
38
|
+
/**
|
|
39
|
+
* `REP c min max sep flags` — `sep` is a child offset or −1; `max` −1 = ∞.
|
|
40
|
+
* `flags` bit 0 = trailing separator allowed, bit 1 = `keepSeparators`.
|
|
41
|
+
*/
|
|
42
|
+
export declare const OP_REP = 6;
|
|
43
|
+
/** `REPV …` — `REP` with `valueUnused`. */
|
|
44
|
+
export declare const OP_REPV = 7;
|
|
45
|
+
/** `OPT c` — child, or `null` at the same position. NOT `undefined`: `optional()`
|
|
46
|
+
* yields `null` on no-match (src/combinators/repeat.ts:269,277) and grammars TEST for
|
|
47
|
+
* it — examples/lang's `call` reducer is `if (args === null) return callee`, so
|
|
48
|
+
* `undefined` there turned a bare identifier into a call node with `args: undefined`.
|
|
49
|
+
* The parse succeeded and only the tree moved. */
|
|
50
|
+
export declare const OP_OPT = 8;
|
|
51
|
+
/** `XFORM f c` — `f` indexes the reducer; called `(value, span)`. */
|
|
52
|
+
export declare const OP_XFORM = 9;
|
|
53
|
+
/**
|
|
54
|
+
* `NODE b c flags proj type tags` — SEVEN words. `b` indexes the build reducer
|
|
55
|
+
* (−1 = none), `c` is the child offset, `proj` the projected child index (−1 =
|
|
56
|
+
* none), `type` and `tags` index the const pool (`tags` −1 = none).
|
|
57
|
+
*
|
|
58
|
+
* `flags` is a BIT FIELD, not a boolean: bit 0 (`&1`) = grammar-owned explicit
|
|
59
|
+
* `captureTrivia`, bit 2 (`&4`) = the builder reads
|
|
60
|
+
* `triviaLog`, bit 3 (`&8`) = it reads `ctx.state`, bit 4 (`&16`) = the node has
|
|
61
|
+
* read fields, bit 5 (`&32`) = `collapse`, bit 6 (`&64`) = `unwrap`, bit 7
|
|
62
|
+
* (`&128`) = `trailingTrivia`. Bit 0 distinguishes capture a host may not
|
|
63
|
+
* suppress from a structural node's default capture. Bits 2 and 3 are resolved at ENCODE time
|
|
64
|
+
* from the reducer's declared arity by the same analysis codegen runs, and
|
|
65
|
+
* forced on under `hostMode: 'cst'`. The driver reads the bits and re-derives
|
|
66
|
+
* nothing.
|
|
67
|
+
*
|
|
68
|
+
* TWO ENCODERS SHARE THIS OPCODE and they do NOT agree on its length. The layout
|
|
69
|
+
* above is `encode.ts` / `exec.ts`. `encode-baseline.ts` / `exec-baseline.ts` emit
|
|
70
|
+
* the FOUR-word form `NODE b c flags` with bits 2 and 3 only, and refuse
|
|
71
|
+
* `collapse` / `unwrap` / `project` outright. Neither driver walks the stream by
|
|
72
|
+
* instruction length, so the divergence is contained — but read the pair you are
|
|
73
|
+
* in, not this comment alone. */
|
|
74
|
+
export declare const OP_NODE = 10;
|
|
75
|
+
/** `RULE r` — `r` indexes `prog.rules`. */
|
|
76
|
+
export declare const OP_RULE = 11;
|
|
77
|
+
/** `GATE cc c` — first-char gate: `cc` indexes a char class; then run `c`. */
|
|
78
|
+
export declare const OP_GATE = 12;
|
|
79
|
+
/** `NOT c` — zero-width negative lookahead. */
|
|
80
|
+
export declare const OP_NOT = 13;
|
|
81
|
+
/**
|
|
82
|
+
* `PEEK c fx` — zero-width positive lookahead. `fx` is the ASSERTION's own set,
|
|
83
|
+
* `['peek(<child tag>)']`, because `peek.ts:60` DISCARDS the body's expectation:
|
|
84
|
+
* a lookahead's failure is "the guard did not hold", not a request for whatever
|
|
85
|
+
* token the body happened to stop on.
|
|
86
|
+
*
|
|
87
|
+
* `encode-baseline.ts` / `exec-baseline.ts` emit and read the two-word form and
|
|
88
|
+
* are internally consistent; read the pair you are in.
|
|
89
|
+
*/
|
|
90
|
+
export declare const OP_PEEK = 14;
|
|
91
|
+
/** `LEAF f c` — `leaf()`: reduce, then record as a spanned leaf. */
|
|
92
|
+
export declare const OP_LEAF = 15;
|
|
93
|
+
/** `EMPTY` — matches the empty string. */
|
|
94
|
+
export declare const OP_EMPTY = 16;
|
|
95
|
+
/**
|
|
96
|
+
* Line-tracking twins of `LIT` / `RX` / `NODE`.
|
|
97
|
+
*
|
|
98
|
+
* This is the variant axis, made concrete. `trackLines` picks these rows when
|
|
99
|
+
* the TABLE IS BUILT; the driver holds a case for each and never asks whether
|
|
100
|
+
* line tracking is on. Same driver, different table contents — G5 exactly.
|
|
101
|
+
*/
|
|
102
|
+
export declare const OP_LIT_TRACK = 17;
|
|
103
|
+
export declare const OP_RX_TRACK = 18;
|
|
104
|
+
export declare const OP_NODE_TRACK = 19;
|
|
105
|
+
/**
|
|
106
|
+
* `SCOPE k c` — a `parser({ trivia })` / `rules({ trivia })` scope.
|
|
107
|
+
*
|
|
108
|
+
* `k` is the scope's trivia COMBINATOR in the const pool. The driver installs it
|
|
109
|
+
* on `ctx.trivia` for the duration and restores the outer one after, which is
|
|
110
|
+
* how the runtime's own `advanceTrivia` fast scanner gets reached — the same
|
|
111
|
+
* shared machinery the interpreter uses, not a second copy of it.
|
|
112
|
+
*/
|
|
113
|
+
export declare const OP_SCOPE = 20;
|
|
114
|
+
/**
|
|
115
|
+
* `EXPECT c e` — `expect()`. Never fails: on a failed child it yields a
|
|
116
|
+
* zero-width `ParseError` value carrying the expected set at `e`.
|
|
117
|
+
*/
|
|
118
|
+
export declare const OP_EXPECT = 21;
|
|
119
|
+
/**
|
|
120
|
+
* `SEQX f n c1 … cn` — a `transform()` whose child is a `sequence()`.
|
|
121
|
+
*
|
|
122
|
+
* That pair is the dominant shape in every grammar here (json is nine of them),
|
|
123
|
+
* and running it as two rows costs two switch dispatches and two JS call frames
|
|
124
|
+
* per rule invocation where the emitted code pays neither. Fusing them into one
|
|
125
|
+
* row halves that for the shape that occurs most.
|
|
126
|
+
*/
|
|
127
|
+
export declare const OP_SEQX = 22;
|
|
128
|
+
/**
|
|
129
|
+
* `SCAN s` — the scanning constructs. `s` indexes a `ScanSpec` in `prog.scans`.
|
|
130
|
+
*
|
|
131
|
+
* WAS `OP_CALL k`, which parked the LIVE combinator in the const pool. That ran
|
|
132
|
+
* correctly and made the program unprintable — `emitConst` refuses a live object
|
|
133
|
+
* — so no shipping grammar could be emitted at all: all four jess dialects use
|
|
134
|
+
* `scanTo()`, three of them also `balanced()`. The number is reused because
|
|
135
|
+
* `OP_CALL` has no other user and nothing in the const pool may be a live object
|
|
136
|
+
* any more; that is now an invariant rather than a convention.
|
|
137
|
+
*
|
|
138
|
+
* Neither construct needs a live object. Both are DESCRIBED by data:
|
|
139
|
+
*
|
|
140
|
+
* `scanTo()` is a sentinel, an ordered skipper list, and two flags. Sentinel
|
|
141
|
+
* and skippers are ordinary grammar-graph combinators, so they are
|
|
142
|
+
* encoded as ordinary table SUBTREES and referenced by offset.
|
|
143
|
+
* `balanced()` is an open string, a close string, an own-skip list and two
|
|
144
|
+
* flags. Its `_def` is its EAGER interior (per-call skip only) and
|
|
145
|
+
* its ambient re-resolution lives on `.parse`, so encoding it from
|
|
146
|
+
* `_def` builds the wrong parser — the spec carries the
|
|
147
|
+
* CONSTRUCTOR ARGUMENTS instead, and `balanced()` itself rebuilds.
|
|
148
|
+
*
|
|
149
|
+
* The driver does not re-implement either scan. `resolveTable`'s pool rebuilds
|
|
150
|
+
* each spec with the SHARED constructor (`scanTo`/`balanced`), handing it
|
|
151
|
+
* subtree-backed combinators, exactly as `triviaSpecs` rebuilds trivia with the
|
|
152
|
+
* shared `classifiedTrivia`. So there is one implementation of each, and the
|
|
153
|
+
* table carries only its arguments.
|
|
154
|
+
*/
|
|
155
|
+
export declare const OP_SCAN = 23;
|
|
156
|
+
/**
|
|
157
|
+
* `FIELD k c` — `field(name, parser)`. `k` indexes the NAME in the const pool.
|
|
158
|
+
*
|
|
159
|
+
* Runs the child and, on success, records `{ name, value, span }` into
|
|
160
|
+
* `ctx._fields` for the nearest enclosing `node()` to assemble. The recording is
|
|
161
|
+
* conditional on `ctx._fields` being live, exactly as `src/combinators/map.ts`
|
|
162
|
+
* has it — a field outside any field-reading node costs nothing.
|
|
163
|
+
*/
|
|
164
|
+
export declare const OP_FIELD = 24;
|
|
165
|
+
/**
|
|
166
|
+
* `LIT_CI k fx` — a case-insensitive `literal()`.
|
|
167
|
+
*
|
|
168
|
+
* Its own row rather than a flag on `LIT`, so the hot exact-match path keeps a
|
|
169
|
+
* bare `startsWith`. NOTE it yields the INPUT's casing, not the literal's —
|
|
170
|
+
* `literal.ts:86` returns `input.slice(pos, end)` — so a node built from it
|
|
171
|
+
* carries the source text. Returning the literal would silently normalise case.
|
|
172
|
+
*/
|
|
173
|
+
export declare const OP_LIT_CI = 27;
|
|
174
|
+
/** `LIT_CI_TRACK k fx` — the line-tracking twin of `LIT_CI`. */
|
|
175
|
+
export declare const OP_LIT_CI_TRACK = 28;
|
|
176
|
+
/**
|
|
177
|
+
* `TOKEN c` — `token()`. Clears trivia AND every capture sink for the child,
|
|
178
|
+
* then contributes ONE leaf spanning the whole match.
|
|
179
|
+
*
|
|
180
|
+
* Was `OP_CALL` (a live combinator in the const pool), which ran correctly but
|
|
181
|
+
* made the table unprintable — `emitConst` refuses non-serialisable entries, so
|
|
182
|
+
* no grammar using `token()` could be emitted as a module. Nothing about it
|
|
183
|
+
* needs a live object: it is save / clear / run / restore / one leaf.
|
|
184
|
+
*/
|
|
185
|
+
export declare const OP_TOKEN = 29;
|
|
186
|
+
/**
|
|
187
|
+
* `SCOPE_CAP k c` — a `parser({ trivia, captureTrivia: true })` scope. Identical
|
|
188
|
+
* operands to `SCOPE`; it additionally sets `ctx.captureTrivia` for the child.
|
|
189
|
+
*
|
|
190
|
+
* A SEPARATE OPCODE rather than a third operand on `SCOPE`, for two reasons.
|
|
191
|
+
* Widening an instruction means every walker that knows its shape has to learn
|
|
192
|
+
* the new one, and there is no central arity table here to change in one place.
|
|
193
|
+
* And the driver should SELECT this piece, not test a flag inside the scope
|
|
194
|
+
* piece — capture is fixed for the whole parse, so it is an assembly decision.
|
|
195
|
+
*
|
|
196
|
+
* The interpreter's equivalent is `grammar.ts:129`:
|
|
197
|
+
* `if (opts.captureTrivia || _ctx?.captureTrivia) ctx.captureTrivia = true`.
|
|
198
|
+
* Note the INHERITANCE — an inner scope does not switch capture back off, which
|
|
199
|
+
* is why this restores the saved value rather than writing `false`.
|
|
200
|
+
*/
|
|
201
|
+
export declare const OP_SCOPE_CAP = 30;
|
|
202
|
+
/**
|
|
203
|
+
* `WITHCTX k c` — `withCtx(extra, c)`. `k` is `extra` in the const pool.
|
|
204
|
+
*
|
|
205
|
+
* SAVE / RESTORE, matching `withCtx.ts`. Both used to CLONE the context, which
|
|
206
|
+
* scoped far more than the state: every scalar the child wrote on `ctx` landed
|
|
207
|
+
* on the clone and died with it, `_fe` / `_fx` included, so a failing `withCtx`
|
|
208
|
+
* subtree contributed nothing to the parent's expected set. That isolation was
|
|
209
|
+
* an implementation detail nobody asked for, not the combinator's contract, so
|
|
210
|
+
* it was fixed at the source rather than mirrored here.
|
|
211
|
+
*/
|
|
212
|
+
export declare const OP_WITHCTX = 31;
|
|
213
|
+
/**
|
|
214
|
+
* `GUARD f e` — `gate(predicate)`. Zero-width: runs `fns[f]` against
|
|
215
|
+
* `ctx.state` and yields `null` at `pos`, or fails with the expected set at `e`.
|
|
216
|
+
*
|
|
217
|
+
* NOT `OP_GATE`, which is the first-CHAR gate — different question, different
|
|
218
|
+
* operand (a char class, not a predicate). The names are close because the
|
|
219
|
+
* combinator was renamed to `gate()` at the API surface while its def tag stayed
|
|
220
|
+
* `guard`; the opcode follows the TAG, since that is what the encoder switches on.
|
|
221
|
+
*
|
|
222
|
+
* Its first set is `any` (a state predicate cannot narrow the input), so a
|
|
223
|
+
* `gate()` leading a choice arm poisons that arm's first-char dispatch. That is
|
|
224
|
+
* a grammar-authoring caveat, not a lowering one.
|
|
225
|
+
*/
|
|
226
|
+
export declare const OP_GUARD = 32;
|
|
227
|
+
/**
|
|
228
|
+
* `ADJ neg kinds fx` — `adjacent()` / `notAdjacent()`. `neg` is 1 for
|
|
229
|
+
* `notAdjacent`, `kinds` indexes the category filter (a `readonly string[]`) in
|
|
230
|
+
* the const pool or is −1, and `fx` is the expected set.
|
|
231
|
+
*
|
|
232
|
+
* A BOUNDARY TEST, NOT A TERM, and that is the whole reason it is its own
|
|
233
|
+
* opcode rather than a zero-width leaf like `OP_GUARD`. It asks whether trivia
|
|
234
|
+
* sat between the PREVIOUS term and here, so it must be evaluated at the
|
|
235
|
+
* sequence cursor — BEFORE the ambient trivia scan that precedes an ordinary
|
|
236
|
+
* non-first term. A piece handed the post-scan position would find the gap
|
|
237
|
+
* already consumed and answer "adjacent" every time, silently: `adjacent()`
|
|
238
|
+
* would become a no-op and `notAdjacent()` a guaranteed failure. So the SEQ
|
|
239
|
+
* pieces read this row at assembly and run the test themselves, exactly as
|
|
240
|
+
* `sequence()` forks `parseAdjacent` (combinators/sequence.ts:118) and as
|
|
241
|
+
* codegen lowers it at the boundary (codegen.ts:1765).
|
|
242
|
+
*
|
|
243
|
+
* Reached as a row in its own right only where there IS no boundary — a bare
|
|
244
|
+
* choice arm, a `node()` body, a repeat item. The interpreter throws there
|
|
245
|
+
* (adjacency.ts) rather than answering a question that was never asked, and so
|
|
246
|
+
* does the driver: same sentence, from `adjacencyMisuse`.
|
|
247
|
+
*
|
|
248
|
+
* The kind filter is resolved against the ACTIVE trivia table at parse time,
|
|
249
|
+
* matching the interpreter — a scope can swap the table, so it is not an
|
|
250
|
+
* assembly-time fact. (Codegen resolves it at COMPILE time and therefore
|
|
251
|
+
* reports an unlabelled table or an unknown category earlier; both engines
|
|
252
|
+
* raise the same `TypeError`, only the moment differs.)
|
|
253
|
+
*/
|
|
254
|
+
export declare const OP_ADJ = 33;
|
|
255
|
+
/**
|
|
256
|
+
* `GREEDY sup n w1 a1 … wn an` — `choice(strategy = greedyClassify)`.
|
|
257
|
+
*
|
|
258
|
+
* NOT a choice. `choice()` auto-selects this strategy (choice.ts:186-202) for the
|
|
259
|
+
* canonical identifier-vs-keyword shape — ONE regex arm that subsumes every other
|
|
260
|
+
* arm, all of which are literals — and it runs a DIFFERENT execution, not a
|
|
261
|
+
* different arm order: the regex arm runs, and then the match is RE-ATTRIBUTED by
|
|
262
|
+
* string equality to a literal arm, whose transform chain is what produces the
|
|
263
|
+
* value (choice.ts:124-136). Encoding it as an ordered `OP_CHOICE` would let the
|
|
264
|
+
* regex arm win every time; the parse would still succeed and only the VALUE and
|
|
265
|
+
* the tree would move. So it gets its own row.
|
|
266
|
+
*
|
|
267
|
+
* `sup` is the super arm's offset, `n` the number of classified literals, and
|
|
268
|
+
* each pair is `(const-pool index of the literal string, that arm's offset)`.
|
|
269
|
+
*
|
|
270
|
+
* The literal arm is RE-RUN at `pos` rather than having its transform chain
|
|
271
|
+
* applied to a known value, and the two are the same thing here: the classified
|
|
272
|
+
* word IS the arm's literal, so `literal()` re-matches at `pos` over exactly
|
|
273
|
+
* `[pos, END)` and every transform then sees the same `(value, span)` pair the
|
|
274
|
+
* interpreter's `applyTransforms` passes. `getCoreLiteralValue` admits only a
|
|
275
|
+
* case-SENSITIVE literal under `transform` wrappers, so the re-run cannot fail
|
|
276
|
+
* and cannot land at a different end. What it does do is push a SECOND CST leaf,
|
|
277
|
+
* which is why the capture sinks are rolled back to the pre-`sup` mark first —
|
|
278
|
+
* leaving exactly one leaf, with the same text and span the interpreter's kept
|
|
279
|
+
* regex leaf has.
|
|
280
|
+
*
|
|
281
|
+
* On a failed `sup` the failure propagates VERBATIM (the regex's own expected
|
|
282
|
+
* set), not the union of the arms — choice.ts:126 returns `superResult` itself,
|
|
283
|
+
* and codegen's `emitGreedyClassify` reports `deriveExpected(superParser)`.
|
|
284
|
+
*/
|
|
285
|
+
export declare const OP_GREEDY = 34;
|
|
286
|
+
/**
|
|
287
|
+
* `REJECT c n t1 o1 … tn on` — one choice arm plus its `autoNot` checks.
|
|
288
|
+
*
|
|
289
|
+
* `autoNot` is the OTHER thing `choice()` computes on its own (choice.ts:55,
|
|
290
|
+
* 325-346): for a literal arm, the inline lookahead that a LATER arm — a longer
|
|
291
|
+
* literal with this one as a prefix, or a regex that subsumes it — would have
|
|
292
|
+
* consumed more. It runs AFTER the arm has already succeeded and can still
|
|
293
|
+
* reject it, so a matched arm loses and a later arm wins (choice.ts:160-164).
|
|
294
|
+
* Ignoring it lowers `if` out of `iffy` and the parse still succeeds.
|
|
295
|
+
*
|
|
296
|
+
* `c` is the arm's offset; each check is a pair `(kind, operand)` — kind 0 is
|
|
297
|
+
* `startsWith`, operand a const-pool string; kind 1 is `firstSet`, operand a
|
|
298
|
+
* char-class index. Both are tested at the arm's END, mirroring `autoNotFires`.
|
|
299
|
+
*
|
|
300
|
+
* Rejection returns `FAIL` and CLEARS `_fc`, because the interpreter's rejection
|
|
301
|
+
* is a `continue` — "pretend this arm was never entered" — whereas an ordinary
|
|
302
|
+
* failing arm's committed flag cuts the whole choice. The enclosing choice does
|
|
303
|
+
* the capture-sink rollback, exactly as it does for a failing arm.
|
|
304
|
+
*
|
|
305
|
+
* A site with any `autoNot` can never take the O(1) first-char dispatch: a check
|
|
306
|
+
* exists only when a later arm shares the arm's leading character, so those two
|
|
307
|
+
* arms' classes intersect and `resolveDispatch` reports the site non-exclusive.
|
|
308
|
+
*/
|
|
309
|
+
export declare const OP_REJECT = 35;
|
|
310
|
+
/**
|
|
311
|
+
* `ARMGATE f c e` — one choice arm plus its PER-ARM state gate,
|
|
312
|
+
* `choice({ gate, combinator })`. `f` indexes the predicate in `prog.fns`, `c` is
|
|
313
|
+
* the arm's offset, and `e` is the arm's own expected set.
|
|
314
|
+
*
|
|
315
|
+
* NOT `OP_GUARD`, and the difference is the entire reason the option exists.
|
|
316
|
+
* `gate()` is a zero-width TERM whose first set is `any`, so leading an arm with
|
|
317
|
+
* one replaces that arm's first set and collapses the whole choice from O(1)
|
|
318
|
+
* first-char dispatch to the ordered `firstMatch` loop (docs/guide/
|
|
319
|
+
* first-char-gating.md lists that as a known gating defect). This row wraps the
|
|
320
|
+
* arm INSTEAD of sitting inside it, so the encoder still reads the arm's own
|
|
321
|
+
* first set for `disp` and the site keeps its dispatch slot.
|
|
322
|
+
*
|
|
323
|
+
* A blocked arm is SKIPPED, not failed — `choice.ts:150` is `continue`. The row
|
|
324
|
+
* therefore clears `_fc` on the gate-false path exactly as `OP_REJECT` does:
|
|
325
|
+
* "pretend this arm was never entered", so no cut it might have raised survives
|
|
326
|
+
* to cut the choice. It still reports `e`, because the OTHER path a blocked arm
|
|
327
|
+
* can be reached by is first-char dispatch, where skip-and-retry and
|
|
328
|
+
* fail-the-choice are the same thing (choice.ts:23-34, :100-105) and the
|
|
329
|
+
* interpreter answers with `deriveExpected(arm)` — this set.
|
|
330
|
+
*
|
|
331
|
+
* The predicate is a live function, like `OP_GUARD`'s, so a grammar using one is
|
|
332
|
+
* runtime-only for `emitTableModule` unless `fnSources` are supplied.
|
|
333
|
+
*/
|
|
334
|
+
export declare const OP_ARMGATE = 36;
|
|
335
|
+
/**
|
|
336
|
+
* `LIVE f` — RUN A HAND-WRITTEN COMBINATOR through its own `.parse`. `f` indexes
|
|
337
|
+
* the combinator in `prog.fns`.
|
|
338
|
+
*
|
|
339
|
+
* NOT the old `OP_CALL` (numbers 23 and 29 both record having been it): that row
|
|
340
|
+
* parked live combinators for `scanTo`/`balanced`/`token` in the CONST pool, and
|
|
341
|
+
* the fix was to describe those constructs AS DATA, which they are. This is the
|
|
342
|
+
* opposite case and the only one left: `Combinator` is a PUBLIC interface, so a
|
|
343
|
+
* caller can hand `compile()` a parser whose `_def.tag` no encoder will ever
|
|
344
|
+
* know. There is nothing to describe — the behaviour lives in a closure the
|
|
345
|
+
* library never sees.
|
|
346
|
+
*
|
|
347
|
+
* It exists because codegen accepts exactly this and delegates at run time
|
|
348
|
+
* (`compiler/codegen.ts`, `emitRuntimeFallback`'s `_rp[i].parse(...)` row). The
|
|
349
|
+
* encoder used to throw `UnsupportedConstruct`, so the table lowering REJECTED
|
|
350
|
+
* grammars the source lowering compiles, and the two lowerings must accept the
|
|
351
|
+
* same language.
|
|
352
|
+
*
|
|
353
|
+
* The cost is stated, not hidden: a live combinator is not data, so a program
|
|
354
|
+
* holding one is `runtimeOnly` — it runs, and `emitTableModule` refuses to print
|
|
355
|
+
* it BY NAME. Codegen degrades identically (a non-empty `runtimeParsers` makes
|
|
356
|
+
* `inlineExpression` null). It never appears for a construct the library itself
|
|
357
|
+
* builds; reaching it means the encoder met a foreign `_def`.
|
|
358
|
+
*
|
|
359
|
+
* The child result is the real interpreter's, so `expected`/`span` propagate
|
|
360
|
+
* verbatim and its `committed` flag is copied into `_fc`, as codegen's does.
|
|
361
|
+
*/
|
|
362
|
+
export declare const OP_LIVE = 37;
|
|
363
|
+
/**
|
|
364
|
+
* `ATTEMPT c` — `attempt()`, the transactional ordered-choice arm.
|
|
365
|
+
*
|
|
366
|
+
* WAS A TRANSPARENT WRAPPER (`case 'attempt': return this.node(d.parser).ip`),
|
|
367
|
+
* which is correct for exactly one placement — an arm of an `OP_CHOICE`, whose
|
|
368
|
+
* per-arm loop already saves and restores the eight capture sinks. Anywhere else
|
|
369
|
+
* — a `sequence()` term, a repeat item, a `node()` body — a failed transaction
|
|
370
|
+
* left its CST leaves, raw children, fields, recovery diagnostics and trivia-log
|
|
371
|
+
* entries behind, and reported the failure at the INNER position rather than
|
|
372
|
+
* re-anchored at the transaction's entry. Both are `attempt()`'s whole contract
|
|
373
|
+
* (`combinators/attempt.ts`), not a choice-arm detail.
|
|
374
|
+
*
|
|
375
|
+
* One child operand and no expected-set operand: on a non-committed inner
|
|
376
|
+
* failure the row keeps the inner's `_fx` VERBATIM and only re-anchors `_fe` to
|
|
377
|
+
* `pos`, exactly as `attempt.ts` returns `{ expected: result.expected, span:
|
|
378
|
+
* { start: pos, end: pos } }`. A committed failure propagates untouched — the
|
|
379
|
+
* rollback still happens, the re-anchor does not.
|
|
380
|
+
*
|
|
381
|
+
* The interpreter's first-set fail-fast guard is NOT lowered. It is an
|
|
382
|
+
* optimisation that reports `deriveExpected(parser)` in place of the start-fail
|
|
383
|
+
* the inner would have produced; running the inner produces that set for real,
|
|
384
|
+
* so the row is behaviourally the guard's post-condition without the second
|
|
385
|
+
* definition of what the inner expects.
|
|
386
|
+
*/
|
|
387
|
+
export declare const OP_ATTEMPT = 38;
|
|
388
|
+
/**
|
|
389
|
+
* `LABEL c fx` — `label(name, parser)`. `fx` is the one-element set `[name]`.
|
|
390
|
+
*
|
|
391
|
+
* WAS A TRANSPARENT WRAPPER, and a label is not transparent: `map.ts:84` returns
|
|
392
|
+
* `{ expected: [name], span: result.span }` on a failed child, i.e. it REPLACES
|
|
393
|
+
* the child's expected set and keeps the child's span. Dropping the row dropped
|
|
394
|
+
* the whole point of the combinator — a table lowering reported
|
|
395
|
+
* `['/[a-z]+/']` where the grammar had said `label('identifier', …)`, so every
|
|
396
|
+
* labelled diagnostic in every grammar regressed to raw regex source.
|
|
397
|
+
*
|
|
398
|
+
* `_fe` IS NOT TOUCHED, deliberately: `label()` keeps `result.span`, so the
|
|
399
|
+
* failure stays where the child put it.
|
|
400
|
+
*/
|
|
401
|
+
export declare const OP_LABEL = 39;
|
|
402
|
+
/**
|
|
403
|
+
* `COV c id on` — A GRAMMAR-COVERAGE COUNTER SITE. Emitted ONLY into a table
|
|
404
|
+
* encoded with `TableSettings.coverage`; an ordinary table contains no such row,
|
|
405
|
+
* which is why turning coverage off costs an ordinary build exactly zero bytes.
|
|
406
|
+
*
|
|
407
|
+
* `c` is the wrapped child's offset — deliberately at `ip + 1`, the slot every
|
|
408
|
+
* other single-child wrapper uses, so `collapseIndirection`, `inspect.ts` and
|
|
409
|
+
* `exec.ts` each gain this opcode by adding it to an existing `case` list rather
|
|
410
|
+
* than by growing a new shape. `id` indexes `prog.cov`, the definition pool.
|
|
411
|
+
*
|
|
412
|
+
* `on` is 0 for ENTRY and 1 for SUCCESS, and it is read at ASSEMBLY TIME, never
|
|
413
|
+
* per parse: `assemble.ts` picks one of two closures from it, exactly as it picks
|
|
414
|
+
* pieces from `RunCfg`. The two phases are not decoration — the source lowering
|
|
415
|
+
* credits a RULE on entry (`codegen.ts:4529`) and a choice arm, dispatch arm or
|
|
416
|
+
* label only once it has SUCCEEDED, and a table that credited all four alike
|
|
417
|
+
* would report a different denominator's worth of hits than the engine it is a
|
|
418
|
+
* drop-in for.
|
|
419
|
+
*
|
|
420
|
+
* THE ROW IS WHY THIS IS NOT A SIDE TABLE keyed by code offset. `encode.ts`
|
|
421
|
+
* memoises by combinator IDENTITY, so one `g.X` reference object that is an arm
|
|
422
|
+
* of three different choices is ONE row — and an offset→id map would have to
|
|
423
|
+
* credit all three arms whenever any one of them ran. A wrapper row is per SITE,
|
|
424
|
+
* which is the granularity the IDs are minted at.
|
|
425
|
+
*/
|
|
426
|
+
export declare const OP_COV = 40;
|
|
427
|
+
/**
|
|
428
|
+
* `DISPATCH sel d other otherRouted n a1 … an` — `dispatch()`.
|
|
429
|
+
*
|
|
430
|
+
* `sel` is the selector's offset, `d` indexes a dispatch table in `prog.dsp`,
|
|
431
|
+
* `other` is the `otherwise()` offset (or −1), `otherRouted` is 1 when the
|
|
432
|
+
* fallback consumes the routed token, and `a1…an` are the arm offsets. Arm
|
|
433
|
+
* `usesRouted` bits live in the `dsp` entry beside the key maps.
|
|
434
|
+
*
|
|
435
|
+
* The selector runs ONCE; the key it returns picks the arm. That is the whole
|
|
436
|
+
* point of `dispatch()` over a `choice()` of arms that each re-parse the opener.
|
|
437
|
+
*/
|
|
438
|
+
export declare const OP_DISPATCH = 25;
|
|
439
|
+
/**
|
|
440
|
+
* `ROUTED fallback` — `routed()`. Yields the token the enclosing `dispatch()`
|
|
441
|
+
* already consumed, so the selected branch can own it. `fallback` is an offset
|
|
442
|
+
* or −1; it runs when there is no routed token at this position.
|
|
443
|
+
*/
|
|
444
|
+
export declare const OP_ROUTED = 26;
|
|
445
|
+
export declare const OP_NAMES: Record<number, string>;
|
|
446
|
+
//# sourceMappingURL=ops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ops.d.ts","sourceRoot":"","sources":["../../src/table/ops.ts"],"names":[],"mappings":"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"}
|