parseman 0.60.4 → 0.60.6
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 +31 -5
- package/dist/analysis/diagnostics.js.map +1 -1
- package/dist/cli/index.js +639 -613
- package/dist/cli/index.js.map +3 -3
- package/dist/combinators/parser.d.ts +34 -3
- package/dist/combinators/parser.d.ts.map +1 -1
- package/dist/combinators/trivia-boundary.d.ts +5 -3
- package/dist/combinators/trivia-boundary.d.ts.map +1 -1
- package/dist/compiler/compile-linkable-table.d.ts.map +1 -1
- package/dist/compiler/linker.d.ts +11 -3
- package/dist/compiler/linker.d.ts.map +1 -1
- package/dist/compiler/token-capability.js +6 -0
- package/dist/compiler/token-capability.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +93 -25
- package/dist/index.js.map +1 -1
- package/dist/plugin/evaluator.d.ts +3 -1
- package/dist/plugin/evaluator.d.ts.map +1 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +116 -75
- package/dist/plugin/index.js.map +1 -1
- package/dist/spec/index.js +3 -1
- package/dist/spec/index.js.map +1 -1
- package/dist/spec/model.d.ts.map +1 -1
- package/dist/table/assemble.d.ts.map +1 -1
- package/dist/table/emit-assembly.d.ts.map +1 -1
- package/dist/table/encode.d.ts.map +1 -1
- package/dist/table/exec.d.ts.map +1 -1
- package/dist/table/index.js +31 -5
- package/dist/table/index.js.map +1 -1
- package/dist/table/ops.d.ts +6 -0
- package/dist/table/ops.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/combinators/grammar.ts +1 -1
- package/src/combinators/parser.ts +82 -9
- package/src/combinators/trivia-boundary.ts +11 -3
- package/src/compiler/compile-linkable-table.ts +4 -1
- package/src/compiler/ir-serialize.ts +10 -4
- package/src/compiler/linker.ts +22 -12
- package/src/index.ts +2 -1
- package/src/plugin/evaluator.ts +16 -5
- package/src/plugin/index.ts +27 -104
- package/src/spec/model.ts +3 -1
- package/src/table/assemble.ts +11 -1
- package/src/table/emit-assembly.ts +10 -1
- package/src/table/encode.ts +16 -9
- package/src/table/exec.ts +11 -9
- package/src/table/ops.ts +6 -0
- package/src/table/site-labels.ts +3 -3
- package/src/version.ts +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Combinator } from '../types.ts';
|
|
2
2
|
import type { HostMode } from '../cst/host-mode.ts';
|
|
3
|
+
import type { Runnable } from '../functional/run.ts';
|
|
3
4
|
import { NODE_TAG, NODE_TYPE, type GrammarWithReflection } from '../cst/reflection.ts';
|
|
4
5
|
/**
|
|
5
6
|
* Non-enumerable key on a `rules()` result holding the factory's declaration
|
|
@@ -7,6 +8,8 @@ import { NODE_TAG, NODE_TYPE, type GrammarWithReflection } from '../cst/reflecti
|
|
|
7
8
|
* reference-creation key order. Read by `parseman/spec` for source-order output.
|
|
8
9
|
*/
|
|
9
10
|
export declare const RULE_ORDER = "__parsemanRuleOrder";
|
|
11
|
+
/** The rule name a `prior.X` placeholder stands for (see `linkRules`), or `undefined`. */
|
|
12
|
+
export declare function priorNameOf(r: Combinator<unknown>): string | undefined;
|
|
10
13
|
/**
|
|
11
14
|
* Define named grammar rules without forward declarations.
|
|
12
15
|
*
|
|
@@ -92,8 +95,36 @@ type RuleMapNodeTag<T extends Record<string, Combinator<unknown>>> = {
|
|
|
92
95
|
[K in keyof T & string]: RuleNodeTag<T[K]>;
|
|
93
96
|
}[keyof T & string];
|
|
94
97
|
type RulesResult<T extends Record<string, Combinator<unknown>>> = T & GrammarWithReflection<RuleMapNodeType<T>, RuleMapNodeTag<T>>;
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
/**
|
|
99
|
+
* The second parameter of a `rules((g, prior) => …)` factory. `prior.X` is the
|
|
100
|
+
* definition of `X` that the grammars composed BEFORE this one gave it, with a
|
|
101
|
+
* top-level `node()` unwrapped to its body, so a composing grammar can re-reduce,
|
|
102
|
+
* wrap or extend an inherited rule without re-spelling it:
|
|
103
|
+
*
|
|
104
|
+
* rules((g, prior: PriorRules<typeof css>) => ({
|
|
105
|
+
* Value: node('Value', prior.Value, reduceValue),
|
|
106
|
+
* }))
|
|
107
|
+
*
|
|
108
|
+
* Naming the base grammar types `prior.X`, and a misspelled rule fails to compile.
|
|
109
|
+
*
|
|
110
|
+
* Its `g.X` references stay bound to the composition (open recursion). A rule's value
|
|
111
|
+
* is `unknown` here, because unwrapping a `node()` changes it. Unnamed, the parameter
|
|
112
|
+
* answers any string, which `noUncheckedIndexedAccess` reads as possibly undefined.
|
|
113
|
+
* See `docs/guide/extending.md`.
|
|
114
|
+
*/
|
|
115
|
+
export type PriorRules<Base = Record<string, Combinator<unknown>>> = [
|
|
116
|
+
KnownRuleNames<Base>
|
|
117
|
+
] extends [never] ? {
|
|
118
|
+
readonly [name: string]: Combinator<unknown>;
|
|
119
|
+
} : {
|
|
120
|
+
readonly [K in KnownRuleNames<Base>]: Combinator<unknown>;
|
|
121
|
+
};
|
|
122
|
+
/** The rule names a grammar's type spells out: not its index signature, if it has one. */
|
|
123
|
+
export type KnownRuleNames<Base> = keyof {
|
|
124
|
+
[K in keyof Base as string extends K ? never : number extends K ? never : Base[K] extends Combinator<unknown> | Runnable ? K : never]: unknown;
|
|
125
|
+
} & string;
|
|
126
|
+
export declare function rules<T extends Record<string, Combinator<unknown>>, P extends object = PriorRules>(factory: (self: any, prior: P) => T): RulesResult<T>;
|
|
127
|
+
export declare function rules<T extends Record<string, Combinator<unknown>>, P extends object = PriorRules>(options: RulesOptions, factory: (self: any, prior: P) => T): RulesResult<T>;
|
|
97
128
|
/**
|
|
98
129
|
* The recipe a `rules()` result was built from — its factory and options —
|
|
99
130
|
* non-enumerable, in piece order. Runtime `compose()` links grammars by running
|
|
@@ -103,7 +134,7 @@ export declare function rules<T extends Record<string, Combinator<unknown>>>(opt
|
|
|
103
134
|
*/
|
|
104
135
|
export declare const RULES_RECIPE: unique symbol;
|
|
105
136
|
export type RulesRecipe = {
|
|
106
|
-
readonly factory: (self: Record<string, Combinator<unknown
|
|
137
|
+
readonly factory: (self: Record<string, Combinator<unknown>>, prior: PriorRules) => Record<string, Combinator<unknown>>;
|
|
107
138
|
readonly options: RulesOptions | undefined;
|
|
108
139
|
};
|
|
109
140
|
/**
|
|
@@ -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;
|
|
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;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAKpD,OAAO,EAA4B,QAAQ,EAAE,SAAS,EAAE,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAGhH;;;;GAIG;AACH,eAAO,MAAM,UAAU,wBAAwB,CAAA;AAiB/C,0FAA0F;AAC1F,wBAAgB,WAAW,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,CAEtE;AAuCD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;8EAC0E;IAC1E,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAAA;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,GAAG,IAA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O,MAAM,YAAY,eAAqC,CAAA;AAC9D,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,KAAK,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAA;IACvH,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,CAAA;CAC3C,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,SAAS,CAAA;IACjD,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CACzC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,SAAS,WAAW,EAAE,EAC/B,IAAI,CAAC,EAAE,WAAW,GACjB,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CA0IrC"}
|
|
@@ -16,9 +16,11 @@ import type { Combinator } from '../types.ts';
|
|
|
16
16
|
*
|
|
17
17
|
* `lazy` is deliberately false and is never followed: a reference is the
|
|
18
18
|
* delegation this question is about, so following it would both loop and answer
|
|
19
|
-
* for a different rule. `grammar`
|
|
20
|
-
* an outer install never reaches its body
|
|
21
|
-
*
|
|
19
|
+
* for a different rule. A `grammar` that names or clears trivia declares its own
|
|
20
|
+
* scope, so an outer install never reaches its body and the answer is false; one
|
|
21
|
+
* that does not (`parser({ trackLines: true }, …)`, which `rules({ trackLines })`
|
|
22
|
+
* wraps every rule in) inherits, so it is transparent. `dispatch` is false because
|
|
23
|
+
* it is a ROUTE: its arms re-enter from the routed token and spell their own padding.
|
|
22
24
|
*
|
|
23
25
|
* Structural and pure — callers resolve it ONCE, not per parse.
|
|
24
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trivia-boundary.d.ts","sourceRoot":"","sources":["../../src/combinators/trivia-boundary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,aAAa,CAAA;AAKxD
|
|
1
|
+
{"version":3,"file":"trivia-boundary.d.ts","sourceRoot":"","sources":["../../src/combinators/trivia-boundary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,aAAa,CAAA;AAKxD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,KAAK,GAAE,MAAkB,GAAG,OAAO,CAyB/F;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,GACpG,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,CAIxC"}
|
|
@@ -1 +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,EAA4B,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;
|
|
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,EAA4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AM,EACV,IAAI,GAAE,oBAAyB,GAC9B,aAAa,GAAG,IAAI,CAwDtB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type HostMode } from '../cst/host-mode.ts';
|
|
2
2
|
import { type LinkableTable } from './compile-linkable-table.ts';
|
|
3
|
+
import { type KnownRuleNames } from '../combinators/parser.ts';
|
|
3
4
|
import type { BuildHost, Combinator, CstCollapsePredicate, ParseContext, ParseResult } from '../types.ts';
|
|
4
5
|
import type { Runnable } from '../functional/run.ts';
|
|
5
6
|
export declare function linkable(rulesMap: Record<string, Combinator<unknown>>, ns?: string, trivia?: Combinator<unknown>, hostMode?: HostMode): LinkableTable;
|
|
@@ -111,6 +112,13 @@ export declare function linkedWinnersOf(rule: Combinator<unknown>): Record<strin
|
|
|
111
112
|
export declare function danglingReference(map: Record<string, Combinator<unknown>>,
|
|
112
113
|
/** Names read through `g` that `map` itself does not hold (a merge-by-name fuse drops them). */
|
|
113
114
|
accessed?: Iterable<string>): string | undefined;
|
|
115
|
+
/** The rules each item spells out. An item that spells out none, such as a plain
|
|
116
|
+
* `Record<string, …>`, could hold anything, so the whole result stays open. */
|
|
117
|
+
type ItemRuleNames<Item> = Item extends unknown ? [KnownRuleNames<Item>] extends [never] ? string : KnownRuleNames<Item> : never;
|
|
118
|
+
/** A composition's rules: every name its items spell out, plus lookup by any string. */
|
|
119
|
+
export type ComposedRules<Items extends readonly unknown[]> = Record<string, Runnable> & {
|
|
120
|
+
[K in ItemRuleNames<Items[number]>]: Runnable;
|
|
121
|
+
};
|
|
114
122
|
/**
|
|
115
123
|
* Compose grammars into ONE parser map — the only public composition entry point.
|
|
116
124
|
* `compose([base, ext, …])`: a later entry's rule WINS by name, and because every
|
|
@@ -127,7 +135,7 @@ accessed?: Iterable<string>): string | undefined;
|
|
|
127
135
|
* costs a walk of the items' declared names. For speed, `compile()` a rule of it;
|
|
128
136
|
* `compile()` specialises when the environment allows and falls back under CSP.
|
|
129
137
|
*/
|
|
130
|
-
export declare function compose
|
|
138
|
+
export declare function compose<const Items extends ReadonlyArray<LinkableTable | Record<string, unknown>>>(items: Items,
|
|
131
139
|
/**
|
|
132
140
|
* Host mode for the composed grammar, same meaning as `compile(g, { hostMode })`.
|
|
133
141
|
* The interpreter routes by host at parse time; this records `'cst'` on every rule
|
|
@@ -135,7 +143,7 @@ export declare function compose(items: Array<LinkableTable | Record<string, unkn
|
|
|
135
143
|
*/
|
|
136
144
|
opts?: {
|
|
137
145
|
hostMode?: HostMode;
|
|
138
|
-
}):
|
|
146
|
+
}): ComposedRules<Items>;
|
|
139
147
|
/**
|
|
140
148
|
* Compose a TERMINAL grammar: a leaf parser that overlays local semantic reductions
|
|
141
149
|
* on reusable recognition rules. Under the macro it lowers to a static table exactly
|
|
@@ -144,7 +152,7 @@ opts?: {
|
|
|
144
152
|
* At runtime it is the same lazy link as `compose()`, marked terminal. The bench and
|
|
145
153
|
* differential harnesses import un-macro'd grammar modules and run this path.
|
|
146
154
|
*/
|
|
147
|
-
export declare function composeLeaf
|
|
155
|
+
export declare function composeLeaf<const Items extends ReadonlyArray<LinkableTable | Record<string, unknown>>>(items: Items): ComposedRules<Items>;
|
|
148
156
|
/** Whether `map` is a runtime composition (a combinator map) rather than a
|
|
149
157
|
* build-compiled one (a table). INTERNAL — diagnostics only. */
|
|
150
158
|
export declare function isInterpretedFuse(map: object): boolean;
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,a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,CAAC,GAAG,QAAQ;CAAE,CAAA;AAE9E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,OAAO,CAAC,KAAK,CAAC,KAAK,SAAS,aAAa,CAAC,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAChG,KAAK,EAAE,KAAK;AACZ;;;;GAIG;AACH,IAAI,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,QAAQ,CAAA;CAAE,GAC7B,aAAa,CAAC,KAAK,CAAC,CAKtB;AA6BD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,CAAC,KAAK,SAAS,aAAa,CAAC,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACpG,KAAK,EAAE,KAAK,GACX,aAAa,CAAC,KAAK,CAAC,CAEtB;AAED;gEACgE;AAChE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEtD;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"}
|
|
@@ -33,6 +33,12 @@ function hasOwnTriviaBoundary(p, depth = MAX_DEPTH) {
|
|
|
33
33
|
case "oneOrMore":
|
|
34
34
|
case "sepBy":
|
|
35
35
|
return true;
|
|
36
|
+
// A scope that names or clears trivia keeps an outer install out of its body.
|
|
37
|
+
// Any other inherits, so it falls through at no cost in depth: line tracking
|
|
38
|
+
// wraps every rule in one, and must not change what this walk sees.
|
|
39
|
+
case "grammar":
|
|
40
|
+
if (d.triviaParser || d.clearTrivia) return false;
|
|
41
|
+
depth++;
|
|
36
42
|
// Transparent wrappers — they add no position, so ask what they wrap.
|
|
37
43
|
case "node":
|
|
38
44
|
case "transform":
|