parseman 0.55.0 → 0.55.2
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 +27 -2
- package/dist/analysis/commitment.d.ts.map +1 -1
- package/dist/analysis/diagnostics.js +110 -80
- package/dist/analysis/diagnostics.js.map +2 -2
- package/dist/cli/index.js +110 -80
- package/dist/cli/index.js.map +2 -2
- package/dist/index.js +111 -81
- package/dist/index.js.map +2 -2
- package/dist/plugin/index.js +111 -81
- package/dist/plugin/index.js.map +2 -2
- package/dist/table/encode.d.ts.map +1 -1
- package/dist/table/index.js +110 -80
- package/dist/table/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/analysis/commitment.ts +107 -20
- package/src/table/encode.ts +47 -70
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../src/table/encode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,UAAU,EAAuB,MAAM,aAAa,CAAA;AAyBhF,OAAO,KAAK,EAAmE,YAAY,EAAc,MAAM,cAAc,CAAA;AAS7H,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AA0B9E,8EAA8E;AAC9E,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,YAAY,GAAG,EAAE,MAAM,EAAqE;CAC7F;AAED,8EAA8E;AAC9E,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,GAAG,KAAK,CAAA;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;IAC7B;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B;;;;;;;;;;;;;OAaG;IACH,QAAQ,C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function hasDirectBuildDef(p, seen = /* @__PURE__ */ new Set()) {
|
|
|
11952
11952
|
return false;
|
|
11953
11953
|
}
|
|
11954
11954
|
}
|
|
11955
|
-
function mayCommitFailure(p,
|
|
11956
|
-
|
|
11957
|
-
|
|
11955
|
+
function mayCommitFailure(p, resolve, memo = /* @__PURE__ */ new Map()) {
|
|
11956
|
+
return reachesMarked(p, (node) => commitFailureSuccessors(node, resolve), memo);
|
|
11957
|
+
}
|
|
11958
|
+
var NO_EDGES = [];
|
|
11959
|
+
function commitFailureSuccessors(p, resolve) {
|
|
11958
11960
|
const d = p._def;
|
|
11959
11961
|
switch (d.tag) {
|
|
11960
11962
|
case "dispatch":
|
|
11963
|
+
case "unknown":
|
|
11961
11964
|
return true;
|
|
11962
11965
|
case "choice":
|
|
11963
11966
|
case "sequence":
|
|
11964
|
-
return d.parsers
|
|
11967
|
+
return d.parsers;
|
|
11965
11968
|
// A contained transaction reports every failure uncommitted.
|
|
11966
11969
|
case "attempt":
|
|
11967
|
-
return d.contain
|
|
11970
|
+
return d.contain === true ? NO_EDGES : [d.parser];
|
|
11968
11971
|
case "many":
|
|
11969
11972
|
case "oneOrMore":
|
|
11970
11973
|
case "optional":
|
|
@@ -11973,31 +11976,77 @@ function mayCommitFailure(p, seen = /* @__PURE__ */ new Set(), resolve) {
|
|
|
11973
11976
|
case "field":
|
|
11974
11977
|
case "grammar":
|
|
11975
11978
|
case "node":
|
|
11976
|
-
return mayCommitFailure(d.parser, seen, resolve);
|
|
11977
|
-
case "sepBy":
|
|
11978
|
-
return mayCommitFailure(d.parser, seen, resolve) || mayCommitFailure(d.separator, seen, resolve);
|
|
11979
11979
|
case "token":
|
|
11980
11980
|
case "leaf":
|
|
11981
|
-
return mayCommitFailure(d.parser, seen, resolve);
|
|
11982
11981
|
case "withCtx":
|
|
11983
|
-
return
|
|
11982
|
+
return [d.parser];
|
|
11983
|
+
case "sepBy":
|
|
11984
|
+
return [d.parser, d.separator];
|
|
11984
11985
|
case "scanTo":
|
|
11985
|
-
return
|
|
11986
|
+
return [
|
|
11987
|
+
d.sentinel,
|
|
11988
|
+
...d.skip,
|
|
11989
|
+
...d.recoverAt === void 0 ? NO_EDGES : [d.recoverAt],
|
|
11990
|
+
...d.stopAt === void 0 ? NO_EDGES : [d.stopAt]
|
|
11991
|
+
];
|
|
11986
11992
|
case "lazy": {
|
|
11987
11993
|
try {
|
|
11988
|
-
return
|
|
11994
|
+
return [d.thunk()];
|
|
11989
11995
|
} catch {
|
|
11990
11996
|
const name = p._ruleName;
|
|
11991
11997
|
const target = name === void 0 ? void 0 : resolve?.(name);
|
|
11992
|
-
return target === void 0 ? true :
|
|
11998
|
+
return target === void 0 ? true : [target];
|
|
11993
11999
|
}
|
|
11994
12000
|
}
|
|
11995
|
-
case "unknown":
|
|
11996
|
-
return true;
|
|
11997
12001
|
default:
|
|
11998
|
-
return
|
|
12002
|
+
return NO_EDGES;
|
|
11999
12003
|
}
|
|
12000
12004
|
}
|
|
12005
|
+
function reachesMarked(root, successors, memo) {
|
|
12006
|
+
const known = memo.get(root);
|
|
12007
|
+
if (known !== void 0) return known;
|
|
12008
|
+
const order = /* @__PURE__ */ new Map();
|
|
12009
|
+
const low = [];
|
|
12010
|
+
const found = [];
|
|
12011
|
+
const stack = [];
|
|
12012
|
+
const visit = (node) => {
|
|
12013
|
+
const at = low.length;
|
|
12014
|
+
order.set(node, at);
|
|
12015
|
+
low.push(at);
|
|
12016
|
+
found.push(false);
|
|
12017
|
+
stack.push(node);
|
|
12018
|
+
const next = successors(node);
|
|
12019
|
+
if (next === true) found[at] = true;
|
|
12020
|
+
else {
|
|
12021
|
+
for (const child of next) {
|
|
12022
|
+
if (found[at]) break;
|
|
12023
|
+
const hit = memo.get(child);
|
|
12024
|
+
if (hit !== void 0) {
|
|
12025
|
+
if (hit) found[at] = true;
|
|
12026
|
+
continue;
|
|
12027
|
+
}
|
|
12028
|
+
const seen = order.get(child);
|
|
12029
|
+
if (seen !== void 0) {
|
|
12030
|
+
if (seen < low[at]) low[at] = seen;
|
|
12031
|
+
continue;
|
|
12032
|
+
}
|
|
12033
|
+
const k = visit(child);
|
|
12034
|
+
if (low[k] < low[at]) low[at] = low[k];
|
|
12035
|
+
if (found[k]) found[at] = true;
|
|
12036
|
+
}
|
|
12037
|
+
}
|
|
12038
|
+
if (low[at] === at) {
|
|
12039
|
+
const answer = found[at];
|
|
12040
|
+
let member;
|
|
12041
|
+
do {
|
|
12042
|
+
member = stack.pop();
|
|
12043
|
+
memo.set(member, answer);
|
|
12044
|
+
} while (member !== node);
|
|
12045
|
+
}
|
|
12046
|
+
return at;
|
|
12047
|
+
};
|
|
12048
|
+
return found[visit(root)];
|
|
12049
|
+
}
|
|
12001
12050
|
|
|
12002
12051
|
// src/compiler/direct-projection.ts
|
|
12003
12052
|
function directArrayProjection(fn, fnSrc, arity) {
|
|
@@ -12421,21 +12470,20 @@ var Encoder = class {
|
|
|
12421
12470
|
nonCommittingChoiceSites = /* @__PURE__ */ new Set();
|
|
12422
12471
|
failureRollbackCleanSites = /* @__PURE__ */ new Set();
|
|
12423
12472
|
/**
|
|
12424
|
-
* `
|
|
12425
|
-
* for the lifetime of this `Encoder`.
|
|
12426
|
-
*
|
|
12427
|
-
*
|
|
12428
|
-
*
|
|
12429
|
-
* (as a local inside `failureNeedsRollback`) was correct but discarded that
|
|
12430
|
-
* fact after every arm, so a grammar with many ordered-choice arms / optional
|
|
12431
|
-
* / attempt sites re-walked the SAME shared rule graph from scratch for each
|
|
12432
|
-
* site — O(sites × graph size) instead of O(graph size). Measured on the
|
|
12433
|
-
* scss-parser grammar (composed CSS-base superset, the deepest/largest of the
|
|
12434
|
-
* four grammars): 47-50s for one `compileRuleMap` with the per-call memo,
|
|
12435
|
-
* versus the whole macro transform completing in under a second once this
|
|
12436
|
-
* memo is hoisted here.
|
|
12473
|
+
* `reachesSideWriter`'s answers, shared by every `failureNeedsRollback` call
|
|
12474
|
+
* for the lifetime of this `Encoder`. Every entry is exact — it depends only on
|
|
12475
|
+
* the node's own reachable subgraph, never on which root's walk asked — so each
|
|
12476
|
+
* combinator is walked once per encode however many choice arms, optionals and
|
|
12477
|
+
* attempt sites reach it.
|
|
12437
12478
|
*/
|
|
12438
12479
|
sideWriterMemo = /* @__PURE__ */ new Map();
|
|
12480
|
+
/**
|
|
12481
|
+
* `mayCommitFailure`'s answers, shared by every choice site for the lifetime
|
|
12482
|
+
* of this `Encoder` — exact for the graph and the `winners` resolver it is
|
|
12483
|
+
* encoding, so the rule graph is walked once per encode rather than once per
|
|
12484
|
+
* choice site.
|
|
12485
|
+
*/
|
|
12486
|
+
commitFailureMemo = /* @__PURE__ */ new Map();
|
|
12439
12487
|
labels = void 0;
|
|
12440
12488
|
/** Trivia table in scope at the row being encoded — codegen's `ctx.activeTrivia`. */
|
|
12441
12489
|
activeTrivia = void 0;
|
|
@@ -12866,63 +12914,45 @@ var Encoder = class {
|
|
|
12866
12914
|
* writer census covers the side sinks that proof deliberately does not model:
|
|
12867
12915
|
* fields, recovered errors, and interpreted scanners. Strict assemblies do
|
|
12868
12916
|
* not run repeat recovery, but these rows can still publish through a caller's
|
|
12869
|
-
* context.
|
|
12870
|
-
* discover a writer the first traversal did not already reach.
|
|
12917
|
+
* context.
|
|
12871
12918
|
*/
|
|
12872
12919
|
failureNeedsRollback(p, autoNot) {
|
|
12873
12920
|
const refName = p._ruleName;
|
|
12874
12921
|
const winner = refName === void 0 ? void 0 : this.winners?.[refName];
|
|
12875
12922
|
const root = winner !== void 0 && !winnerWrapsReference2(winner, p) ? winner : p;
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
12883
|
-
|
|
12884
|
-
|
|
12885
|
-
|
|
12886
|
-
|
|
12887
|
-
|
|
12888
|
-
|
|
12889
|
-
|
|
12890
|
-
|
|
12891
|
-
|
|
12892
|
-
|
|
12893
|
-
|
|
12894
|
-
|
|
12895
|
-
|
|
12896
|
-
|
|
12897
|
-
|
|
12898
|
-
|
|
12899
|
-
|
|
12900
|
-
|
|
12901
|
-
|
|
12902
|
-
|
|
12903
|
-
|
|
12904
|
-
}
|
|
12905
|
-
break;
|
|
12906
|
-
}
|
|
12907
|
-
default: {
|
|
12908
|
-
let complete = true;
|
|
12909
|
-
result = { found: false, complete: true };
|
|
12910
|
-
for (const child of childrenOf(def)) {
|
|
12911
|
-
const childResult = hasSideWriter(child);
|
|
12912
|
-
if (childResult.found) {
|
|
12913
|
-
result = { found: true, complete: true };
|
|
12914
|
-
break;
|
|
12915
|
-
}
|
|
12916
|
-
complete &&= childResult.complete;
|
|
12917
|
-
}
|
|
12918
|
-
if (!result.found) result = { found: false, complete };
|
|
12923
|
+
return mayLeavePartialCapture(root, /* @__PURE__ */ new Set(), true) || this.reachesSideWriter(root) || (autoNot?.length ?? 0) > 0 && capturesLeaf(root);
|
|
12924
|
+
}
|
|
12925
|
+
/**
|
|
12926
|
+
* Whether a field, recovered error, interpreted scanner or unresolvable shape
|
|
12927
|
+
* is reachable from `root` — the writer census of `failureNeedsRollback`,
|
|
12928
|
+
* entering each combinator once per `Encoder` (see `reachesMarked`).
|
|
12929
|
+
*/
|
|
12930
|
+
reachesSideWriter(root) {
|
|
12931
|
+
return reachesMarked(root, (node) => this.sideWriterSuccessors(node), this.sideWriterMemo);
|
|
12932
|
+
}
|
|
12933
|
+
/** The census's edges out of `node`, or `true` when `node` is itself a writer. */
|
|
12934
|
+
sideWriterSuccessors(node) {
|
|
12935
|
+
const def = node._def;
|
|
12936
|
+
switch (def.tag) {
|
|
12937
|
+
case "field":
|
|
12938
|
+
case "expect":
|
|
12939
|
+
case "recover":
|
|
12940
|
+
case "scanTo":
|
|
12941
|
+
case "unknown":
|
|
12942
|
+
return true;
|
|
12943
|
+
case "lazy": {
|
|
12944
|
+
const name = node._ruleName;
|
|
12945
|
+
const winner = name === void 0 ? void 0 : this.winners?.[name];
|
|
12946
|
+
if (winner !== void 0 && !winnerWrapsReference2(winner, node)) return [winner];
|
|
12947
|
+
try {
|
|
12948
|
+
return [def.thunk()];
|
|
12949
|
+
} catch {
|
|
12950
|
+
return true;
|
|
12919
12951
|
}
|
|
12920
12952
|
}
|
|
12921
|
-
|
|
12922
|
-
|
|
12923
|
-
|
|
12924
|
-
};
|
|
12925
|
-
return mayLeavePartialCapture(root, /* @__PURE__ */ new Set(), true) || hasSideWriter(root).found || (autoNot?.length ?? 0) > 0 && capturesLeaf(root);
|
|
12953
|
+
default:
|
|
12954
|
+
return childrenOf(def);
|
|
12955
|
+
}
|
|
12926
12956
|
}
|
|
12927
12957
|
/** A first set becomes a char class string, or −1 for `any`. */
|
|
12928
12958
|
charClass(fs) {
|
|
@@ -13253,7 +13283,7 @@ var Encoder = class {
|
|
|
13253
13283
|
this.code[head + 4 + kids.length + i] = this.expected(deriveExpected(arms[i]));
|
|
13254
13284
|
}
|
|
13255
13285
|
this.choiceRollbackMasks.set(head, rollbackMask);
|
|
13256
|
-
if (arms.every((arm) => !mayCommitFailure(arm,
|
|
13286
|
+
if (arms.every((arm) => !mayCommitFailure(arm, rr, this.commitFailureMemo))) {
|
|
13257
13287
|
this.nonCommittingChoiceSites.add(head);
|
|
13258
13288
|
}
|
|
13259
13289
|
return head;
|