parseman 0.54.0 → 0.55.1
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/diagnostics.js +102 -61
- package/dist/analysis/diagnostics.js.map +2 -2
- package/dist/cli/index.js +102 -61
- package/dist/cli/index.js.map +2 -2
- package/dist/combinators/withCtx.d.ts +22 -7
- package/dist/combinators/withCtx.d.ts.map +1 -1
- package/dist/index.js +121 -71
- package/dist/index.js.map +2 -2
- package/dist/plugin/evaluator.d.ts.map +1 -1
- package/dist/plugin/index.js +126 -73
- package/dist/plugin/index.js.map +2 -2
- package/dist/table/assemble.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 +102 -61
- package/dist/table/index.js.map +2 -2
- package/dist/table/ops.d.ts +3 -1
- package/dist/table/ops.d.ts.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/combinators/withCtx.ts +61 -28
- package/src/plugin/evaluator.ts +12 -2
- package/src/table/assemble.ts +11 -1
- package/src/table/encode.ts +94 -65
- package/src/table/exec.ts +2 -1
- package/src/table/ops.ts +3 -1
- package/src/types.ts +2 -0
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assemble.d.ts","sourceRoot":"","sources":["../../src/table/assemble.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAsB,YAAY,EAA0B,MAAM,aAAa,CAAA;AA0CvG;;;;;;;;;;;;;GAaG;AACH,OAAO,EAGL,KAAK,cAAc,EAAsB,KAAK,aAAa,EAC1C,KAAK,YAAY,EAAE,KAAK,SAAS,EACnD,MAAM,cAAc,CAAA;AA6ErB;;;;;;;;;;;;;GAaG;A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BnD"}
|
package/dist/table/exec.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/table/exec.ts"],"names":[],"mappings":"AA6CA,OAAO,EAEL,KAAK,cAAc,EACF,KAAK,YAAY,EAAE,KAAK,SAAS,EACnD,MAAM,cAAc,CAAA;AA4BrB;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,EAAE;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,UAAU,CAAA;IAChB,+EAA+E;IAC/E,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;IAChC;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IACpB,sFAAsF;IACtF,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,qFAAqF;IACrF,YAAY,EAAE,MAAM,CAAA;CAC+H,CAAA;AAUrJ,wBAAgB,kBAAkB,IAAI,IAAI,CASzC;
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/table/exec.ts"],"names":[],"mappings":"AA6CA,OAAO,EAEL,KAAK,cAAc,EACF,KAAK,YAAY,EAAE,KAAK,SAAS,EACnD,MAAM,cAAc,CAAA;AA4BrB;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,EAAE;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,UAAU,CAAA;IAChB,+EAA+E;IAC/E,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;IAChC;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IACpB,sFAAsF;IACtF,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,qFAAqF;IACrF,YAAY,EAAE,MAAM,CAAA;CAC+H,CAAA;AAUrJ,wBAAgB,kBAAkB,IAAI,IAAI,CASzC;AAwlDD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,YAAY,GAAG,cAAc;AACrC;;;;;;;;GAQG;AACH,IAAI,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,EACjC,gBAAgB,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM,GACvD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CA8B3B"}
|
package/dist/table/index.js
CHANGED
|
@@ -9449,8 +9449,21 @@ function assemble(t, prog, cfg) {
|
|
|
9449
9449
|
};
|
|
9450
9450
|
}
|
|
9451
9451
|
case OP_WITHCTX: {
|
|
9452
|
-
const
|
|
9452
|
+
const ki = code[ip + 1];
|
|
9453
9453
|
const child = link(code[ip + 2]);
|
|
9454
|
+
if (ki < 0) {
|
|
9455
|
+
const derive2 = fns[~ki];
|
|
9456
|
+
return (input, pos, ctx) => {
|
|
9457
|
+
const saved = ctx.state;
|
|
9458
|
+
ctx.state = derive2(saved);
|
|
9459
|
+
try {
|
|
9460
|
+
return child(input, pos, ctx);
|
|
9461
|
+
} finally {
|
|
9462
|
+
ctx.state = saved;
|
|
9463
|
+
}
|
|
9464
|
+
};
|
|
9465
|
+
}
|
|
9466
|
+
const extra = k[ki];
|
|
9454
9467
|
return (input, pos, ctx) => {
|
|
9455
9468
|
const saved = ctx.state;
|
|
9456
9469
|
ctx.state = extra;
|
|
@@ -12408,19 +12421,11 @@ var Encoder = class {
|
|
|
12408
12421
|
nonCommittingChoiceSites = /* @__PURE__ */ new Set();
|
|
12409
12422
|
failureRollbackCleanSites = /* @__PURE__ */ new Set();
|
|
12410
12423
|
/**
|
|
12411
|
-
* `
|
|
12412
|
-
* for the lifetime of this `Encoder`.
|
|
12413
|
-
*
|
|
12414
|
-
*
|
|
12415
|
-
*
|
|
12416
|
-
* (as a local inside `failureNeedsRollback`) was correct but discarded that
|
|
12417
|
-
* fact after every arm, so a grammar with many ordered-choice arms / optional
|
|
12418
|
-
* / attempt sites re-walked the SAME shared rule graph from scratch for each
|
|
12419
|
-
* site — O(sites × graph size) instead of O(graph size). Measured on the
|
|
12420
|
-
* scss-parser grammar (composed CSS-base superset, the deepest/largest of the
|
|
12421
|
-
* four grammars): 47-50s for one `compileRuleMap` with the per-call memo,
|
|
12422
|
-
* versus the whole macro transform completing in under a second once this
|
|
12423
|
-
* memo is hoisted here.
|
|
12424
|
+
* `reachesSideWriter`'s answers, shared by every `failureNeedsRollback` call
|
|
12425
|
+
* for the lifetime of this `Encoder`. Every entry is exact — it depends only on
|
|
12426
|
+
* the node's own reachable subgraph, never on which root's walk asked — so each
|
|
12427
|
+
* combinator is walked once per encode however many choice arms, optionals and
|
|
12428
|
+
* attempt sites reach it.
|
|
12424
12429
|
*/
|
|
12425
12430
|
sideWriterMemo = /* @__PURE__ */ new Map();
|
|
12426
12431
|
labels = void 0;
|
|
@@ -12853,63 +12858,96 @@ var Encoder = class {
|
|
|
12853
12858
|
* writer census covers the side sinks that proof deliberately does not model:
|
|
12854
12859
|
* fields, recovered errors, and interpreted scanners. Strict assemblies do
|
|
12855
12860
|
* not run repeat recovery, but these rows can still publish through a caller's
|
|
12856
|
-
* context.
|
|
12857
|
-
* discover a writer the first traversal did not already reach.
|
|
12861
|
+
* context.
|
|
12858
12862
|
*/
|
|
12859
12863
|
failureNeedsRollback(p, autoNot) {
|
|
12860
12864
|
const refName = p._ruleName;
|
|
12861
12865
|
const winner = refName === void 0 ? void 0 : this.winners?.[refName];
|
|
12862
12866
|
const root = winner !== void 0 && !winnerWrapsReference2(winner, p) ? winner : p;
|
|
12863
|
-
|
|
12864
|
-
|
|
12865
|
-
|
|
12866
|
-
|
|
12867
|
-
|
|
12868
|
-
|
|
12869
|
-
|
|
12870
|
-
|
|
12871
|
-
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
12883
|
-
|
|
12884
|
-
|
|
12885
|
-
|
|
12886
|
-
|
|
12887
|
-
|
|
12888
|
-
|
|
12889
|
-
|
|
12890
|
-
|
|
12867
|
+
return mayLeavePartialCapture(root, /* @__PURE__ */ new Set(), true) || this.reachesSideWriter(root) || (autoNot?.length ?? 0) > 0 && capturesLeaf(root);
|
|
12868
|
+
}
|
|
12869
|
+
/**
|
|
12870
|
+
* Whether a field, recovered error, interpreted scanner or unresolvable shape
|
|
12871
|
+
* is reachable from `root` — the writer census of `failureNeedsRollback`.
|
|
12872
|
+
*
|
|
12873
|
+
* Reachability over a cyclic graph, decided with Tarjan's strongly connected
|
|
12874
|
+
* components so that every node the walk enters leaves with its exact answer
|
|
12875
|
+
* memoized: the members of one component reach each other, so they share one
|
|
12876
|
+
* answer, settled when the walk returns to the component's first node. A DFS
|
|
12877
|
+
* that instead cuts a cycle at its own ancestor path learns nothing it can
|
|
12878
|
+
* keep about a node whose walk hit the cut, and re-walks that node along
|
|
12879
|
+
* every path that reaches it — exponential over recursive value rules (linking
|
|
12880
|
+
* jess's SCSS grammar cost ~290G instructions). This walk enters each node
|
|
12881
|
+
* once per `Encoder`.
|
|
12882
|
+
*/
|
|
12883
|
+
reachesSideWriter(root) {
|
|
12884
|
+
const memo = this.sideWriterMemo;
|
|
12885
|
+
const known = memo.get(root);
|
|
12886
|
+
if (known !== void 0) return known;
|
|
12887
|
+
const order = /* @__PURE__ */ new Map();
|
|
12888
|
+
const low = [];
|
|
12889
|
+
const found = [];
|
|
12890
|
+
const stack = [];
|
|
12891
|
+
const visit = (node) => {
|
|
12892
|
+
const at = low.length;
|
|
12893
|
+
order.set(node, at);
|
|
12894
|
+
low.push(at);
|
|
12895
|
+
found.push(false);
|
|
12896
|
+
stack.push(node);
|
|
12897
|
+
const next = this.sideWriterSuccessors(node);
|
|
12898
|
+
if (next === true) found[at] = true;
|
|
12899
|
+
else {
|
|
12900
|
+
for (const child of next) {
|
|
12901
|
+
const hit = memo.get(child);
|
|
12902
|
+
if (hit !== void 0) {
|
|
12903
|
+
if (hit) found[at] = true;
|
|
12904
|
+
continue;
|
|
12891
12905
|
}
|
|
12892
|
-
|
|
12893
|
-
|
|
12894
|
-
|
|
12895
|
-
|
|
12896
|
-
result = { found: false, complete: true };
|
|
12897
|
-
for (const child of childrenOf(def)) {
|
|
12898
|
-
const childResult = hasSideWriter(child);
|
|
12899
|
-
if (childResult.found) {
|
|
12900
|
-
result = { found: true, complete: true };
|
|
12901
|
-
break;
|
|
12902
|
-
}
|
|
12903
|
-
complete &&= childResult.complete;
|
|
12906
|
+
const seen = order.get(child);
|
|
12907
|
+
if (seen !== void 0) {
|
|
12908
|
+
if (seen < low[at]) low[at] = seen;
|
|
12909
|
+
continue;
|
|
12904
12910
|
}
|
|
12905
|
-
|
|
12911
|
+
const k = visit(child);
|
|
12912
|
+
if (low[k] < low[at]) low[at] = low[k];
|
|
12913
|
+
if (found[k]) found[at] = true;
|
|
12906
12914
|
}
|
|
12907
12915
|
}
|
|
12908
|
-
|
|
12909
|
-
|
|
12910
|
-
|
|
12916
|
+
if (low[at] === at) {
|
|
12917
|
+
const answer = found[at];
|
|
12918
|
+
let member;
|
|
12919
|
+
do {
|
|
12920
|
+
member = stack.pop();
|
|
12921
|
+
memo.set(member, answer);
|
|
12922
|
+
} while (member !== node);
|
|
12923
|
+
}
|
|
12924
|
+
return at;
|
|
12911
12925
|
};
|
|
12912
|
-
return
|
|
12926
|
+
return found[visit(root)];
|
|
12927
|
+
}
|
|
12928
|
+
/** The census's edges out of `node`, or `true` when `node` is itself a writer. */
|
|
12929
|
+
sideWriterSuccessors(node) {
|
|
12930
|
+
const def = node._def;
|
|
12931
|
+
switch (def.tag) {
|
|
12932
|
+
case "field":
|
|
12933
|
+
case "expect":
|
|
12934
|
+
case "recover":
|
|
12935
|
+
case "scanTo":
|
|
12936
|
+
case "unknown":
|
|
12937
|
+
return true;
|
|
12938
|
+
case "lazy": {
|
|
12939
|
+
const name = node._ruleName;
|
|
12940
|
+
const winner = name === void 0 ? void 0 : this.winners?.[name];
|
|
12941
|
+
if (winner !== void 0 && !winnerWrapsReference2(winner, node)) return [winner];
|
|
12942
|
+
try {
|
|
12943
|
+
return [def.thunk()];
|
|
12944
|
+
} catch {
|
|
12945
|
+
return true;
|
|
12946
|
+
}
|
|
12947
|
+
}
|
|
12948
|
+
default:
|
|
12949
|
+
return childrenOf(def);
|
|
12950
|
+
}
|
|
12913
12951
|
}
|
|
12914
12952
|
/** A first set becomes a char class string, or −1 for `any`. */
|
|
12915
12953
|
charClass(fs) {
|
|
@@ -13426,6 +13464,9 @@ var Encoder = class {
|
|
|
13426
13464
|
this.expected([adjacencyExpected(d)])
|
|
13427
13465
|
);
|
|
13428
13466
|
case "withCtx": {
|
|
13467
|
+
if (typeof d.extra === "function") {
|
|
13468
|
+
return this.emit(OP_WITHCTX, ~this.fn(d.extra, d.extraSrc ?? null), this.node(d.parser).ip);
|
|
13469
|
+
}
|
|
13429
13470
|
if (!emittableConst(d.extra)) {
|
|
13430
13471
|
this.runtimeOnly.add("withCtx(extra) \u2014 the state object is not serialisable");
|
|
13431
13472
|
}
|