parseman 0.51.2 → 0.53.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/dist/analysis/commitment.d.ts.map +1 -1
- package/dist/analysis/diagnostics.js +411 -28
- package/dist/analysis/diagnostics.js.map +3 -3
- package/dist/cli/index.js +6162 -6372
- package/dist/cli/index.js.map +3 -3
- package/dist/combinators/attempt.d.ts +11 -1
- package/dist/combinators/attempt.d.ts.map +1 -1
- package/dist/combinators/map.d.ts.map +1 -1
- package/dist/combinators/node.d.ts +6 -2
- package/dist/combinators/node.d.ts.map +1 -1
- package/dist/combinators/parser.d.ts +34 -0
- package/dist/combinators/parser.d.ts.map +1 -1
- package/dist/combinators/ref.d.ts +0 -13
- package/dist/combinators/ref.d.ts.map +1 -1
- package/dist/compiler/borrowed-rules.d.ts +30 -0
- package/dist/compiler/borrowed-rules.d.ts.map +1 -0
- package/dist/compiler/compile-linkable-table.d.ts +1 -1
- package/dist/compiler/grammar-coverage-ids.d.ts.map +1 -1
- package/dist/compiler/ir-serialize.d.ts +10 -4
- package/dist/compiler/ir-serialize.d.ts.map +1 -1
- package/dist/compiler/linker.d.ts +48 -91
- package/dist/compiler/linker.d.ts.map +1 -1
- package/dist/compiler/token-capability.js +4 -0
- package/dist/compiler/token-capability.js.map +1 -1
- package/dist/coverage.d.ts +1 -1
- package/dist/coverage.d.ts.map +1 -1
- package/dist/cst/reflection.d.ts.map +1 -1
- package/dist/cst/trivia-kinds.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +470 -725
- package/dist/index.js.map +3 -3
- package/dist/language-service/index.js.map +1 -1
- package/dist/plugin/evaluator.d.ts +38 -2
- package/dist/plugin/evaluator.d.ts.map +1 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +1127 -544
- package/dist/plugin/index.js.map +3 -3
- package/dist/plugin/ir-eval.d.ts +21 -0
- package/dist/plugin/ir-eval.d.ts.map +1 -0
- package/dist/plugin/reducer-resolver.d.ts +6 -0
- package/dist/plugin/reducer-resolver.d.ts.map +1 -1
- package/dist/spec/index.js +555 -6086
- package/dist/spec/index.js.map +3 -3
- package/dist/spec/railroad-lib.d.ts +7 -2
- package/dist/spec/railroad-lib.d.ts.map +1 -1
- package/dist/spec/railroad.d.ts.map +1 -1
- package/dist/table/assemble.d.ts.map +1 -1
- package/dist/table/compile-rule-map.d.ts +11 -4
- package/dist/table/compile-rule-map.d.ts.map +1 -1
- package/dist/table/compile.d.ts +16 -0
- package/dist/table/compile.d.ts.map +1 -1
- package/dist/table/emit-assembly.d.ts.map +1 -1
- package/dist/table/encode-baseline.d.ts.map +1 -1
- package/dist/table/exec.d.ts.map +1 -1
- package/dist/table/index.js +272 -102
- package/dist/table/index.js.map +2 -2
- package/dist/table/ops.d.ts +7 -5
- package/dist/table/ops.d.ts.map +1 -1
- package/dist/table/site-labels.d.ts.map +1 -1
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/analysis/commitment.ts +3 -1
- package/src/analysis/rebuild.ts +1 -1
- package/src/combinators/attempt.ts +26 -3
- package/src/combinators/first-set.ts +5 -1
- package/src/combinators/map.ts +5 -1
- package/src/combinators/node.ts +12 -3
- package/src/combinators/parser.ts +133 -67
- package/src/combinators/ref.ts +10 -1
- package/src/compiler/borrowed-rules.ts +88 -0
- package/src/compiler/compile-linkable-table.ts +1 -1
- package/src/compiler/grammar-coverage-ids.ts +35 -6
- package/src/compiler/ir-serialize.ts +13 -119
- package/src/compiler/linker.ts +190 -666
- package/src/coverage.ts +7 -5
- package/src/cst/reflection.ts +6 -1
- package/src/cst/trivia-kinds.ts +6 -0
- package/src/index.ts +1 -0
- package/src/plugin/evaluator.ts +114 -14
- package/src/plugin/index.ts +588 -110
- package/src/plugin/ir-eval.ts +165 -0
- package/src/plugin/reducer-resolver.ts +20 -3
- package/src/spec/railroad-lib.ts +18 -8
- package/src/spec/railroad.ts +3 -4
- package/src/table/assemble.ts +22 -8
- package/src/table/compile-rule-map.ts +18 -8
- package/src/table/compile.ts +61 -0
- package/src/table/emit-assembly.ts +8 -3
- package/src/table/encode-baseline.ts +5 -1
- package/src/table/encode.ts +13 -13
- package/src/table/exec.ts +6 -2
- package/src/table/ops.ts +7 -5
- package/src/table/site-labels.ts +3 -1
- package/src/types.ts +8 -1
- package/src/version.ts +1 -1
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import type { Combinator } from '../types.ts';
|
|
2
|
+
export type AttemptOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Also contain COMMITMENT. A failure committed inside the transaction — a
|
|
5
|
+
* `dispatch()` whose selected branch failed — is reported as an ordinary
|
|
6
|
+
* failure at the attempt's entry, so an enclosing `choice()` still tries its
|
|
7
|
+
* next arm. For two readings of one prefix that only a later token decides.
|
|
8
|
+
*/
|
|
9
|
+
contain?: boolean;
|
|
10
|
+
};
|
|
2
11
|
/**
|
|
3
12
|
* Transactional ordered-choice arm. On failure it restores Parseman's
|
|
4
13
|
* structural capture/trivia/error sinks and reports failure at its entry point;
|
|
5
14
|
* user-owned `ctx.state` is intentionally not cloned or mutated by Parseman.
|
|
15
|
+
* A committed failure keeps its commitment unless `contain` is set.
|
|
6
16
|
*/
|
|
7
|
-
export declare function attempt<T>(parser: Combinator<T
|
|
17
|
+
export declare function attempt<T>(parser: Combinator<T>, options?: AttemptOptions): Combinator<T>;
|
|
8
18
|
//# sourceMappingURL=attempt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attempt.d.ts","sourceRoot":"","sources":["../../src/combinators/attempt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA6B,MAAM,aAAa,CAAA;AAKxE
|
|
1
|
+
{"version":3,"file":"attempt.d.ts","sourceRoot":"","sources":["../../src/combinators/attempt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA6B,MAAM,aAAa,CAAA;AAKxE,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAaD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,CAAC,CAAC,CA+BzF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/combinators/map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA6B,MAAM,aAAa,CAAA;AAUxE,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAC5B,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,KAAK,CAAC,GACxD,UAAU,CAAC,CAAC,CAAC,CAiEf;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/combinators/map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA6B,MAAM,aAAa,CAAA;AAUxE,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAC5B,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,KAAK,CAAC,GACxD,UAAU,CAAC,CAAC,CAAC,CAiEf;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAkBlE;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,GAClD,UAAU,CAAC,OAAO,CAAC,CAqBrB;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAW/E;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAY/E"}
|
|
@@ -33,8 +33,12 @@ export type BuildNode<N> = (children: ReadonlyArray<unknown>, fields: FieldMap |
|
|
|
33
33
|
* enclosing `parser()` did not opt into document-wide trivia capture. This is
|
|
34
34
|
* scoped to the node; sibling and parent nodes retain their own setting.
|
|
35
35
|
* - `trailingTrivia` — after a successful node body, consume the active grammar
|
|
36
|
-
* trivia once
|
|
37
|
-
*
|
|
36
|
+
* trivia once, inside THIS node's span: it lands in this node's log when the
|
|
37
|
+
* node captures trivia (its reducer reads the log, `captureTrivia`, a structural
|
|
38
|
+
* node, a CST host) and in the root trivia table either way. It does not by
|
|
39
|
+
* itself turn capture on. Intended for a document root whose body is a
|
|
40
|
+
* repetition, or a value whose trailing comments belong to it; do not set it on
|
|
41
|
+
* a block that already has a closing delimiter.
|
|
38
42
|
* - `tags` — grammar-level CST categories for visitor dispatch. Stored once in
|
|
39
43
|
* grammar reflection; not copied onto every CST node.
|
|
40
44
|
* Both skip `build` only for a one-child match; zero or two-plus children go
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/combinators/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAoD,MAAM,aAAa,CAAA;AAQzG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAElE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CACzB,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,EAChC,MAAM,EAAE,QAAQ,GAAG,SAAS,EAC5B,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EACpC,WAAW,EAAE,aAAa,CAAC,OAAO,CAAC,EACnC,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,KAAK,EAAE,OAAO,KACX,CAAC,CAAA;AAEN
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/combinators/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAoD,MAAM,aAAa,CAAA;AAQzG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAElE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CACzB,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,EAChC,MAAM,EAAE,QAAQ,GAAG,SAAS,EAC5B,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EACpC,WAAW,EAAE,aAAa,CAAC,OAAO,CAAC,EACnC,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,KAAK,EAAE,OAAO,KACX,CAAC,CAAA;AAEN;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,CAAC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AAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA"}
|
|
@@ -94,5 +94,39 @@ type RuleMapNodeTag<T extends Record<string, Combinator<unknown>>> = {
|
|
|
94
94
|
type RulesResult<T extends Record<string, Combinator<unknown>>> = T & GrammarWithReflection<RuleMapNodeType<T>, RuleMapNodeTag<T>>;
|
|
95
95
|
export declare function rules<T extends Record<string, Combinator<unknown>>>(factory: (self: any) => T): RulesResult<T>;
|
|
96
96
|
export declare function rules<T extends Record<string, Combinator<unknown>>>(options: RulesOptions, factory: (self: any) => T): RulesResult<T>;
|
|
97
|
+
/**
|
|
98
|
+
* The recipe a `rules()` result was built from — its factory and options —
|
|
99
|
+
* non-enumerable, in piece order. Runtime `compose()` links grammars by running
|
|
100
|
+
* these again against ONE shared namespace (`linkRules`), which is what makes a
|
|
101
|
+
* composition the same graph as one `rules()` written over every piece. A
|
|
102
|
+
* composed result carries the concatenated list, so it composes again.
|
|
103
|
+
*/
|
|
104
|
+
export declare const RULES_RECIPE: unique symbol;
|
|
105
|
+
export type RulesRecipe = {
|
|
106
|
+
readonly factory: (self: Record<string, Combinator<unknown>>) => Record<string, Combinator<unknown>>;
|
|
107
|
+
readonly options: RulesOptions | undefined;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* How a composition overrides its pieces' own options: the composing grammar's
|
|
111
|
+
* trivia governs every rule (composing-wins), and an explicit host mode wins
|
|
112
|
+
* over each piece's.
|
|
113
|
+
*/
|
|
114
|
+
export type LinkOptions = {
|
|
115
|
+
readonly trivia?: Combinator<unknown> | undefined;
|
|
116
|
+
readonly hostMode?: HostMode | undefined;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Build ONE rule map from one or more recipes, run in order against a single
|
|
120
|
+
* shared namespace, a later recipe's definition winning per rule name.
|
|
121
|
+
*
|
|
122
|
+
* `rules()` is the one-recipe case. Runtime `compose()` passes every piece's
|
|
123
|
+
* recipe plus `link`: each `g.X` in every factory then resolves to the one
|
|
124
|
+
* composed slot for X, so an override reroutes a base piece's own calls (open
|
|
125
|
+
* recursion) and every choice computes its first-set dispatch against the
|
|
126
|
+
* winners. The graph is built fresh, so no shared rule of any piece is touched;
|
|
127
|
+
* under `link` a winner is always held in a fresh slot, so the stamps below never
|
|
128
|
+
* land on a combinator a factory returned from module scope either.
|
|
129
|
+
*/
|
|
130
|
+
export declare function linkRules(recipes: readonly RulesRecipe[], link?: LinkOptions): Record<string, Combinator<unknown>>;
|
|
97
131
|
export {};
|
|
98
132
|
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/combinators/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAInD,OAAO,EAA4B,QAAQ,EAAE,SAAS,EAAE,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAGhH;;;;GAIG;AACH,eAAO,MAAM,UAAU,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/combinators/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAInD,OAAO,EAA4B,QAAQ,EAAE,SAAS,EAAE,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAGhH;;;;GAIG;AACH,eAAO,MAAM,UAAU,wBAAwB,CAAA;AAmD/C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;8EAC0E;IAC1E,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAAA;IACnC;;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
|
|
2
|
-
/**
|
|
3
|
-
* Create a forward-declared parser slot for mutually recursive grammars.
|
|
4
|
-
*
|
|
5
|
-
* Because JS evaluates arguments eagerly, you can't reference a variable
|
|
6
|
-
* before it's declared. ref() creates a placeholder you fill in later:
|
|
7
|
-
*
|
|
8
|
-
* const value = ref<JSONValue>()
|
|
9
|
-
* const array = transform(sequence(literal('['), sepBy(value, literal(',')), literal(']')), ...)
|
|
10
|
-
* const object = transform(sequence(literal('{'), sepBy(pair, literal(',')), literal('}')), ...)
|
|
11
|
-
* value.define(choice(object, array, string, number, bool, nullVal))
|
|
12
|
-
*
|
|
13
|
-
* Unlike lazy(() => x), you use the ref directly — no wrapping at each call site.
|
|
14
|
-
*/
|
|
15
2
|
export declare function ref<T>(): Combinator<T> & {
|
|
16
3
|
define(p: Combinator<T>): void;
|
|
17
4
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../../src/combinators/ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAyC,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../../src/combinators/ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAyC,MAAM,aAAa,CAAA;AAqCpF,wBAAgB,GAAG,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG;IAAE,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;CAAE,CAmG3E"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the interpreter and a compiled table would bind one reference differently.
|
|
3
|
+
*
|
|
4
|
+
* A rule reference (`g.X`) is a slot object. The interpreter follows the slot it
|
|
5
|
+
* holds. The table encoder binds a reference to the map's rule of the same NAME
|
|
6
|
+
* (`encode.ts`, `winners`). Within one linked map the two are the same rule. They
|
|
7
|
+
* differ only for a rule object BORROWED from another grammar (`Entry: base.Entry`):
|
|
8
|
+
* its graph holds `base`'s own slots, so the interpreter keeps `base`'s `Atom` while
|
|
9
|
+
* the encoder binds this map's `Atom`. Both parse, and they accept different input.
|
|
10
|
+
*
|
|
11
|
+
* ponytail: refuses the pattern instead of rebinding borrowed graphs, which is the
|
|
12
|
+
* planned follow-up that lets both engines agree.
|
|
13
|
+
*/
|
|
14
|
+
import type { Combinator } from '../types.ts';
|
|
15
|
+
type Comb = Combinator<unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* The first rule of `map` whose graph reaches another grammar's slot for a rule
|
|
18
|
+
* `map` also defines — the rule, and the name it references — or `undefined`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function borrowedRuleReference(map: Readonly<Record<string, Comb>>): {
|
|
21
|
+
rule: string;
|
|
22
|
+
reference: string;
|
|
23
|
+
} | undefined;
|
|
24
|
+
/** The refusal, worded for the API that refused. */
|
|
25
|
+
export declare function borrowedRuleMessage(api: string, hit: {
|
|
26
|
+
rule: string;
|
|
27
|
+
reference: string;
|
|
28
|
+
}): string;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=borrowed-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"borrowed-rules.d.ts","sourceRoot":"","sources":["../../src/compiler/borrowed-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAI7C,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;AAe/B;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,GAClC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAwCjD;AAED,oDAAoD;AACpD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAMjG"}
|
|
@@ -26,7 +26,7 @@ import type { TableProgram, TableRule } from '../table/program.ts';
|
|
|
26
26
|
* composable half, and it is NOT new machinery: the plugin
|
|
27
27
|
* already carries pieces as IR (`plugin/index.ts:1772`) and
|
|
28
28
|
* the linker already re-lowers them (`linker.ts:640`,
|
|
29
|
-
* `compileLinkable(evalRuleMapIR(p.ir), …)`).
|
|
29
|
+
* `compileLinkable(evalRuleMapIR(p.ir), …)` at build time).
|
|
30
30
|
*
|
|
31
31
|
* ── WHY THAT MAKES COMPOSITION THE EASY KIND ─────────────────────────────────
|
|
32
32
|
* The open question was whether table-to-table composition has to merge two
|
|
@@ -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,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,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20
|
import type { Combinator } from '../types.ts';
|
|
21
21
|
type Comb = Combinator<unknown>;
|
|
22
22
|
export declare function serializeRuleMap(ruleMap: ReadonlyArray<readonly [string, Comb]>, scanSkip?: readonly Comb[] | null): string | null;
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
|
|
23
|
+
/**
|
|
24
|
+
* ONE plain combinator as IR — what a compiled module carries on an exported terminal
|
|
25
|
+
* so another module can import it into a grammar (the macro evaluates grammars, and a
|
|
26
|
+
* compiled parser function is not a combinator it can evaluate).
|
|
27
|
+
*
|
|
28
|
+
* No new format: it is `serializeRuleMap`'s `scanSkip` channel over an empty map, which
|
|
29
|
+
* already serializes rule-free terminals OUTSIDE any factory — exactly this shape. Its
|
|
30
|
+
* inverse, `evalCombinatorIR`, evaluates source and so lives in `src/plugin/ir-eval.ts`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function serializeCombinator(c: Comb): string | null;
|
|
27
33
|
export {};
|
|
28
34
|
//# sourceMappingURL=ir-serialize.d.ts.map
|
|
@@ -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;AAuB7E,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;AAsG/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
|
|
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;AAsG/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;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAE1D"}
|
|
@@ -48,30 +48,15 @@ export { FUSED_HOST_MODE, FUSED_HOST_ELIDED } from '../cst/host-mode.ts';
|
|
|
48
48
|
export declare function fusedHostModeOf(registry: object): HostMode;
|
|
49
49
|
/** Whether a fused/composed rule map dropped any direct builder's CST branch. */
|
|
50
50
|
export declare function fusedHostElidedOf(registry: object): boolean;
|
|
51
|
-
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
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`.
|
|
64
|
-
*/
|
|
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. */
|
|
51
|
+
/** The carried pieces a BUILD-compiled (`compose()` under the macro) grammar
|
|
52
|
+
* holds: its pieces as serialized IR, re-lowered by the macro plugin at build
|
|
53
|
+
* time. A runtime composition carries recipes instead (`RULES_RECIPE`). */
|
|
68
54
|
export declare const COMPOSED_PIECES: unique symbol;
|
|
69
|
-
/** The carried pieces a
|
|
70
|
-
* the value is not
|
|
71
|
-
* the pieces are re-lowerable IR even though the fused map itself is only functions. */
|
|
55
|
+
/** The carried pieces a build-compiled composed grammar holds, or `undefined`
|
|
56
|
+
* when the value is not one. */
|
|
72
57
|
export declare function composedPiecesOf(grammar: Record<string, unknown>): ReadonlyArray<LinkableTable | IRPiece> | undefined;
|
|
73
|
-
/** The compact IR form a grammar carries
|
|
74
|
-
*
|
|
58
|
+
/** The compact IR form a build-compiled grammar carries: the combinator-construction
|
|
59
|
+
* expression, re-lowered by the macro plugin at build time. */
|
|
75
60
|
export type IRPiece = {
|
|
76
61
|
ns: string;
|
|
77
62
|
ir: string;
|
|
@@ -90,7 +75,7 @@ export declare function once<T>(fn: () => T): () => T;
|
|
|
90
75
|
* where the skip must be REPORTED — a diagnostic that drops part of the grammar and
|
|
91
76
|
* then returns a clean result is indistinguishable from one that verified it. */
|
|
92
77
|
export declare function carriedRuleMaps(carried: ReadonlyArray<LinkableTable | IRPiece>): Array<Array<[string, Combinator<unknown>]>>;
|
|
93
|
-
/** `carriedRuleMaps` plus the pieces it could NOT
|
|
78
|
+
/** `carriedRuleMaps` plus the pieces it could NOT recover, named by namespace and
|
|
94
79
|
* rule count, so a caller can report exactly how much of the grammar went unseen. */
|
|
95
80
|
export declare function carriedRuleMapsDetailed(carried: ReadonlyArray<LinkableTable | IRPiece>): {
|
|
96
81
|
maps: Array<Array<[string, Combinator<unknown>]>>;
|
|
@@ -100,16 +85,10 @@ export declare function carriedRuleMapsDetailed(carried: ReadonlyArray<LinkableT
|
|
|
100
85
|
}>;
|
|
101
86
|
};
|
|
102
87
|
/**
|
|
103
|
-
* Recover the override-winner COMBINATOR map behind a
|
|
104
|
-
* pieces that could not be recovered.
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* (gating analysis, the spec/EBNF/railroad model) cannot read it directly. The graph
|
|
108
|
-
* is not lost, though — `compose()` retains re-lowerable IR — so this is the single
|
|
109
|
-
* shared recovery both consumers use. Sharing it is the point: two copies of this
|
|
110
|
-
* logic is how one walker gets fixed and the other silently keeps failing.
|
|
111
|
-
*
|
|
112
|
-
* Returns `undefined` when `grammar` is not a composed result.
|
|
88
|
+
* Recover the override-winner COMBINATOR map behind a BUILD-compiled composed
|
|
89
|
+
* grammar, plus the pieces that could not be recovered. A runtime composition is
|
|
90
|
+
* already a combinator map, so this returns `undefined` for it, exactly as for a
|
|
91
|
+
* plain `rules()` map: walk it directly.
|
|
113
92
|
*/
|
|
114
93
|
export declare function recoverComposedRules(grammar: Record<string, unknown>): {
|
|
115
94
|
rules: Map<string, Combinator<unknown>>;
|
|
@@ -118,76 +97,54 @@ export declare function recoverComposedRules(grammar: Record<string, unknown>):
|
|
|
118
97
|
ruleNames: string[];
|
|
119
98
|
}>;
|
|
120
99
|
} | undefined;
|
|
121
|
-
/**
|
|
122
|
-
* `
|
|
123
|
-
* This is intentionally internal: callers must not treat it as a parser API. */
|
|
100
|
+
/** The final override-winner combinator map of a runtime composition, or
|
|
101
|
+
* `undefined` for anything else. INTERNAL: coverage tooling only. */
|
|
124
102
|
export declare function composedCoverageRules(grammar: Record<string, unknown>): Record<string, Combinator<unknown>> | undefined;
|
|
103
|
+
/** The linked winner map a runtime composition's rule belongs to, or `undefined`.
|
|
104
|
+
* Lets a coverage run over ONE composed rule name its choices exactly as
|
|
105
|
+
* `composedGrammarCoverageDefinitions` does. INTERNAL: coverage tooling only. */
|
|
106
|
+
export declare function linkedWinnersOf(rule: Combinator<unknown>): Record<string, Combinator<unknown>> | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Compose grammars into ONE parser map — the only public composition entry point.
|
|
109
|
+
* `compose([base, ext, …])`: a later entry's rule WINS by name, and because every
|
|
110
|
+
* piece is linked against one namespace, an override reroutes the base's OWN calls
|
|
111
|
+
* too (open recursion).
|
|
112
|
+
*
|
|
113
|
+
* UNDER THE MACRO, `compose([...])` is lowered at BUILD time to a static table.
|
|
114
|
+
*
|
|
115
|
+
* AT RUNTIME it only links (docs/design/runtime-and-size-contract.md, rule 2):
|
|
116
|
+
* every piece's `rules()` factory runs again against one shared namespace, so the
|
|
117
|
+
* result is exactly the interpreter grammar one `rules()` over all the pieces would
|
|
118
|
+
* build. It builds no table, evaluates no source and mutates no piece. Linking is
|
|
119
|
+
* LAZY — the first read of a rule links the whole map once — so `compose()` itself
|
|
120
|
+
* costs a walk of the items' declared names. For speed, `compile()` a rule of it;
|
|
121
|
+
* `compile()` specialises when the environment allows and falls back under CSP.
|
|
122
|
+
*/
|
|
125
123
|
export declare function compose(items: Array<LinkableTable | Record<string, unknown>>,
|
|
126
124
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
* branch. Pass `'cst'` to fuse a SECOND artifact from the same pieces for the linter /
|
|
131
|
-
* IDE / language-service driver. Two compilations of one grammar, decided here, rather
|
|
132
|
-
* than one artifact deciding per node on every parse.
|
|
125
|
+
* Host mode for the composed grammar, same meaning as `compile(g, { hostMode })`.
|
|
126
|
+
* The interpreter routes by host at parse time; this records `'cst'` on every rule
|
|
127
|
+
* so `run()` can refuse a mismatched host instead of building the wrong tree.
|
|
133
128
|
*/
|
|
134
129
|
opts?: {
|
|
135
130
|
hostMode?: HostMode;
|
|
136
|
-
}): Record<string,
|
|
131
|
+
}): Record<string, Runnable>;
|
|
137
132
|
/**
|
|
138
|
-
* Compose a
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* Under the macro this lowers to STATIC fused source (functions), exactly like
|
|
142
|
-
* `compose()`. It is still macro-only as a *compiled* artifact: without macro
|
|
143
|
-
* lowering there is no safe way to keep lexical builders out of carried IR, so it
|
|
144
|
-
* never falls back to runtime CODEGEN composition.
|
|
145
|
-
*
|
|
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.
|
|
133
|
+
* Compose a TERMINAL grammar: a leaf parser that overlays local semantic reductions
|
|
134
|
+
* on reusable recognition rules. Under the macro it lowers to a static table exactly
|
|
135
|
+
* like `compose()` and must: there is no runtime codegen fallback.
|
|
149
136
|
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
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.
|
|
137
|
+
* At runtime it is the same lazy link as `compose()`, marked terminal. The bench and
|
|
138
|
+
* differential harnesses import un-macro'd grammar modules and run this path.
|
|
164
139
|
*/
|
|
165
140
|
export declare function composeLeaf(items: Array<LinkableTable | Record<string, unknown>>): Record<string, Runnable>;
|
|
166
|
-
/** Whether `map` is
|
|
167
|
-
*
|
|
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. */
|
|
141
|
+
/** Whether `map` is a runtime composition (a combinator map) rather than a
|
|
142
|
+
* build-compiled one (a table). INTERNAL — diagnostics only. */
|
|
170
143
|
export declare function isInterpretedFuse(map: object): boolean;
|
|
171
144
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* No codegen, no `new Function`, no macro build step: the result is a plain map of
|
|
176
|
-
* combinators that `run()` / `parseDoc()` accept exactly like a fused map.
|
|
177
|
-
*
|
|
178
|
-
* This is what diagnostics and profiling run against — they must stay in
|
|
179
|
-
* interpreted mode, and before this they could not see a composed grammar at all.
|
|
180
|
-
*
|
|
181
|
-
* Items are the SAME items `compose()`/`composeLeaf()` take: `rules()` maps
|
|
182
|
-
* (the intended input), a prior `fuseInterpreted()` result, or a runtime
|
|
183
|
-
* `compose()` result (re-lowered from its carried IR — note that carried IR cannot
|
|
184
|
-
* materialize direct `node()` builders, so prefer the source maps). A precompiled
|
|
185
|
-
* `linkable()` artifact is rejected: it has no combinator graph.
|
|
186
|
-
*
|
|
187
|
-
* MUTATION: binding a cross-piece hole rewrites the shared placeholder object every
|
|
188
|
-
* call site already holds — that IS how an override reaches a base piece's own
|
|
189
|
-
* calls. A second, DIFFERENT fusion over the same piece objects therefore throws
|
|
190
|
-
* rather than silently rewriting the first one's parser.
|
|
145
|
+
* The linked interpreter map for a composition, as plain combinators — what
|
|
146
|
+
* diagnostics and profiling walk. The same link `compose()` makes, forced now.
|
|
147
|
+
* INTERNAL: not re-exported from `src/index.ts`.
|
|
191
148
|
*/
|
|
192
149
|
export declare function fuseInterpreted(items: Array<LinkableTable | Record<string, unknown>>, opts?: {
|
|
193
150
|
hostMode?: HostMode;
|
|
@@ -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":"AAeA,OAAO,EAAsC,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACvF,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAA;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tD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACrD,IAAI,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,QAAQ,CAAA;CAAE,GAC7B,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAGrC"}
|
|
@@ -239,6 +239,10 @@ function firstSetBody(p, seen, resolve, activeTrivia) {
|
|
|
239
239
|
case "node":
|
|
240
240
|
case "sepBy":
|
|
241
241
|
case "expect":
|
|
242
|
+
// A transaction accepts exactly what its inner accepts. Its own `_meta` is
|
|
243
|
+
// the inner's construction-time set, which reads `any` when the inner opens
|
|
244
|
+
// with a rule reference — resolve through it like any other wrapper.
|
|
245
|
+
case "attempt":
|
|
242
246
|
return fs(d.parser);
|
|
243
247
|
case "grammar":
|
|
244
248
|
return firstSetOf(
|