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.
@@ -1 +1 @@
1
- {"version":3,"file":"choice.d.ts","sourceRoot":"","sources":["../../src/combinators/choice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAC+B,QAAQ,EAClD,MAAM,aAAa,CAAA;AAKpB,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,KAAK,CAAA;AACvH,KAAK,SAAS,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI;KACrE,CAAC,IAAI,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAChC,CAAC,MAAM,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAEjD,wBAAgB,MAAM,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EACxH,GAAG,IAAI,EAAE,CAAC,GACT,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAqK1B;AAgID;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAWrF;AA6CD,uEAAuE;AACvE,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,CAKzE;AAED,qEAAqE;AACrE,wBAAgB,eAAe,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAMhG"}
1
+ {"version":3,"file":"choice.d.ts","sourceRoot":"","sources":["../../src/combinators/choice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAC+B,QAAQ,EAClD,MAAM,aAAa,CAAA;AAKpB,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,KAAK,CAAA;AACvH,KAAK,SAAS,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI;KACrE,CAAC,IAAI,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAChC,CAAC,MAAM,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAEjD,wBAAgB,MAAM,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EACxH,GAAG,IAAI,EAAE,CAAC,GACT,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CA8K1B;AAgID;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAWrF;AA6CD,uEAAuE;AACvE,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,CAKzE;AAED,qEAAqE;AACrE,wBAAgB,eAAe,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAMhG"}
package/dist/index.js CHANGED
@@ -2950,6 +2950,7 @@ function choice(...args) {
2950
2950
  },
2951
2951
  parse(input, pos, ctx) {
2952
2952
  const expected = [];
2953
+ let expectedAt = pos;
2953
2954
  if (disjoint) {
2954
2955
  const code = pos < input.length ? input.codePointAt(pos) : -1;
2955
2956
  let idx = code >= 0 && code < 128 ? asciiDispatch[code] : -1;
@@ -3007,7 +3008,12 @@ function choice(...args) {
3007
3008
  const result = parsers[i].parse(input, pos, ctx);
3008
3009
  if (!result.ok) {
3009
3010
  rollbackTrivia(ctx, mark);
3010
- expected.push(...result.expected);
3011
+ const at = result.span.start;
3012
+ if (at > expectedAt) {
3013
+ expectedAt = at;
3014
+ expected.length = 0;
3015
+ }
3016
+ if (at === expectedAt) expected.push(...result.expected);
3011
3017
  if (result.committed) return { ok: false, expected, span: result.span, committed: true };
3012
3018
  continue;
3013
3019
  }
@@ -3018,6 +3024,9 @@ function choice(...args) {
3018
3024
  }
3019
3025
  return result;
3020
3026
  }
3027
+ if (expected.length === 0) {
3028
+ for (const parser2 of parsers) expected.push(...deriveExpected(parser2));
3029
+ }
3021
3030
  return { ok: false, expected, span: { start: pos, end: pos } };
3022
3031
  }
3023
3032
  };
@@ -5608,24 +5617,43 @@ function choiceNode(arms, classes, armExpected, choiceExpected) {
5608
5617
  };
5609
5618
  for (let i = arms.length - 1; i >= 0; i--) {
5610
5619
  const arm = arms[i], cls = classes[i], staticExpected = armExpected[i], next = tail;
5611
- tail = (input, pos, ctx, lead2, acc) => {
5620
+ tail = (input, pos, ctx, lead2, acc, best) => {
5612
5621
  if (cls !== void 0 && !classHas(cls, lead2)) {
5613
- return next(input, pos, ctx, lead2, appendExpected(acc, staticExpected));
5622
+ return next(
5623
+ input,
5624
+ pos,
5625
+ ctx,
5626
+ lead2,
5627
+ best === pos ? appendExpected(acc, staticExpected) : acc,
5628
+ best
5629
+ );
5614
5630
  }
5615
5631
  ctx._fc = false;
5616
5632
  const end = arm.run(input, pos, ctx);
5617
5633
  if (end >= 0) return end;
5618
- const nextAcc = appendExpected(acc, ctx._fx);
5634
+ const at = ctx._fe ?? pos;
5635
+ if (at > best) {
5636
+ best = at;
5637
+ acc = void 0;
5638
+ }
5639
+ const nextAcc = at === best ? appendExpected(acc, ctx._fx) : acc;
5619
5640
  if (committed(ctx)) {
5620
5641
  if (nextAcc !== void 0) ctx._fx = nextAcc;
5621
5642
  return -1;
5622
5643
  }
5623
- return next(input, pos, ctx, lead2, nextAcc);
5644
+ return next(input, pos, ctx, lead2, nextAcc, best);
5624
5645
  };
5625
5646
  }
5626
5647
  return {
5627
5648
  match: matchTail,
5628
- run: (input, pos, ctx) => tail(input, pos, ctx, pos < input.length ? input.codePointAt(pos) : -1, void 0)
5649
+ run: (input, pos, ctx) => tail(
5650
+ input,
5651
+ pos,
5652
+ ctx,
5653
+ pos < input.length ? input.codePointAt(pos) : -1,
5654
+ void 0,
5655
+ pos
5656
+ )
5629
5657
  };
5630
5658
  }
5631
5659
  function notNode(body, failure) {
@@ -9719,9 +9747,11 @@ ${catchCases}
9719
9747
  ctx._fc=false
9720
9748
  {const v=${arm}(input,pos,ctx)
9721
9749
  if(v!==FAIL)return v}
9722
- acc=${catchName}(${i},prev,acc)
9750
+ if(best===pos)acc=${catchName}(${i},prev,acc)
9723
9751
  prev=${i + 1}
9724
- acc=_accSet(ctx._fx,acc)
9752
+ {const at=ctx._fe??pos
9753
+ if(at>best){best=at;acc=undefined}
9754
+ if(at===best)acc=_accSet(ctx._fx,acc)}
9725
9755
  if(ctx._fc===true){if(acc!==undefined)ctx._fx=acc;return FAIL}
9726
9756
  ${emitRollback(p, L.buf, sinks)}
9727
9757
  }`;
@@ -9730,19 +9760,22 @@ ${emitRollback(p, L.buf, sinks)}
9730
9760
  ctx._fc=false
9731
9761
  {const v=${arm}(input,pos,ctx)
9732
9762
  if(v!==FAIL)return v}
9733
- acc=_accSet(ctx._fx,acc)
9763
+ {const at=ctx._fe??pos
9764
+ if(at>best){best=at;acc=undefined}
9765
+ if(at===best)acc=_accSet(ctx._fx,acc)}
9734
9766
  if(ctx._fc===true){if(acc!==undefined)ctx._fx=acc;return FAIL}
9735
9767
  ${emitRollback(p, L.buf, sinks)}
9736
- }else acc=_accSet(${expected[i]},acc)`).join("\n");
9768
+ }else if(best===pos)acc=_accSet(${expected[i]},acc)`).join("\n");
9737
9769
  return `${head}
9738
9770
  const c=lead(input,pos)
9739
9771
  ${emitMark(p, L.buf, sinks)}
9740
9772
  let acc
9773
+ let best=pos
9741
9774
  ${maskable ? `if(c<128){
9742
9775
  const bits=${maskName}[c<0?128:c]
9743
9776
  let prev=0
9744
9777
  ${maskArms}
9745
- acc=${catchName}(${n},prev,acc)
9778
+ if(best===pos)acc=${catchName}(${n},prev,acc)
9746
9779
  ctx._fe=pos;ctx._fx=acc??${choiceFx}
9747
9780
  return FAIL
9748
9781
  }
@@ -10874,14 +10907,19 @@ function assemble(t, prog, cfg) {
10874
10907
  };
10875
10908
  }
10876
10909
  function maskedChoiceBlock(start, a0, a1, a2, a3, through, next, total, choiceFx) {
10877
- return (input, pos, ctx, bits, need, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot, acc, prev) => {
10910
+ return (input, pos, ctx, bits, need, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot, acc, prev, best) => {
10878
10911
  if ((bits & 1 << start) !== 0) {
10879
10912
  ctx._fc = false;
10880
10913
  const v = a0(input, pos, ctx);
10881
10914
  if (v !== FAIL) return v;
10882
- acc = through(start, prev, acc);
10915
+ if (best === pos) acc = through(start, prev, acc);
10883
10916
  prev = start + 1;
10884
- acc = accSet(ctx._fx, acc);
10917
+ const at = ctx._fe ?? pos;
10918
+ if (at > best) {
10919
+ best = at;
10920
+ acc = void 0;
10921
+ }
10922
+ if (at === best) acc = accSet(ctx._fx, acc);
10885
10923
  if (committed3(ctx)) {
10886
10924
  if (acc !== void 0) ctx._fx = acc;
10887
10925
  return FAIL;
@@ -10892,9 +10930,14 @@ function assemble(t, prog, cfg) {
10892
10930
  ctx._fc = false;
10893
10931
  const v = a1(input, pos, ctx);
10894
10932
  if (v !== FAIL) return v;
10895
- acc = through(start + 1, prev, acc);
10933
+ if (best === pos) acc = through(start + 1, prev, acc);
10896
10934
  prev = start + 2;
10897
- acc = accSet(ctx._fx, acc);
10935
+ const at = ctx._fe ?? pos;
10936
+ if (at > best) {
10937
+ best = at;
10938
+ acc = void 0;
10939
+ }
10940
+ if (at === best) acc = accSet(ctx._fx, acc);
10898
10941
  if (committed3(ctx)) {
10899
10942
  if (acc !== void 0) ctx._fx = acc;
10900
10943
  return FAIL;
@@ -10905,9 +10948,14 @@ function assemble(t, prog, cfg) {
10905
10948
  ctx._fc = false;
10906
10949
  const v = a2(input, pos, ctx);
10907
10950
  if (v !== FAIL) return v;
10908
- acc = through(start + 2, prev, acc);
10951
+ if (best === pos) acc = through(start + 2, prev, acc);
10909
10952
  prev = start + 3;
10910
- acc = accSet(ctx._fx, acc);
10953
+ const at = ctx._fe ?? pos;
10954
+ if (at > best) {
10955
+ best = at;
10956
+ acc = void 0;
10957
+ }
10958
+ if (at === best) acc = accSet(ctx._fx, acc);
10911
10959
  if (committed3(ctx)) {
10912
10960
  if (acc !== void 0) ctx._fx = acc;
10913
10961
  return FAIL;
@@ -10918,9 +10966,14 @@ function assemble(t, prog, cfg) {
10918
10966
  ctx._fc = false;
10919
10967
  const v = a3(input, pos, ctx);
10920
10968
  if (v !== FAIL) return v;
10921
- acc = through(start + 3, prev, acc);
10969
+ if (best === pos) acc = through(start + 3, prev, acc);
10922
10970
  prev = start + 4;
10923
- acc = accSet(ctx._fx, acc);
10971
+ const at = ctx._fe ?? pos;
10972
+ if (at > best) {
10973
+ best = at;
10974
+ acc = void 0;
10975
+ }
10976
+ if (at === best) acc = accSet(ctx._fx, acc);
10924
10977
  if (committed3(ctx)) {
10925
10978
  if (acc !== void 0) ctx._fx = acc;
10926
10979
  return FAIL;
@@ -10928,23 +10981,28 @@ function assemble(t, prog, cfg) {
10928
10981
  if (need) rollbackTriviaAt(ctx, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot);
10929
10982
  }
10930
10983
  if (next !== void 0) {
10931
- return next(input, pos, ctx, bits, need, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot, acc, prev);
10984
+ return next(input, pos, ctx, bits, need, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot, acc, prev, best);
10932
10985
  }
10933
- acc = through(total, prev, acc);
10986
+ if (best === pos) acc = through(total, prev, acc);
10934
10987
  ctx._fe = pos;
10935
10988
  ctx._fx = acc ?? choiceFx;
10936
10989
  return FAIL;
10937
10990
  };
10938
10991
  }
10939
10992
  function generalChoiceBlock(start, a0, a1, a2, a3, g0, g1, g2, g3, through, next, total, choiceFx) {
10940
- return (input, pos, ctx, c, need, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot, acc, prev) => {
10993
+ return (input, pos, ctx, c, need, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot, acc, prev, best) => {
10941
10994
  if (g0 === null || classHas2(g0, c)) {
10942
10995
  ctx._fc = false;
10943
10996
  const v = a0(input, pos, ctx);
10944
10997
  if (v !== FAIL) return v;
10945
- acc = through(start, prev, acc);
10998
+ if (best === pos) acc = through(start, prev, acc);
10946
10999
  prev = start + 1;
10947
- acc = accSet(ctx._fx, acc);
11000
+ const at = ctx._fe ?? pos;
11001
+ if (at > best) {
11002
+ best = at;
11003
+ acc = void 0;
11004
+ }
11005
+ if (at === best) acc = accSet(ctx._fx, acc);
10948
11006
  if (committed3(ctx)) {
10949
11007
  if (acc !== void 0) ctx._fx = acc;
10950
11008
  return FAIL;
@@ -10955,9 +11013,14 @@ function assemble(t, prog, cfg) {
10955
11013
  ctx._fc = false;
10956
11014
  const v = a1(input, pos, ctx);
10957
11015
  if (v !== FAIL) return v;
10958
- acc = through(start + 1, prev, acc);
11016
+ if (best === pos) acc = through(start + 1, prev, acc);
10959
11017
  prev = start + 2;
10960
- acc = accSet(ctx._fx, acc);
11018
+ const at = ctx._fe ?? pos;
11019
+ if (at > best) {
11020
+ best = at;
11021
+ acc = void 0;
11022
+ }
11023
+ if (at === best) acc = accSet(ctx._fx, acc);
10961
11024
  if (committed3(ctx)) {
10962
11025
  if (acc !== void 0) ctx._fx = acc;
10963
11026
  return FAIL;
@@ -10968,9 +11031,14 @@ function assemble(t, prog, cfg) {
10968
11031
  ctx._fc = false;
10969
11032
  const v = a2(input, pos, ctx);
10970
11033
  if (v !== FAIL) return v;
10971
- acc = through(start + 2, prev, acc);
11034
+ if (best === pos) acc = through(start + 2, prev, acc);
10972
11035
  prev = start + 3;
10973
- acc = accSet(ctx._fx, acc);
11036
+ const at = ctx._fe ?? pos;
11037
+ if (at > best) {
11038
+ best = at;
11039
+ acc = void 0;
11040
+ }
11041
+ if (at === best) acc = accSet(ctx._fx, acc);
10974
11042
  if (committed3(ctx)) {
10975
11043
  if (acc !== void 0) ctx._fx = acc;
10976
11044
  return FAIL;
@@ -10981,9 +11049,14 @@ function assemble(t, prog, cfg) {
10981
11049
  ctx._fc = false;
10982
11050
  const v = a3(input, pos, ctx);
10983
11051
  if (v !== FAIL) return v;
10984
- acc = through(start + 3, prev, acc);
11052
+ if (best === pos) acc = through(start + 3, prev, acc);
10985
11053
  prev = start + 4;
10986
- acc = accSet(ctx._fx, acc);
11054
+ const at = ctx._fe ?? pos;
11055
+ if (at > best) {
11056
+ best = at;
11057
+ acc = void 0;
11058
+ }
11059
+ if (at === best) acc = accSet(ctx._fx, acc);
10987
11060
  if (committed3(ctx)) {
10988
11061
  if (acc !== void 0) ctx._fx = acc;
10989
11062
  return FAIL;
@@ -10991,9 +11064,9 @@ function assemble(t, prog, cfg) {
10991
11064
  if (need) rollbackTriviaAt(ctx, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot);
10992
11065
  }
10993
11066
  if (next !== void 0) {
10994
- return next(input, pos, ctx, c, need, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot, acc, prev);
11067
+ return next(input, pos, ctx, c, need, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot, acc, prev, best);
10995
11068
  }
10996
- acc = through(total, prev, acc);
11069
+ if (best === pos) acc = through(total, prev, acc);
10997
11070
  ctx._fe = pos;
10998
11071
  ctx._fx = acc ?? choiceFx;
10999
11072
  return FAIL;
@@ -12349,6 +12422,7 @@ function assemble(t, prog, cfg) {
12349
12422
  const mLog = need ? ctx._triviaLog?.length ?? 0 : 0;
12350
12423
  const mRoot = need ? ctx._rootTriviaLog?.length ?? 0 : 0;
12351
12424
  let acc;
12425
+ let best = pos;
12352
12426
  if (c < 128) {
12353
12427
  const bits = mask[c < 0 ? 128 : c];
12354
12428
  let prev = 0;
@@ -12357,7 +12431,12 @@ function assemble(t, prog, cfg) {
12357
12431
  const v = a0(input, pos, ctx);
12358
12432
  if (v !== FAIL) return v;
12359
12433
  prev = 1;
12360
- acc = accSet(ctx._fx, acc);
12434
+ const at = ctx._fe ?? pos;
12435
+ if (at > best) {
12436
+ best = at;
12437
+ acc = void 0;
12438
+ }
12439
+ if (at === best) acc = accSet(ctx._fx, acc);
12361
12440
  if (committed3(ctx)) {
12362
12441
  if (acc !== void 0) ctx._fx = acc;
12363
12442
  return FAIL;
@@ -12368,9 +12447,14 @@ function assemble(t, prog, cfg) {
12368
12447
  ctx._fc = false;
12369
12448
  const v = a1(input, pos, ctx);
12370
12449
  if (v !== FAIL) return v;
12371
- if (prev < 1) acc = accSet(e0, acc);
12450
+ if (best === pos && prev < 1) acc = accSet(e0, acc);
12372
12451
  prev = 2;
12373
- acc = accSet(ctx._fx, acc);
12452
+ const at = ctx._fe ?? pos;
12453
+ if (at > best) {
12454
+ best = at;
12455
+ acc = void 0;
12456
+ }
12457
+ if (at === best) acc = accSet(ctx._fx, acc);
12374
12458
  if (committed3(ctx)) {
12375
12459
  if (acc !== void 0) ctx._fx = acc;
12376
12460
  return FAIL;
@@ -12381,19 +12465,24 @@ function assemble(t, prog, cfg) {
12381
12465
  ctx._fc = false;
12382
12466
  const v = a2(input, pos, ctx);
12383
12467
  if (v !== FAIL) return v;
12384
- if (prev < 1) acc = accSet(e0, acc);
12385
- if (prev < 2) acc = accSet(e1, acc);
12468
+ if (best === pos && prev < 1) acc = accSet(e0, acc);
12469
+ if (best === pos && prev < 2) acc = accSet(e1, acc);
12386
12470
  prev = 3;
12387
- acc = accSet(ctx._fx, acc);
12471
+ const at = ctx._fe ?? pos;
12472
+ if (at > best) {
12473
+ best = at;
12474
+ acc = void 0;
12475
+ }
12476
+ if (at === best) acc = accSet(ctx._fx, acc);
12388
12477
  if (committed3(ctx)) {
12389
12478
  if (acc !== void 0) ctx._fx = acc;
12390
12479
  return FAIL;
12391
12480
  }
12392
12481
  if (need) rollbackTriviaAt(ctx, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot);
12393
12482
  }
12394
- if (prev < 1) acc = accSet(e0, acc);
12395
- if (prev < 2) acc = accSet(e1, acc);
12396
- if (n === 3 && prev < 3) acc = accSet(e2, acc);
12483
+ if (best === pos && prev < 1) acc = accSet(e0, acc);
12484
+ if (best === pos && prev < 2) acc = accSet(e1, acc);
12485
+ if (best === pos && n === 3 && prev < 3) acc = accSet(e2, acc);
12397
12486
  ctx._fe = pos;
12398
12487
  ctx._fx = acc ?? choiceFx;
12399
12488
  return FAIL;
@@ -12402,36 +12491,51 @@ function assemble(t, prog, cfg) {
12402
12491
  ctx._fc = false;
12403
12492
  const v = a0(input, pos, ctx);
12404
12493
  if (v !== FAIL) return v;
12405
- acc = accSet(ctx._fx, acc);
12494
+ const at = ctx._fe ?? pos;
12495
+ if (at > best) {
12496
+ best = at;
12497
+ acc = void 0;
12498
+ }
12499
+ if (at === best) acc = accSet(ctx._fx, acc);
12406
12500
  if (committed3(ctx)) {
12407
12501
  if (acc !== void 0) ctx._fx = acc;
12408
12502
  return FAIL;
12409
12503
  }
12410
12504
  if (need) rollbackTriviaAt(ctx, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot);
12411
- } else acc = accSet(e0, acc);
12505
+ } else if (best === pos) acc = accSet(e0, acc);
12412
12506
  if (g1 === null || classHas2(g1, c)) {
12413
12507
  ctx._fc = false;
12414
12508
  const v = a1(input, pos, ctx);
12415
12509
  if (v !== FAIL) return v;
12416
- acc = accSet(ctx._fx, acc);
12510
+ const at = ctx._fe ?? pos;
12511
+ if (at > best) {
12512
+ best = at;
12513
+ acc = void 0;
12514
+ }
12515
+ if (at === best) acc = accSet(ctx._fx, acc);
12417
12516
  if (committed3(ctx)) {
12418
12517
  if (acc !== void 0) ctx._fx = acc;
12419
12518
  return FAIL;
12420
12519
  }
12421
12520
  if (need) rollbackTriviaAt(ctx, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot);
12422
- } else acc = accSet(e1, acc);
12521
+ } else if (best === pos) acc = accSet(e1, acc);
12423
12522
  if (n === 3) {
12424
12523
  if (g2 === null || classHas2(g2, c)) {
12425
12524
  ctx._fc = false;
12426
12525
  const v = a2(input, pos, ctx);
12427
12526
  if (v !== FAIL) return v;
12428
- acc = accSet(ctx._fx, acc);
12527
+ const at = ctx._fe ?? pos;
12528
+ if (at > best) {
12529
+ best = at;
12530
+ acc = void 0;
12531
+ }
12532
+ if (at === best) acc = accSet(ctx._fx, acc);
12429
12533
  if (committed3(ctx)) {
12430
12534
  if (acc !== void 0) ctx._fx = acc;
12431
12535
  return FAIL;
12432
12536
  }
12433
12537
  if (need) rollbackTriviaAt(ctx, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot);
12434
- } else acc = accSet(e2, acc);
12538
+ } else if (best === pos) acc = accSet(e2, acc);
12435
12539
  }
12436
12540
  ctx._fe = pos;
12437
12541
  ctx._fx = acc ?? choiceFx;
@@ -12529,7 +12633,8 @@ function assemble(t, prog, cfg) {
12529
12633
  mLog,
12530
12634
  mRoot,
12531
12635
  void 0,
12532
- 0
12636
+ 0,
12637
+ pos
12533
12638
  );
12534
12639
  }
12535
12640
  return general(
@@ -12546,7 +12651,8 @@ function assemble(t, prog, cfg) {
12546
12651
  mLog,
12547
12652
  mRoot,
12548
12653
  void 0,
12549
- 0
12654
+ 0,
12655
+ pos
12550
12656
  );
12551
12657
  };
12552
12658
  }
@@ -12574,7 +12680,8 @@ function assemble(t, prog, cfg) {
12574
12680
  mLog,
12575
12681
  mRoot,
12576
12682
  void 0,
12577
- 0
12683
+ 0,
12684
+ pos
12578
12685
  );
12579
12686
  };
12580
12687
  }
@@ -15911,7 +16018,7 @@ function compileRuleMap(ruleMap, opts = {}) {
15911
16018
  }
15912
16019
 
15913
16020
  // src/version.ts
15914
- var PARSEMAN_VERSION = "0.48.0";
16021
+ var PARSEMAN_VERSION = "0.48.1";
15915
16022
 
15916
16023
  // src/compiler/compile-linkable-table.ts
15917
16024
  function isLocal(rule) {