parseman 0.48.0 → 0.48.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.
@@ -3348,6 +3348,7 @@ function choice(...args) {
3348
3348
  },
3349
3349
  parse(input, pos, ctx) {
3350
3350
  const expected = [];
3351
+ let expectedAt = pos;
3351
3352
  if (disjoint) {
3352
3353
  const code = pos < input.length ? input.codePointAt(pos) : -1;
3353
3354
  let idx = code >= 0 && code < 128 ? asciiDispatch[code] : -1;
@@ -3405,7 +3406,12 @@ function choice(...args) {
3405
3406
  const result = parsers[i].parse(input, pos, ctx);
3406
3407
  if (!result.ok) {
3407
3408
  rollbackTrivia(ctx, mark);
3408
- expected.push(...result.expected);
3409
+ const at = result.span.start;
3410
+ if (at > expectedAt) {
3411
+ expectedAt = at;
3412
+ expected.length = 0;
3413
+ }
3414
+ if (at === expectedAt) expected.push(...result.expected);
3409
3415
  if (result.committed) return { ok: false, expected, span: result.span, committed: true };
3410
3416
  continue;
3411
3417
  }
@@ -3416,6 +3422,9 @@ function choice(...args) {
3416
3422
  }
3417
3423
  return result;
3418
3424
  }
3425
+ if (expected.length === 0) {
3426
+ for (const parser2 of parsers) expected.push(...deriveExpected(parser2));
3427
+ }
3419
3428
  return { ok: false, expected, span: { start: pos, end: pos } };
3420
3429
  }
3421
3430
  };