parseman 0.55.1 → 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 +76 -71
- package/dist/analysis/diagnostics.js.map +2 -2
- package/dist/cli/index.js +76 -71
- package/dist/cli/index.js.map +2 -2
- package/dist/index.js +77 -72
- package/dist/index.js.map +2 -2
- package/dist/plugin/index.js +77 -72
- package/dist/plugin/index.js.map +2 -2
- package/dist/table/encode.d.ts.map +1 -1
- package/dist/table/index.js +76 -71
- 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 +12 -59
- 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) {
|
|
@@ -12428,6 +12477,13 @@ var Encoder = class {
|
|
|
12428
12477
|
* attempt sites reach it.
|
|
12429
12478
|
*/
|
|
12430
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();
|
|
12431
12487
|
labels = void 0;
|
|
12432
12488
|
/** Trivia table in scope at the row being encoded — codegen's `ctx.activeTrivia`. */
|
|
12433
12489
|
activeTrivia = void 0;
|
|
@@ -12868,62 +12924,11 @@ var Encoder = class {
|
|
|
12868
12924
|
}
|
|
12869
12925
|
/**
|
|
12870
12926
|
* 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`.
|
|
12927
|
+
* is reachable from `root` — the writer census of `failureNeedsRollback`,
|
|
12928
|
+
* entering each combinator once per `Encoder` (see `reachesMarked`).
|
|
12882
12929
|
*/
|
|
12883
12930
|
reachesSideWriter(root) {
|
|
12884
|
-
|
|
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;
|
|
12905
|
-
}
|
|
12906
|
-
const seen = order.get(child);
|
|
12907
|
-
if (seen !== void 0) {
|
|
12908
|
-
if (seen < low[at]) low[at] = seen;
|
|
12909
|
-
continue;
|
|
12910
|
-
}
|
|
12911
|
-
const k = visit(child);
|
|
12912
|
-
if (low[k] < low[at]) low[at] = low[k];
|
|
12913
|
-
if (found[k]) found[at] = true;
|
|
12914
|
-
}
|
|
12915
|
-
}
|
|
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;
|
|
12925
|
-
};
|
|
12926
|
-
return found[visit(root)];
|
|
12931
|
+
return reachesMarked(root, (node) => this.sideWriterSuccessors(node), this.sideWriterMemo);
|
|
12927
12932
|
}
|
|
12928
12933
|
/** The census's edges out of `node`, or `true` when `node` is itself a writer. */
|
|
12929
12934
|
sideWriterSuccessors(node) {
|
|
@@ -13278,7 +13283,7 @@ var Encoder = class {
|
|
|
13278
13283
|
this.code[head + 4 + kids.length + i] = this.expected(deriveExpected(arms[i]));
|
|
13279
13284
|
}
|
|
13280
13285
|
this.choiceRollbackMasks.set(head, rollbackMask);
|
|
13281
|
-
if (arms.every((arm) => !mayCommitFailure(arm,
|
|
13286
|
+
if (arms.every((arm) => !mayCommitFailure(arm, rr, this.commitFailureMemo))) {
|
|
13282
13287
|
this.nonCommittingChoiceSites.add(head);
|
|
13283
13288
|
}
|
|
13284
13289
|
return head;
|