parseman 0.55.2 → 0.55.4

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/cli/index.js CHANGED
@@ -3919,14 +3919,8 @@ function choice(...args) {
3919
3919
  if (result.committed) return { ok: false, expected, span: { start: pos, end: pos }, committed: true };
3920
3920
  return { ok: false, expected, span: { start: pos, end: pos } };
3921
3921
  }
3922
- return {
3923
- ok: false,
3924
- expected: parsers.flatMap((p) => {
3925
- const r = p.parse(input, pos, ctx);
3926
- return r.ok ? [] : r.expected;
3927
- }),
3928
- span: { start: pos, end: pos }
3929
- };
3922
+ if (ctx._probe !== void 0 || ctx._tolerant) for (const p of parsers) p.parse(input, pos, ctx);
3923
+ return { ok: false, expected: [...scalarExpected], span: { start: pos, end: pos } };
3930
3924
  }
3931
3925
  if (strategy?.tag === "greedyClassify") {
3932
3926
  const superResult = parsers[strategy.superIndex].parse(input, pos, ctx);
@@ -14646,7 +14640,8 @@ function tableRules(source, metadataOrEntry = {}) {
14646
14640
  scanSkipFor: (ri, ctx) => {
14647
14641
  const a = cache.forCtx(ctx);
14648
14642
  selected = a;
14649
- return a.scanSkip[skipOf?.[ri] ?? -1];
14643
+ const slot = skipOf?.[ri];
14644
+ return slot === void 0 || slot < 0 ? void 0 : a.scanSkip[slot];
14650
14645
  }
14651
14646
  }, artifactMetadata, resolved);
14652
14647
  if (entry === void 0) return map;
@@ -17559,8 +17554,11 @@ function compileImpl(combinator, mapFnSources, opts = {}) {
17559
17554
  // falls back to regex-scanning generated hooks; a table has no hooks to scan,
17560
17555
  // so this is the channel.
17561
17556
  ...plan === void 0 ? {} : { coverageDefinitions: plan.definitions },
17562
- parse(input, pos = 0) {
17563
- return runOnce(input, pos, createParseContext());
17557
+ // The same three arguments as a combinator's own `parse`, so a compiled
17558
+ // parser runs where a combinator does. A caller probing many positions
17559
+ // passes one context and pays for none per call.
17560
+ parse(input, pos = 0, ctx) {
17561
+ return runOnce(input, pos, ctx ?? createParseContext());
17564
17562
  },
17565
17563
  parseWithContext(input, parseCtx, pos = 0) {
17566
17564
  return runOnce(input, pos, parseCtx);