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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ParseContext, ParseFail } from '../types.ts';
|
|
1
|
+
import type { Combinator, ParseContext, ParseFail } from '../types.ts';
|
|
2
2
|
/**
|
|
3
3
|
* Result of scanning trivia: the position after it, plus a `commit()` that
|
|
4
4
|
* records the matched trivia tokens into the active rawChildren collector.
|
|
@@ -20,9 +20,17 @@ export type TriviaRollbackMark = {
|
|
|
20
20
|
log: number;
|
|
21
21
|
rootLog: number;
|
|
22
22
|
};
|
|
23
|
+
export type FastTriviaScanner = (input: string, cur: number) => number;
|
|
23
24
|
/** True when trivia recording must be deferred until the following term commits. */
|
|
24
25
|
export declare function needsDeferredTriviaCommit(ctx: ParseContext): boolean;
|
|
25
26
|
export declare function saveTriviaMark(ctx: ParseContext): TriviaRollbackMark;
|
|
27
|
+
/**
|
|
28
|
+
* Trivia rollback from SCALAR marks — the allocation-free twin of
|
|
29
|
+
* `rollbackTrivia`. See `rollbackCstCaptureAt`; `saveTriviaMark` allocates twice
|
|
30
|
+
* (this wrapper plus the CST mark it delegates to) and the table driver took one
|
|
31
|
+
* per sequence term and per repetition item.
|
|
32
|
+
*/
|
|
33
|
+
export declare function rollbackTriviaAt(ctx: ParseContext, raw: number, tlog: number, leaves: number, fields: number, errors: number, log: number, rootLog: number): void;
|
|
26
34
|
export declare function rollbackTrivia(ctx: ParseContext, mark: TriviaRollbackMark): void;
|
|
27
35
|
/**
|
|
28
36
|
* A ZERO-WIDTH LOOKAHEAD's mark: everything `saveTriviaMark` covers, plus the
|
|
@@ -56,9 +64,40 @@ export declare function advanceTrivia(input: string, cur: number, ctx: ParseCont
|
|
|
56
64
|
* position after the trivia (or `cur` if none) and a `commit()` to record it.
|
|
57
65
|
*/
|
|
58
66
|
export declare function scanTrivia(input: string, cur: number, ctx: ParseContext): TriviaScan;
|
|
67
|
+
/**
|
|
68
|
+
* Skip trivia at `cur` through an INSTALLED scanner, recording it immediately.
|
|
69
|
+
*
|
|
70
|
+
* The table drivers install a scanner only for UNLABELLED trivia with
|
|
71
|
+
* `trackLines` off, and that is exactly the case where the deferred path's whole
|
|
72
|
+
* commit is the single row `(cur, end)` — so there is nothing to defer, and the
|
|
73
|
+
* `{ end, commit }` pair plus its closure that `scanTrivia(…).commit()` allocated
|
|
74
|
+
* on EVERY sequence term of EVERY capturing grammar buy nothing. This is that
|
|
75
|
+
* branch with the allocations removed, kept here so recording has one home.
|
|
76
|
+
*/
|
|
77
|
+
export declare function skipTriviaScanned(s: FastTriviaScanner, input: string, cur: number, ctx: ParseContext): number;
|
|
59
78
|
/**
|
|
60
79
|
* Consume trivia at `cur`, recording it immediately. For callers that always
|
|
61
80
|
* accept the trivia between two committed terms (e.g. sequence/sepBy).
|
|
62
81
|
*/
|
|
63
82
|
export declare function consumeTrivia(input: string, cur: number, ctx: ParseContext): number;
|
|
83
|
+
/**
|
|
84
|
+
* End of the trivia run at `cur`, WITHOUT recording any of it.
|
|
85
|
+
*
|
|
86
|
+
* The read-only twin of `consumeTrivia`, for a zero-width ASSERTION that wants the
|
|
87
|
+
* adjacency fact and must leave no trace: the deferred path returns a scan whose
|
|
88
|
+
* `commit()` is simply never called, so nothing lands in any buffer and there is
|
|
89
|
+
* nothing to roll back. The following term re-scans the same gap and owns the
|
|
90
|
+
* commit/rewind decision exactly as if the assertion were not there.
|
|
91
|
+
*/
|
|
92
|
+
export declare function probeTriviaEnd(input: string, cur: number, ctx: ParseContext): number;
|
|
93
|
+
/**
|
|
94
|
+
* The specialised scanner for a trivia combinator, or null when its shape has no
|
|
95
|
+
* lowering. Memoized on the combinator.
|
|
96
|
+
*
|
|
97
|
+
* EXPORTED because G5's leaf swap needs it at TABLE-BUILD time: the table driver
|
|
98
|
+
* resolves the scanner once, per trivia entry, and installs the closure at scope
|
|
99
|
+
* entry — where the generic path called this (a WeakMap lookup) plus a chain of
|
|
100
|
+
* option branches on EVERY sequence term.
|
|
101
|
+
*/
|
|
102
|
+
export declare function fastTriviaScanner(trivia: Combinator<unknown>): FastTriviaScanner | null;
|
|
64
103
|
//# sourceMappingURL=trivia-skip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trivia-skip.d.ts","sourceRoot":"","sources":["../../src/combinators/trivia-skip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"trivia-skip.d.ts","sourceRoot":"","sources":["../../src/combinators/trivia-skip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAe,MAAM,aAAa,CAAA;AAmBnF;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,CAAA;AAE5D,iEAAiE;AACjE,MAAM,MAAM,kBAAkB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAG5I,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;AAmBtE,oFAAoF;AACpF,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAEpE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,YAAY,GAAG,kBAAkB,CAWpE;A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M,EAAE,GAAG,EAAE,YAAY,GAAG,MAAM,CAcpF;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,iBAAiB,GAAG,IAAI,CAevF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withCtx.d.ts","sourceRoot":"","sources":["../../src/combinators/withCtx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAyC,MAAM,aAAa,CAAA;AAEpF;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"withCtx.d.ts","sourceRoot":"","sources":["../../src/combinators/withCtx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAyC,MAAM,aAAa,CAAA;AAEpF;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAgChF"}
|
|
@@ -0,0 +1,104 @@
|
|
|
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 TableRuleMapOptions } from '../table/compile-rule-map.ts';
|
|
5
|
+
import type { TableProgram, TableRule } from '../table/program.ts';
|
|
6
|
+
/**
|
|
7
|
+
* `compileLinkable()` FOR THE TABLE LOWERING — `linkable()` produces TABLES too.
|
|
8
|
+
*
|
|
9
|
+
* ── WHAT `compileLinkable` ACTUALLY RETURNS, AND WHY NONE OF IT TRANSFERS ─────
|
|
10
|
+
* `LinkablePieces` is `prelude` / `ruleFns` / `wrappers` / `firstSets` /
|
|
11
|
+
* `firstSetRecipes` / `nullable` / `deps` / `needsEmptyTl` — every field of it is
|
|
12
|
+
* SOURCE TEXT or an input to resolving source text. It exists because
|
|
13
|
+
* source-lowering composition is a TEXTUAL splice: `fusedBody()` concatenates
|
|
14
|
+
* namespaced preludes, picks a winning `_r_<Name>` per name, and substitutes
|
|
15
|
+
* `@FS:` dispatch placeholders with the winner's first-set condition. A table has
|
|
16
|
+
* no text to splice and no placeholders to resolve, so porting those fields would
|
|
17
|
+
* be porting the mechanism rather than the capability.
|
|
18
|
+
*
|
|
19
|
+
* The capability is: a piece must be RUNNABLE on its own, and COMPOSABLE with
|
|
20
|
+
* other pieces. This artifact carries exactly those two things.
|
|
21
|
+
*
|
|
22
|
+
* `prog` / `rules` — the piece AS A TABLE. Present whenever the piece is
|
|
23
|
+
* self-contained. This is the ruling: a `linkable()`
|
|
24
|
+
* artifact is a table, not a bag of compiled functions.
|
|
25
|
+
* `ir` — the piece's combinator graph, serialized. This is the
|
|
26
|
+
* composable half, and it is NOT new machinery: the plugin
|
|
27
|
+
* already carries pieces as IR (`plugin/index.ts:1772`) and
|
|
28
|
+
* the linker already re-lowers them (`linker.ts:640`,
|
|
29
|
+
* `compileLinkable(evalRuleMapIR(p.ir), …)`).
|
|
30
|
+
*
|
|
31
|
+
* ── WHY THAT MAKES COMPOSITION THE EASY KIND ─────────────────────────────────
|
|
32
|
+
* The open question was whether table-to-table composition has to merge two
|
|
33
|
+
* ALREADY-ENCODED programs — relocating code offsets and merging const, fn,
|
|
34
|
+
* class, expected and dispatch pools. It does not, as long as every piece
|
|
35
|
+
* carries its IR: the composer evaluates each piece's IR back to a rule map,
|
|
36
|
+
* merges the maps (later pieces overriding earlier names, which is what
|
|
37
|
+
* `compose()` means), and calls `encodeTable` ONCE over the merged map. One
|
|
38
|
+
* encode, no relocation, and the result is byte-for-byte the table the merged
|
|
39
|
+
* grammar would have produced if it had been written as one `rules()` call.
|
|
40
|
+
*
|
|
41
|
+
* The relocation route is only forced for a piece with NO IR, which is why `ir`
|
|
42
|
+
* being null is reported here as a first-class fact rather than folded into a
|
|
43
|
+
* bare `null` return.
|
|
44
|
+
*
|
|
45
|
+
* ── THE HOLE CASE IS NOT REFUSED ─────────────────────────────────────────────
|
|
46
|
+
* A piece that references a rule it does not define (`g.Value` with no
|
|
47
|
+
* `.define()` — `hasExternalRuleRef`'s SHARED-SHAPE signature) cannot be encoded
|
|
48
|
+
* standalone: `encodeTable` resolves a `lazy` by calling its thunk, and that
|
|
49
|
+
* thunk throws. Such a piece gets `prog: null` and `rules: null` and keeps its
|
|
50
|
+
* `ir`, which is the correct answer rather than a refusal: a shape with a hole
|
|
51
|
+
* is not a parser in ANY lowering, and it composes through the merge above,
|
|
52
|
+
* where the hole is filled by whichever piece supplies the name.
|
|
53
|
+
*/
|
|
54
|
+
export type LinkableTableOptions = Omit<TableRuleMapOptions, 'runtimeRef'>;
|
|
55
|
+
export type LinkableTable = {
|
|
56
|
+
/**
|
|
57
|
+
* The parseman version that produced this artifact — the same ARTIFACT VERSION
|
|
58
|
+
* LOCK `LinkablePieces.v` carries, for the same reason: artifacts are
|
|
59
|
+
* version-locked and the format has no back-compat read path.
|
|
60
|
+
*/
|
|
61
|
+
v: string;
|
|
62
|
+
ns: string;
|
|
63
|
+
/** Local rule names, external (undefined) entries already dropped. */
|
|
64
|
+
keys: string[];
|
|
65
|
+
/** Rule names this piece REFERENCES but does not define. */
|
|
66
|
+
external: string[];
|
|
67
|
+
/** The piece as a table — null when it has holes (see `external`). */
|
|
68
|
+
prog: TableProgram | null;
|
|
69
|
+
/** The runnable form of `prog` — null for the same reason. */
|
|
70
|
+
rules: Record<string, TableRule> | null;
|
|
71
|
+
/** The emitted expression for `prog`, or null when there is no `prog`. */
|
|
72
|
+
replacement: string | null;
|
|
73
|
+
/**
|
|
74
|
+
* The piece's combinator graph, serialized — the COMPOSABLE half. Null when
|
|
75
|
+
* the map cannot be faithfully serialized (a callback with no captured
|
|
76
|
+
* source); a null here is what would force composition to merge encoded
|
|
77
|
+
* programs instead of merging rule maps.
|
|
78
|
+
*/
|
|
79
|
+
ir: string | null;
|
|
80
|
+
/**
|
|
81
|
+
* The piece's rule map as LIVE COMBINATORS — present only for an in-process
|
|
82
|
+
* artifact, never serialized.
|
|
83
|
+
*
|
|
84
|
+
* `ir` is the portable composable half, and a grammar BUILT AT RUNTIME often has no
|
|
85
|
+
* `ir` at all (a live callback has no recoverable source). Such a piece still has to
|
|
86
|
+
* compose, and in-process it can: the combinators themselves are right there. Without
|
|
87
|
+
* this the runtime `compose([linkable(g)])` refused a grammar the source lowering
|
|
88
|
+
* composed happily.
|
|
89
|
+
*/
|
|
90
|
+
ruleMap: ReadonlyArray<readonly [string, Combinator<unknown>]>;
|
|
91
|
+
hostMode: HostMode;
|
|
92
|
+
hostBranchElided: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Whether any rule carries a DIRECT builder, and whether the piece is free of
|
|
95
|
+
* semantic reduction. `composeLeaf` gates on both, and they are predicates over the
|
|
96
|
+
* combinator graph rather than products of lowering it — so they belong on the
|
|
97
|
+
* artifact regardless of which lowering produced it.
|
|
98
|
+
*/
|
|
99
|
+
hasDirectBuilders: boolean;
|
|
100
|
+
isRecognitionOnly: boolean;
|
|
101
|
+
reflection: GrammarReflection;
|
|
102
|
+
};
|
|
103
|
+
export declare function compileLinkableTable(ruleMapArg: ReadonlyArray<readonly [string, Combinator<unknown>]>, ns: string, opts?: LinkableTableOptions): LinkableTable | null;
|
|
104
|
+
//# sourceMappingURL=compile-linkable-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-linkable-table.d.ts","sourceRoot":"","sources":["../../src/compiler/compile-linkable-table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO,EAA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MAAM,EACV,IAAI,GAAE,oBAAyB,GAC9B,aAAa,GAAG,IAAI,CAwDtB"}
|
|
@@ -27,8 +27,6 @@ export type DegradationLevel = 'off' | 'warn' | 'error';
|
|
|
27
27
|
export type DegradationCode =
|
|
28
28
|
/** A node build's formal parameter list could not be read → all capture tiers kept. */
|
|
29
29
|
'build-arity-unconfirmed'
|
|
30
|
-
/** A node build looks like an `mk(...)` wrapper but did not match → no inline-mk. */
|
|
31
|
-
| 'mk-inline-missed'
|
|
32
30
|
/** A composed/carried piece is an opaque artifact → its rules were not analysed. */
|
|
33
31
|
| 'opaque-artifact'
|
|
34
32
|
/** A coverage-definition request could not read the grammar → empty is NOT a zero. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"degradation.d.ts","sourceRoot":"","sources":["../../src/compiler/degradation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,2BAA2B;AAC3B,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAA;AAEvD,oDAAoD;AACpD,MAAM,MAAM,eAAe;AACzB,uFAAuF;AACrF,yBAAyB;AAC3B,
|
|
1
|
+
{"version":3,"file":"degradation.d.ts","sourceRoot":"","sources":["../../src/compiler/degradation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,2BAA2B;AAC3B,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAA;AAEvD,oDAAoD;AACpD,MAAM,MAAM,eAAe;AACzB,uFAAuF;AACrF,yBAAyB;AAC3B,oFAAoF;GAClF,iBAAiB;AACnB,sFAAsF;GACpF,kCAAkC,CAAA;AAEtC;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,CAAA;AAEjD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,eAAe,CAAA;IACrB,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,4FAA4F;IAC5F,KAAK,EAAE,MAAM,CAAA;IACb,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAA;IACf,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAA;IAClB,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,+DAA+D;AAC/D,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CAExD;AAUD,sFAAsF;AACtF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,EAAE,CAkBzE;AAkBD,8DAA8D;AAC9D,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C;AAED,4EAA4E;AAC5E,wBAAgB,qBAAqB,IAAI,WAAW,EAAE,CAGrD;AAED,6EAA6E;AAC7E,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAOrE;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,CAKrF;AA2BD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI,CAatD;AAKD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,4BAA4B,IAAI,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAsBxE;AAED,kDAAkD;AAClD,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED,qFAAqF;AACrF,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD"}
|
|
@@ -17,6 +17,19 @@ export declare function parserHasOwnFields(p: Combinator<unknown>, seen?: Set<Co
|
|
|
17
17
|
* shape returns `true` (keep the frame) — we only elide when provably safe.
|
|
18
18
|
*/
|
|
19
19
|
export declare function parserHasTriviaSite(p: Combinator<unknown>, seen?: Set<Combinator<unknown>>): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The same question asked of the ROOT trivia log (`_ctx._rootTriviaLog`) instead
|
|
22
|
+
* of the current node's frame.
|
|
23
|
+
*
|
|
24
|
+
* The two differ in exactly one case, and it is the case that matters: a nested
|
|
25
|
+
* `node()` manages its own FRAME, so nothing inside it reaches the enclosing
|
|
26
|
+
* frame's log — but the root log is not a frame, and every trivia run inside that
|
|
27
|
+
* node still lands in it. Reusing `parserHasTriviaSite` for the root sink
|
|
28
|
+
* therefore under-reports: it dropped the mark on `node()` arms whose trivia does
|
|
29
|
+
* accumulate, and a parse-tree diff caught it as trivia entries that were no
|
|
30
|
+
* longer rewound on a failed choice arm (`length: 3` becoming `length: 6`).
|
|
31
|
+
*/
|
|
32
|
+
export declare function parserHasRootTriviaSite(p: Combinator<unknown>, seen?: Set<Combinator<unknown>>): boolean;
|
|
20
33
|
/**
|
|
21
34
|
* Can this node's inner grammar explicitly enable trivia capture? A surrounding
|
|
22
35
|
* node owns the collector, so a nested `parser({ captureTrivia: true })` must
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/compiler/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAGlE,KAAK,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAElD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAKtD;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,IAAI,GAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAa,GAAG,OAAO,CAmC9G;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC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CAAA;CAAE,CAAC,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAW/J"}
|
|
@@ -5,13 +5,13 @@ export type GrammarCoverageDefinition = {
|
|
|
5
5
|
};
|
|
6
6
|
export type GrammarCoveragePlan = {
|
|
7
7
|
definitions: readonly GrammarCoverageDefinition[];
|
|
8
|
-
choices:
|
|
9
|
-
dispatches:
|
|
8
|
+
choices: Map<Combinator<unknown>, readonly string[]>;
|
|
9
|
+
dispatches: Map<Combinator<unknown>, readonly string[]>;
|
|
10
10
|
/** Trace-only transaction identity. Attempts are not coverage definitions: a
|
|
11
11
|
* rejected transaction must not create a semantic winner or denominator. */
|
|
12
|
-
attempts:
|
|
13
|
-
labels:
|
|
14
|
-
rules:
|
|
12
|
+
attempts: Map<Combinator<unknown>, string>;
|
|
13
|
+
labels: Map<Combinator<unknown>, readonly string[]>;
|
|
14
|
+
rules: Map<Combinator<unknown>, string>;
|
|
15
15
|
};
|
|
16
16
|
/** Canonical deterministic IDs for one explicit entry closure, or every public
|
|
17
17
|
* entry in a `rules()` map. Multiple roots share identity maps so a shared
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grammar-coverage-ids.d.ts","sourceRoot":"","sources":["../../src/compiler/grammar-coverage-ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,aAAa,CAAA;AAGxD,MAAM,MAAM,yBAAyB,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,cAAc,GAAG,OAAO,CAAA;CAAE,CAAA;AAC9G,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,SAAS,yBAAyB,EAAE,CAAA;IACjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"grammar-coverage-ids.d.ts","sourceRoot":"","sources":["../../src/compiler/grammar-coverage-ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,aAAa,CAAA;AAGxD,MAAM,MAAM,yBAAyB,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,cAAc,GAAG,OAAO,CAAA;CAAE,CAAA;AAC9G,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,SAAS,yBAAyB,EAAE,CAAA;IACjD,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC,CAAA;IACpD,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC,CAAA;IACvD;gFAC4E;IAC5E,QAAQ,EAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAA;IAC1C,MAAM,EAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC,CAAA;IACnD,KAAK,EAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAA;CACxC,CAAA;AAkDD;;yCAEyC;AACzC,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,SAAS,UAAU,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,mBAAmB,CA8DhK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ir-serialize.d.ts","sourceRoot":"","sources":["../../src/compiler/ir-serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAkC,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"ir-serialize.d.ts","sourceRoot":"","sources":["../../src/compiler/ir-serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAkC,MAAM,aAAa,CAAA;AAuB7E,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;AAiG/B,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,EAC/C,QAAQ,CAAC,EAAE,SAAS,IAAI,EAAE,GAAG,IAAI,GAChC,MAAM,GAAG,IAAI,CAUf;AAED;;oFAEoF;AACpF,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAyG/D"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type HostMode } from '../cst/host-mode.ts';
|
|
2
|
+
import { type LinkableTable } from './compile-linkable-table.ts';
|
|
2
3
|
import type { BuildHost, Combinator, CstCollapsePredicate, ParseContext, ParseResult } from '../types.ts';
|
|
3
|
-
import type {
|
|
4
|
-
export declare function linkable(rulesMap: Record<string, Combinator<unknown>>, ns?: string, trivia?: Combinator<unknown>, hostMode?: HostMode):
|
|
4
|
+
import type { Runnable } from '../functional/run.ts';
|
|
5
|
+
export declare function linkable(rulesMap: Record<string, Combinator<unknown>>, ns?: string, trivia?: Combinator<unknown>, hostMode?: HostMode): LinkableTable;
|
|
5
6
|
export type CstBuildHostOptions = {
|
|
6
7
|
/**
|
|
7
8
|
* Collapse transparent one-child CST wrapper nodes at build time.
|
|
@@ -42,51 +43,33 @@ export declare function cstBuildHost(type: string, children: ReadonlyArray<unkno
|
|
|
42
43
|
export type FusedRule = (input: string, pos: number, ctx: ParseContext | Record<string, unknown>) => ParseResult<unknown> & {
|
|
43
44
|
readonly value?: unknown;
|
|
44
45
|
};
|
|
45
|
-
/**
|
|
46
|
-
* Restrict a grammar/artifact to `names` plus their transitive rule-dependency
|
|
47
|
-
* closure (à la carte selection) — e.g. Jess taking parts of Less and parts of
|
|
48
|
-
* Sass: `compose([pick(less, ['MixinCall']), pick(sass, ['EachFor']), css])`. A
|
|
49
|
-
* picked rule pulls in every rule name it references, so the result is always
|
|
50
|
-
* self-consistent within the artifact. Accepts a grammar (`rules()` result) or a
|
|
51
|
-
* compiled artifact; returns an artifact for `compose()`.
|
|
52
|
-
*/
|
|
53
|
-
export declare function pick(grammar: LinkablePieces | Record<string, Combinator<unknown>>, names: string[]): LinkablePieces;
|
|
54
|
-
/** Restrict a set of linkable pieces to `names` + their transitive dep closure,
|
|
55
|
-
* keeping each surviving rule in the piece that WINS it (later piece wins, matching
|
|
56
|
-
* compose override order). Shared by `pick()` (runtime) and the macro's build-time
|
|
57
|
-
* `pick(...)` handling, so à-la-carte selection is identical on both paths. */
|
|
58
|
-
export declare function pickPieces(pieces: LinkablePieces[], names: string[]): LinkablePieces[];
|
|
59
|
-
/**
|
|
60
|
-
* Build the fused-closure body (shared by the runtime `fuseRules` and the
|
|
61
|
-
* build-time `emitFusedSource`). Returns the closure body (which reads `_env`
|
|
62
|
-
* for any non-inlined callbacks) and the `_env` to bind. In macro mode callbacks
|
|
63
|
-
* are inlined from source, so `_env` is empty and the body is fully static.
|
|
64
|
-
*/
|
|
65
|
-
export declare function fusedBody(pieces: LinkablePieces[], hoist?: ModuleHoist): {
|
|
66
|
-
body: string;
|
|
67
|
-
env: Record<string, unknown>;
|
|
68
|
-
};
|
|
69
|
-
/** Fuse at RUNTIME (via `new Function`) — used by `compose()` when not compiled
|
|
70
|
-
* by the macro (like `compile()`). The macro path uses `emitFusedSource` instead.
|
|
71
|
-
* Both stamp the host mode from inside `fusedBody`; see `hostModeOfPieces`. */
|
|
72
|
-
export declare function fuseRules(pieces: LinkablePieces[]): Record<string, FusedRule>;
|
|
73
46
|
export { FUSED_HOST_MODE, FUSED_HOST_ELIDED } from '../cst/host-mode.ts';
|
|
74
47
|
/** The host mode a fused/composed rule map was built for. Defaults to 'ast'. */
|
|
75
48
|
export declare function fusedHostModeOf(registry: object): HostMode;
|
|
76
49
|
/** Whether a fused/composed rule map dropped any direct builder's CST branch. */
|
|
77
50
|
export declare function fusedHostElidedOf(registry: object): boolean;
|
|
78
51
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
52
|
+
* Compose grammars/artifacts into a runnable parser map — the ONLY public
|
|
53
|
+
* composition entry point. `compose([base, ext, …])`: later entries override
|
|
54
|
+
* earlier ones by rule name, and because fusion re-binds every reference in one
|
|
55
|
+
* shared scope, an override reroutes the base's OWN calls too (open recursion).
|
|
56
|
+
*
|
|
57
|
+
* Each entry may be a **grammar** (a `rules()` result — a map of combinators,
|
|
58
|
+
* linkable-ified here) OR an already-compiled **linkable artifact** (what the
|
|
59
|
+
* macro emits and a package ships). So a package needs no opt-in wrapper to be
|
|
60
|
+
* composable — `compose([importedGrammar, myRules])` just works.
|
|
61
|
+
*
|
|
62
|
+
* The macro compiles `compose([...])` to STATIC fused source (no `new Function`).
|
|
63
|
+
* Called at runtime (no macro, like `compile()`) it fuses via `new Function`.
|
|
84
64
|
*/
|
|
85
|
-
|
|
65
|
+
/** A composed parser carries its flattened source pieces (non-enumerable) so it
|
|
66
|
+
* can be composed AGAIN — `compose([lessGrammar, delta])` where `lessGrammar` is
|
|
67
|
+
* itself a `compose([...])` result. */
|
|
68
|
+
export declare const COMPOSED_PIECES: unique symbol;
|
|
86
69
|
/** The carried pieces a `compose()`/`composeLeaf()` result holds, or `undefined` when
|
|
87
70
|
* the value is not a composed grammar. This is what makes a fused grammar analysable:
|
|
88
71
|
* the pieces are re-lowerable IR even though the fused map itself is only functions. */
|
|
89
|
-
export declare function composedPiecesOf(grammar: Record<string, unknown>): ReadonlyArray<
|
|
72
|
+
export declare function composedPiecesOf(grammar: Record<string, unknown>): ReadonlyArray<LinkableTable | IRPiece> | undefined;
|
|
90
73
|
/** The compact IR form a grammar carries instead of its lowered rule source: the
|
|
91
74
|
* combinator-construction expression, re-lowered here at fuse time. */
|
|
92
75
|
export type IRPiece = {
|
|
@@ -106,10 +89,10 @@ export declare function once<T>(fn: () => T): () => T;
|
|
|
106
89
|
* Skipping is not the same as having nothing to say. Use `carriedRuleMapsDetailed`
|
|
107
90
|
* where the skip must be REPORTED — a diagnostic that drops part of the grammar and
|
|
108
91
|
* then returns a clean result is indistinguishable from one that verified it. */
|
|
109
|
-
export declare function carriedRuleMaps(carried: ReadonlyArray<
|
|
92
|
+
export declare function carriedRuleMaps(carried: ReadonlyArray<LinkableTable | IRPiece>): Array<Array<[string, Combinator<unknown>]>>;
|
|
110
93
|
/** `carriedRuleMaps` plus the pieces it could NOT re-lower, named by namespace and
|
|
111
94
|
* rule count, so a caller can report exactly how much of the grammar went unseen. */
|
|
112
|
-
export declare function carriedRuleMapsDetailed(carried: ReadonlyArray<
|
|
95
|
+
export declare function carriedRuleMapsDetailed(carried: ReadonlyArray<LinkableTable | IRPiece>): {
|
|
113
96
|
maps: Array<Array<[string, Combinator<unknown>]>>;
|
|
114
97
|
opaque: Array<{
|
|
115
98
|
ns: string;
|
|
@@ -139,10 +122,7 @@ export declare function recoverComposedRules(grammar: Record<string, unknown>):
|
|
|
139
122
|
* `compose()`, or `undefined` when a precompiled opaque artifact participated.
|
|
140
123
|
* This is intentionally internal: callers must not treat it as a parser API. */
|
|
141
124
|
export declare function composedCoverageRules(grammar: Record<string, unknown>): Record<string, Combinator<unknown>> | undefined;
|
|
142
|
-
|
|
143
|
-
* back to a rule map and re-lowered; a full piece passes through. */
|
|
144
|
-
export declare function materializePiece(p: LinkablePieces | IRPiece, trivia?: Combinator<unknown>, captureTerminals?: boolean, hostMode?: HostMode): LinkablePieces;
|
|
145
|
-
export declare function compose(items: Array<LinkablePieces | Record<string, unknown>>,
|
|
125
|
+
export declare function compose(items: Array<LinkableTable | Record<string, unknown>>,
|
|
146
126
|
/**
|
|
147
127
|
* Compile-time host mode for the fused artifact, same meaning as
|
|
148
128
|
* `compile(g, { hostMode })`. Omit (or `'ast'`) for the eval driver — the fused rules
|
|
@@ -163,16 +143,30 @@ opts?: {
|
|
|
163
143
|
* lowering there is no safe way to keep lexical builders out of carried IR, so it
|
|
164
144
|
* never falls back to runtime CODEGEN composition.
|
|
165
145
|
*
|
|
166
|
-
* Called at runtime (no macro) it returns the INTERPRETED fuse of the same items
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
146
|
+
* Called at runtime (no macro) it returns the INTERPRETED fuse of the same items —
|
|
147
|
+
* a combinator map, not a map of compiled functions (`fuseInterpreted`), fused lazily
|
|
148
|
+
* per rule name.
|
|
149
|
+
*
|
|
150
|
+
* THE RETURN TYPE IS `Runnable`, NOT `FusedRule`, BECAUSE BOTH PATHS ARE REAL. A macro
|
|
151
|
+
* build yields fused functions; an un-macro'd call yields combinators. `Runnable` is
|
|
152
|
+
* already the library's name for "either of those" — it is what `run()` and
|
|
153
|
+
* `parseDoc()` take — so the declared type is TRUE on both paths and a caller needs no
|
|
154
|
+
* narrowing to use the result. This used to declare `Record<string, FusedRule>` and
|
|
155
|
+
* launder the runtime path through an `as unknown as`, which let a caller hold a
|
|
156
|
+
* combinator map while the type promised compiled functions.
|
|
157
|
+
*
|
|
158
|
+
* Do NOT "fix" this by deleting the runtime path. It is load-bearing: the `bench/jess`
|
|
159
|
+
* harness family and two differential-gate legs (`emit-identity-one`,
|
|
160
|
+
* `scan-shape-oracle-one`) import un-macro'd grammar modules and depend on this lazy
|
|
161
|
+
* interpreted fuse, one dialect per process. Whether an un-macro'd `composeLeaf()`
|
|
162
|
+
* should exist at all is a separate, open owner question — but while the gates depend
|
|
163
|
+
* on it, it exists, and the type says so.
|
|
172
164
|
*/
|
|
173
|
-
export declare function composeLeaf(items: Array<
|
|
165
|
+
export declare function composeLeaf(items: Array<LinkableTable | Record<string, unknown>>): Record<string, Runnable>;
|
|
174
166
|
/** Whether `map` is an interpreted fuse (a combinator map) rather than a compiled
|
|
175
|
-
* `compose()` result (a map of fused functions).
|
|
167
|
+
* `compose()` result (a map of fused functions). INTERNAL — not re-exported from
|
|
168
|
+
* `src/index.ts`. A consumer never has to ask this question: what it holds is
|
|
169
|
+
* whatever the macro built. Diagnostics that fuse interpreted on purpose do. */
|
|
176
170
|
export declare function isInterpretedFuse(map: object): boolean;
|
|
177
171
|
/**
|
|
178
172
|
* Materialize a composition as a RUNNABLE INTERPRETED rule map — the interpreted
|
|
@@ -195,7 +189,7 @@ export declare function isInterpretedFuse(map: object): boolean;
|
|
|
195
189
|
* calls. A second, DIFFERENT fusion over the same piece objects therefore throws
|
|
196
190
|
* rather than silently rewriting the first one's parser.
|
|
197
191
|
*/
|
|
198
|
-
export declare function fuseInterpreted(items: Array<
|
|
192
|
+
export declare function fuseInterpreted(items: Array<LinkableTable | Record<string, unknown>>, opts?: {
|
|
199
193
|
hostMode?: HostMode;
|
|
200
194
|
}): Record<string, Combinator<unknown>>;
|
|
201
195
|
//# sourceMappingURL=linker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linker.d.ts","sourceRoot":"","sources":["../../src/compiler/linker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"linker.d.ts","sourceRoot":"","sources":["../../src/compiler/linker.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAsC,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEvF,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAKtF,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,oBAAoB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAapD,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,EAC7C,EAAE,CAAC,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,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
5
|
+
* `literal`, `keywords`, and `regex`. This module walks the combinator graph
|
|
6
|
+
* and assigns each distinct terminal a small integer TOKEN ID.
|
|
7
|
+
*
|
|
8
|
+
* Two things are deliberately separated, because conflating them is what makes
|
|
9
|
+
* a naive derived scanner useless:
|
|
10
|
+
*
|
|
11
|
+
* - The token ID SPACE is GLOBAL. One id per distinct terminal across the whole
|
|
12
|
+
* grammar, so an id can be compared, switched on, and indexed with.
|
|
13
|
+
* - The CANDIDATE SET is LOCAL, per decision point. Global maximal munch over
|
|
14
|
+
* the whole alphabet is wrong: a css alphabet contains construct-local
|
|
15
|
+
* long-run terminals (`[^()]+`, `[^{}/]+`, the `scanTo` raw-prelude runs)
|
|
16
|
+
* that swallow the document. Measured: global munch yields SEVEN tokens for a
|
|
17
|
+
* 123 KB stylesheet. A decision point consults only the terminals that can
|
|
18
|
+
* actually start one of its arms.
|
|
19
|
+
*
|
|
20
|
+
* Nothing here decides HOW a token is recognized (see `token-scanner.ts`); this
|
|
21
|
+
* module only decides WHAT the tokens are and WHICH ones each site may see.
|
|
22
|
+
*/
|
|
23
|
+
import type { Combinator } from '../types.ts';
|
|
24
|
+
/** A terminal in the derived alphabet, with its globally assigned id. */
|
|
25
|
+
export type TokenTerminal = {
|
|
26
|
+
kind: 'literal';
|
|
27
|
+
id: number;
|
|
28
|
+
value: string;
|
|
29
|
+
caseInsensitive: boolean;
|
|
30
|
+
} | {
|
|
31
|
+
kind: 'keywords';
|
|
32
|
+
id: number;
|
|
33
|
+
words: readonly string[];
|
|
34
|
+
caseInsensitive: boolean;
|
|
35
|
+
boundary: string | undefined;
|
|
36
|
+
} | {
|
|
37
|
+
kind: 'regex';
|
|
38
|
+
id: number;
|
|
39
|
+
source: string;
|
|
40
|
+
flags: string;
|
|
41
|
+
};
|
|
42
|
+
/** Reserved ids. Real terminals start at `FIRST_TERMINAL_ID`. */
|
|
43
|
+
export declare const TOK_EOF = 0;
|
|
44
|
+
export declare const TOK_UNKNOWN = 1;
|
|
45
|
+
export declare const TOK_WS = 2;
|
|
46
|
+
export declare const FIRST_TERMINAL_ID = 3;
|
|
47
|
+
export type Alphabet = {
|
|
48
|
+
terminals: TokenTerminal[];
|
|
49
|
+
/** Dedup key → id, so the same terminal spelled twice gets ONE id. */
|
|
50
|
+
byKey: Map<string, number>;
|
|
51
|
+
/** The combinator that contributed each id (first one wins), for candidate sets. */
|
|
52
|
+
originOf: Map<number, Combinator<unknown>>;
|
|
53
|
+
};
|
|
54
|
+
/** Direct sub-parsers of a def, resolving a lazy through `resolve` when its own thunk is a hole. */
|
|
55
|
+
export declare function tokenChildren(p: Combinator<unknown>, resolve?: (name: string) => Combinator<unknown> | undefined): Combinator<unknown>[];
|
|
56
|
+
/**
|
|
57
|
+
* Collect the alphabet over `roots`. Ids are assigned in first-encounter order,
|
|
58
|
+
* which is stable for a given grammar and therefore safe to switch on.
|
|
59
|
+
*/
|
|
60
|
+
export declare function collectAlphabet(roots: ReadonlyArray<Combinator<unknown>>, resolve?: (name: string) => Combinator<unknown> | undefined): Alphabet;
|
|
61
|
+
/** The id already assigned to this terminal, if it is one. */
|
|
62
|
+
export declare function terminalId(alphabet: Alphabet, p: Combinator<unknown>): number | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* The LEADING terminal of an arm — the one a decision point would consult. Walks
|
|
65
|
+
* through the wrappers that do not consume input, and through a sequence's
|
|
66
|
+
* nullable/zero-width prefix. Returns undefined when the lead is not a single
|
|
67
|
+
* derived terminal, which is the signal to stay scannerless at that site.
|
|
68
|
+
*/
|
|
69
|
+
export declare function leadTerminal(p: Combinator<unknown>, alphabet: Alphabet, resolve?: (name: string) => Combinator<unknown> | undefined, depth?: number): number | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* The CANDIDATE SET for one decision point: the leading terminals of its arms.
|
|
72
|
+
* `complete` is false when any arm's lead is not a derived terminal — that site
|
|
73
|
+
* must stay scannerless, per-construct, exactly as `scanSkip` and first-set
|
|
74
|
+
* gating already apply per region rather than globally.
|
|
75
|
+
*/
|
|
76
|
+
export type CandidateSet = {
|
|
77
|
+
ids: number[];
|
|
78
|
+
complete: boolean;
|
|
79
|
+
};
|
|
80
|
+
export declare function candidateSet(arms: ReadonlyArray<Combinator<unknown>>, alphabet: Alphabet, resolve?: (name: string) => Combinator<unknown> | undefined): CandidateSet;
|
|
81
|
+
//# sourceMappingURL=token-alphabet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-alphabet.d.ts","sourceRoot":"","sources":["../../src/compiler/token-alphabet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,aAAa,CAAA;AAExD,yEAAyE;AACzE,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,OAAO,CAAA;CAAE,GACxE;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,eAAe,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAClH;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEhE,iEAAiE;AACjE,eAAO,MAAM,OAAO,IAAI,CAAA;AACxB,eAAO,MAAM,WAAW,IAAI,CAAA;AAC5B,eAAO,MAAM,MAAM,IAAI,CAAA;AACvB,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAElC,MAAM,MAAM,QAAQ,GAAG;IACrB,SAAS,EAAE,aAAa,EAAE,CAAA;IAC1B,sEAAsE;IACtE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MA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