parseman 0.50.0 → 0.50.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.
@@ -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;AAwBhF,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,CAAC,QAAQ,CAAC,EAAE,mBAAmB,CAAA;CACxC,CAAA;AAurDD,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,EAC5C,QAAQ,GAAE,aAAkB,GAC3B,YAAY,CAEd;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,EAC5C,QAAQ,GAAE,aAAkB,GAC3B;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAA;CAAE,CA+BnD"}
1
+ {"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../src/table/encode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,UAAU,EAAuB,MAAM,aAAa,CAAA;AAwBhF,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,CAAC,QAAQ,CAAC,EAAE,mBAAmB,CAAA;CACxC,CAAA;AA2sDD,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,EAC5C,QAAQ,GAAE,aAAkB,GAC3B,YAAY,CAEd;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,EAC5C,QAAQ,GAAE,aAAkB,GAC3B;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAA;CAAE,CA+BnD"}
@@ -11991,6 +11991,22 @@ var Encoder = class {
11991
11991
  choiceRollbackMasks = /* @__PURE__ */ new Map();
11992
11992
  nonCommittingChoiceSites = /* @__PURE__ */ new Set();
11993
11993
  failureRollbackCleanSites = /* @__PURE__ */ new Set();
11994
+ /**
11995
+ * `hasSideWriter` memo for `failureNeedsRollback`, shared across every call
11996
+ * for the lifetime of this `Encoder`. A cached entry is written only when
11997
+ * `complete` is true, which means the answer is a path-independent fact
11998
+ * about that combinator node — it does not depend on which root's traversal
11999
+ * asked, only on the node's own reachable subgraph. Scoping the memo per call
12000
+ * (as a local inside `failureNeedsRollback`) was correct but discarded that
12001
+ * fact after every arm, so a grammar with many ordered-choice arms / optional
12002
+ * / attempt sites re-walked the SAME shared rule graph from scratch for each
12003
+ * site — O(sites × graph size) instead of O(graph size). Measured on the
12004
+ * scss-parser grammar (composed CSS-base superset, the deepest/largest of the
12005
+ * four grammars): 47-50s for one `compileRuleMap` with the per-call memo,
12006
+ * versus the whole macro transform completing in under a second once this
12007
+ * memo is hoisted here.
12008
+ */
12009
+ sideWriterMemo = /* @__PURE__ */ new Map();
11994
12010
  labels = void 0;
11995
12011
  /** Trivia table in scope at the row being encoded — codegen's `ctx.activeTrivia`. */
11996
12012
  activeTrivia = void 0;
@@ -12416,13 +12432,13 @@ var Encoder = class {
12416
12432
  const refName = p._ruleName;
12417
12433
  const winner = refName === void 0 ? void 0 : this.winners?.[refName];
12418
12434
  const root = winner !== void 0 && !winnerWrapsReference2(winner, p) ? winner : p;
12419
- const sideWriterMemo = /* @__PURE__ */ new Map();
12420
- const hasSideWriter = (current, seen = /* @__PURE__ */ new Set()) => {
12435
+ const sideWriterMemo = this.sideWriterMemo;
12436
+ const seen = /* @__PURE__ */ new Set();
12437
+ const hasSideWriter = (current) => {
12421
12438
  const cached = sideWriterMemo.get(current);
12422
12439
  if (cached !== void 0) return { found: cached, complete: true };
12423
12440
  if (seen.has(current)) return { found: false, complete: false };
12424
- const next = new Set(seen);
12425
- next.add(current);
12441
+ seen.add(current);
12426
12442
  const def = current._def;
12427
12443
  let result;
12428
12444
  switch (def.tag) {
@@ -12437,11 +12453,11 @@ var Encoder = class {
12437
12453
  const name = current._ruleName;
12438
12454
  const resolvedWinner = name === void 0 ? void 0 : this.winners?.[name];
12439
12455
  if (resolvedWinner !== void 0 && !winnerWrapsReference2(resolvedWinner, current)) {
12440
- result = hasSideWriter(resolvedWinner, next);
12456
+ result = hasSideWriter(resolvedWinner);
12441
12457
  break;
12442
12458
  }
12443
12459
  try {
12444
- result = hasSideWriter(def.thunk(), next);
12460
+ result = hasSideWriter(def.thunk());
12445
12461
  } catch {
12446
12462
  result = { found: true, complete: true };
12447
12463
  }
@@ -12451,7 +12467,7 @@ var Encoder = class {
12451
12467
  let complete = true;
12452
12468
  result = { found: false, complete: true };
12453
12469
  for (const child of childrenOf(def)) {
12454
- const childResult = hasSideWriter(child, next);
12470
+ const childResult = hasSideWriter(child);
12455
12471
  if (childResult.found) {
12456
12472
  result = { found: true, complete: true };
12457
12473
  break;
@@ -12461,6 +12477,7 @@ var Encoder = class {
12461
12477
  if (!result.found) result = { found: false, complete };
12462
12478
  }
12463
12479
  }
12480
+ seen.delete(current);
12464
12481
  if (result.found || result.complete) sideWriterMemo.set(current, result.found);
12465
12482
  return result;
12466
12483
  };