parseman 0.58.3 → 0.59.0

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.
Files changed (61) hide show
  1. package/dist/analysis/diagnostics.js +141 -93
  2. package/dist/analysis/diagnostics.js.map +3 -3
  3. package/dist/cli/index.js +143 -94
  4. package/dist/cli/index.js.map +3 -3
  5. package/dist/combinators/dispatch.d.ts.map +1 -1
  6. package/dist/combinators/field-trivia.d.ts.map +1 -1
  7. package/dist/combinators/keywords.d.ts.map +1 -1
  8. package/dist/combinators/literal.d.ts.map +1 -1
  9. package/dist/combinators/node.d.ts.map +1 -1
  10. package/dist/combinators/regex.d.ts.map +1 -1
  11. package/dist/combinators/scanTo.d.ts.map +1 -1
  12. package/dist/combinators/token.d.ts.map +1 -1
  13. package/dist/compiler/linker.d.ts.map +1 -1
  14. package/dist/compiler/token-capability.js.map +1 -1
  15. package/dist/cst/capture-buffer.d.ts.map +1 -1
  16. package/dist/cst/plain.js +69 -0
  17. package/dist/cst/plain.js.map +6 -0
  18. package/dist/index.js +144 -98
  19. package/dist/index.js.map +3 -3
  20. package/dist/language-service/index.js +19 -2
  21. package/dist/language-service/index.js.map +2 -2
  22. package/dist/line-index.d.ts +13 -0
  23. package/dist/line-index.d.ts.map +1 -1
  24. package/dist/plugin/entry-supercompiler.d.ts.map +1 -1
  25. package/dist/plugin/index.js +146 -100
  26. package/dist/plugin/index.js.map +3 -3
  27. package/dist/recovery/scan.d.ts.map +1 -1
  28. package/dist/run/index.js +4 -1
  29. package/dist/run/index.js.map +2 -2
  30. package/dist/spec/index.js +18 -1
  31. package/dist/spec/index.js.map +2 -2
  32. package/dist/table/assemble.d.ts.map +1 -1
  33. package/dist/table/emit-assembly.d.ts +1 -1
  34. package/dist/table/emit-assembly.d.ts.map +1 -1
  35. package/dist/table/emit.d.ts +6 -0
  36. package/dist/table/emit.d.ts.map +1 -1
  37. package/dist/table/index.js +124 -89
  38. package/dist/table/index.js.map +3 -3
  39. package/dist/table/run-support.d.ts.map +1 -1
  40. package/dist/version.d.ts +1 -1
  41. package/package.json +2 -1
  42. package/src/combinators/dispatch.ts +2 -1
  43. package/src/combinators/field-trivia.ts +6 -5
  44. package/src/combinators/keywords.ts +3 -2
  45. package/src/combinators/literal.ts +5 -4
  46. package/src/combinators/node.ts +3 -1
  47. package/src/combinators/regex.ts +5 -4
  48. package/src/combinators/scanTo.ts +2 -1
  49. package/src/combinators/token.ts +3 -6
  50. package/src/compiler/linker.ts +4 -2
  51. package/src/cst/capture-buffer.ts +13 -5
  52. package/src/cst/plain.d.ts +35 -0
  53. package/src/cst/plain.js +74 -0
  54. package/src/line-index.ts +37 -0
  55. package/src/plugin/entry-supercompiler.ts +3 -2
  56. package/src/recovery/scan.ts +2 -1
  57. package/src/table/assemble.ts +33 -35
  58. package/src/table/emit-assembly.ts +27 -24
  59. package/src/table/emit.ts +9 -1
  60. package/src/table/run-support.ts +4 -7
  61. package/src/version.ts +1 -1
@@ -384,6 +384,7 @@ function failAt(ctx, expected, pos) {
384
384
  }
385
385
 
386
386
  // src/line-index.ts
387
+ import { PlainLineSpan, PlainSpan } from "../cst/plain.js";
387
388
  function createLineIndex() {
388
389
  return { lineStarts: [0] };
389
390
  }
@@ -436,6 +437,27 @@ function annotateSpan(span, index) {
436
437
  endColumn: e.col
437
438
  };
438
439
  }
440
+ var SPAN_KEYS = ["start", "end", "startLine", "startColumn", "endLine", "endColumn"];
441
+ function copySpan(span) {
442
+ let n = 0;
443
+ for (const key in span) {
444
+ if (key !== SPAN_KEYS[n]) return { ...span };
445
+ n++;
446
+ }
447
+ if (n === 2) return new PlainSpan(span.start, span.end);
448
+ if (n === 6 && span.startLine !== void 0 && span.startColumn !== void 0 && span.endLine !== void 0 && span.endColumn !== void 0) {
449
+ return new PlainLineSpan(span.start, span.end, span.startLine, span.startColumn, span.endLine, span.endColumn);
450
+ }
451
+ return { ...span };
452
+ }
453
+ function lineSpanFromContext(span, ctx) {
454
+ if (!ctx.trackLines) return span;
455
+ const index = ctx._lineIndex ?? (ctx._lineStarts ? { lineStarts: ctx._lineStarts } : void 0);
456
+ if (!index) return span;
457
+ const s = offsetToLineCol(index, span.start);
458
+ const e = offsetToLineCol(index, span.end);
459
+ return new PlainLineSpan(span.start, span.end, s.line, s.col, e.line, e.col);
460
+ }
439
461
  function annotateSpanFromLineContext(span, ctx) {
440
462
  if (!ctx.trackLines) return span;
441
463
  const index = ctx._lineIndex ?? (ctx._lineStarts ? { lineStarts: ctx._lineStarts } : void 0);
@@ -443,6 +465,7 @@ function annotateSpanFromLineContext(span, ctx) {
443
465
  }
444
466
 
445
467
  // src/cst/capture-buffer.ts
468
+ import { PlainBuf, PlainLeaf } from "../cst/plain.js";
446
469
  var EMPTY = [];
447
470
  var EMPTY_TL = [];
448
471
  function cstCaptureActive(ctx) {
@@ -457,7 +480,7 @@ function beginCstNodeCapture(ctx) {
457
480
  cap: ctx.captureTrivia,
458
481
  buf: ctx._cstBuf
459
482
  };
460
- ctx._cstBuf = {};
483
+ ctx._cstBuf = new PlainBuf(void 0, void 0, 0);
461
484
  ctx._cstChildren = void 0;
462
485
  ctx._cstLeaves = void 0;
463
486
  ctx._cstRawChildren = void 0;
@@ -482,12 +505,15 @@ function endCstNodeCapture(ctx, saved) {
482
505
  ctx.captureTrivia = saved.cap;
483
506
  return materialized;
484
507
  }
508
+ function isLeaf(v) {
509
+ return typeof v === "object" && v !== null && v._tag === "leaf";
510
+ }
485
511
  function pushCstLeaf(ctx, leaf2) {
486
512
  if (!ctx.trackLines) {
487
513
  pushCstChild(ctx, leaf2, leaf2);
488
514
  return;
489
515
  }
490
- const annotated = leaf2 && typeof leaf2 === "object" && leaf2.span ? { ...leaf2, span: annotateSpanFromLineContext(leaf2.span, ctx) } : leaf2;
516
+ const annotated = isLeaf(leaf2) ? new PlainLeaf(leaf2.value, lineSpanFromContext(leaf2.span, ctx)) : leaf2 && typeof leaf2 === "object" && leaf2.span ? { ...leaf2, span: annotateSpanFromLineContext(leaf2.span, ctx) } : leaf2;
491
517
  pushCstChild(ctx, annotated, annotated);
492
518
  }
493
519
  function pushCstChild(ctx, built, rawEntry2) {
@@ -676,6 +702,7 @@ function assertionFailureExpected(positive, childTag) {
676
702
  }
677
703
 
678
704
  // src/combinators/keywords.ts
705
+ import { PlainLeaf as PlainLeaf2, PlainSpan as PlainSpan2 } from "../cst/plain.js";
679
706
  function escapeRe(s) {
680
707
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
681
708
  }
@@ -724,8 +751,8 @@ function keywords(words, opts = {}) {
724
751
  const m = re.exec(input);
725
752
  if (m === null) return failAt(ctx, directTerminalFailureExpected(def), pos);
726
753
  const value = m[0];
727
- const span = { start: pos, end: pos + value.length };
728
- if (cstCaptureActive(ctx)) pushCstLeaf(ctx, { _tag: "leaf", value, span });
754
+ const span = new PlainSpan2(pos, pos + value.length);
755
+ if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf2(value, span));
729
756
  return { ok: true, value, span };
730
757
  }
731
758
  };
@@ -2451,6 +2478,7 @@ function parse(combinator, input, opts = {}) {
2451
2478
  }
2452
2479
 
2453
2480
  // src/recovery/scan.ts
2481
+ import { PlainSpan as PlainSpan3 } from "../cst/plain.js";
2454
2482
  function probeAt(sentinel, input, pos, ctx) {
2455
2483
  const s = {
2456
2484
  _probe: ctx._probe,
@@ -2527,7 +2555,7 @@ function firstSetSentinel(fs) {
2527
2555
  function recoverScan(input, from, ctx, sync, expected) {
2528
2556
  let scanPos = from;
2529
2557
  while (scanPos < input.length && !probeAt(sync, input, scanPos, ctx)) scanPos++;
2530
- const span = { start: from, end: scanPos };
2558
+ const span = new PlainSpan3(from, scanPos);
2531
2559
  if (ctx.trackLines) recordLineRangeFromContext(ctx, input, from, scanPos);
2532
2560
  const error = { _tag: "parseError", span: ctx.trackLines ? annotateSpanFromLineContext(span, ctx) : span, expected };
2533
2561
  ctx._errors?.push(error);
@@ -2983,17 +3011,18 @@ function buildAsciiDispatch(parsers) {
2983
3011
  }
2984
3012
 
2985
3013
  // src/combinators/field-trivia.ts
3014
+ import { PlainSpan as PlainSpan4, PlainTriviaField } from "../cst/plain.js";
2986
3015
  var LEAD = { at: -1 };
2987
3016
  var FIELD_LEADING_TRIVIA = 1;
2988
3017
  var FIELD_TRAILING_TRIVIA = 2;
2989
3018
  function triviaFieldCapture(name, value, input, start, end, leadFrom, trailEnd) {
2990
- return {
3019
+ return new PlainTriviaField(
2991
3020
  name,
2992
3021
  value,
2993
- span: { start, end },
2994
- leading: leadFrom >= 0 && leadFrom < start ? input.slice(leadFrom, start) : "",
2995
- trailing: trailEnd > end ? input.slice(end, trailEnd) : ""
2996
- };
3022
+ new PlainSpan4(start, end),
3023
+ leadFrom >= 0 && leadFrom < start ? input.slice(leadFrom, start) : "",
3024
+ trailEnd > end ? input.slice(end, trailEnd) : ""
3025
+ );
2997
3026
  }
2998
3027
  function leadsTrivia(p) {
2999
3028
  return p._def.tag === "field" && p._def.leadingTrivia === true;
@@ -3829,6 +3858,7 @@ function firstSetFromRegex(source, flags = "") {
3829
3858
  }
3830
3859
 
3831
3860
  // src/combinators/regex.ts
3861
+ import { PlainLeaf as PlainLeaf3, PlainSpan as PlainSpan5 } from "../cst/plain.js";
3832
3862
  var SCAN_BAIL_AT = 64;
3833
3863
  function inRanges3(cp, ranges) {
3834
3864
  for (let i = 0; i < ranges.length; i++) {
@@ -3941,9 +3971,9 @@ function regex(pattern, flags = "") {
3941
3971
  if (scanEnd !== void 0) {
3942
3972
  if (scanEnd === null) return failAt(ctx, directTerminalFailureExpected(def), pos);
3943
3973
  const value = input.slice(pos, scanEnd);
3944
- const span2 = { start: pos, end: scanEnd };
3974
+ const span2 = new PlainSpan5(pos, scanEnd);
3945
3975
  if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, scanEnd);
3946
- if (cstCaptureActive(ctx)) pushCstLeaf(ctx, { _tag: "leaf", value, span: span2 });
3976
+ if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf3(value, span2));
3947
3977
  return { ok: true, value, span: span2 };
3948
3978
  }
3949
3979
  anchored.lastIndex = pos;
@@ -3951,9 +3981,9 @@ function regex(pattern, flags = "") {
3951
3981
  if (m === null) {
3952
3982
  return failAt(ctx, directTerminalFailureExpected(def), pos);
3953
3983
  }
3954
- const span = { start: pos, end: pos + m[0].length };
3984
+ const span = new PlainSpan5(pos, pos + m[0].length);
3955
3985
  if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, span.end);
3956
- if (cstCaptureActive(ctx)) pushCstLeaf(ctx, { _tag: "leaf", value: m[0], span });
3986
+ if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf3(m[0], span));
3957
3987
  return { ok: true, value: m[0], span };
3958
3988
  }
3959
3989
  };
@@ -3980,6 +4010,7 @@ function buildLexBodyRecognizer(spec, constants) {
3980
4010
  }
3981
4011
 
3982
4012
  // src/table/run-support.ts
4013
+ import { PlainLeaf as PlainLeaf4, PlainLineSpan as PlainLineSpan2, PlainSpan as PlainSpan6 } from "../cst/plain.js";
3983
4014
  function lineCol(ctx, offset) {
3984
4015
  const starts = ctx._lineStarts ?? [0];
3985
4016
  let lo = 0, hi = starts.length - 1;
@@ -3992,18 +4023,14 @@ function lineCol(ctx, offset) {
3992
4023
  }
3993
4024
  function spanLines(ctx, start, end) {
3994
4025
  const s = lineCol(ctx, start), e = lineCol(ctx, end);
3995
- return { start, end, startLine: s[0], startColumn: s[1], endLine: e[0], endColumn: e[1] };
4026
+ return new PlainLineSpan2(start, end, s[0], s[1], e[0], e[1]);
3996
4027
  }
3997
4028
  function rawEntry(v, input, s, e) {
3998
4029
  if (typeof v === "object" && v !== null) {
3999
4030
  const tg = v._tag;
4000
4031
  if (tg === "node" || tg === "leaf" || tg === "parseError") return v;
4001
4032
  }
4002
- return {
4003
- _tag: "leaf",
4004
- value: typeof v === "string" ? v : typeof v === "object" && v !== null ? input.slice(s, e) : "",
4005
- span: { start: s, end: e }
4006
- };
4033
+ return new PlainLeaf4(typeof v === "string" ? v : typeof v === "object" && v !== null ? input.slice(s, e) : "", new PlainSpan6(s, e));
4007
4034
  }
4008
4035
  function lead(input, pos) {
4009
4036
  if (pos >= input.length) return -1;
@@ -4017,7 +4044,7 @@ function collapseEmpty(ctx, build, input, pos, end, readsRaw) {
4017
4044
  const collected = ctx._cstBuf !== void 0 || ctx._cstChildren !== void 0;
4018
4045
  if (collected) popCstChild(ctx);
4019
4046
  const raw = readsRaw ? [rawEntry(void 0, input, pos, end)] : EMPTY_KIDS;
4020
- const nd = build(EMPTY_KIDS, void 0, { start: pos, end }, raw, EMPTY_TRIVIA, void 0);
4047
+ const nd = build(EMPTY_KIDS, void 0, new PlainSpan6(pos, end), raw, EMPTY_TRIVIA, void 0);
4021
4048
  if (collected) pushCstChild(ctx, nd, ctx._cstBuf?.noRaw === true ? void 0 : rawEntry(nd, input, pos, end));
4022
4049
  return nd;
4023
4050
  }
@@ -5239,6 +5266,7 @@ function buildReadsState(def) {
5239
5266
  }
5240
5267
 
5241
5268
  // src/combinators/token.ts
5269
+ import { PlainLeaf as PlainLeaf5 } from "../cst/plain.js";
5242
5270
  function semanticLeafValue(_ctx, _input, _start, _end, value) {
5243
5271
  return value;
5244
5272
  }
@@ -5292,7 +5320,7 @@ function token(root) {
5292
5320
  if (!result.ok) return result;
5293
5321
  const span = result.span;
5294
5322
  const value = input.slice(pos, span.end);
5295
- if (wasCapturing) pushCstLeaf(ctx, { _tag: "leaf", value, span });
5323
+ if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf5(value, span));
5296
5324
  return { ok: true, value, span };
5297
5325
  }
5298
5326
  };
@@ -5340,11 +5368,7 @@ function makeLeaf(root, fn, sourceCstValue) {
5340
5368
  }
5341
5369
  if (!result.ok) return result;
5342
5370
  const value = fn(result.value, result.span);
5343
- if (wasCapturing) pushCstLeaf(ctx, {
5344
- _tag: "leaf",
5345
- value: cstValue(ctx, input, pos, result.span.end, value),
5346
- span: result.span
5347
- });
5371
+ if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf5(cstValue(ctx, input, pos, result.span.end, value), result.span));
5348
5372
  return { ok: true, value, span: result.span };
5349
5373
  }
5350
5374
  };
@@ -6367,6 +6391,7 @@ function buildFieldMap(captures) {
6367
6391
  }
6368
6392
 
6369
6393
  // src/combinators/dispatch.ts
6394
+ import { PlainLeaf as PlainLeaf6 } from "../cst/plain.js";
6370
6395
  function parserUsesRouted(parser2, seen = /* @__PURE__ */ new Set()) {
6371
6396
  if (seen.has(parser2)) return false;
6372
6397
  seen.add(parser2);
@@ -6529,6 +6554,7 @@ var OP_NAMES = {
6529
6554
  };
6530
6555
 
6531
6556
  // src/combinators/node.ts
6557
+ import { PlainNode, PlainSpan as PlainSpan7 } from "../cst/plain.js";
6532
6558
  function unwrapChild(child) {
6533
6559
  return child !== null && typeof child === "object" && child._tag === "leaf" ? child.value : child;
6534
6560
  }
@@ -6634,7 +6660,7 @@ function node(typeOrCombinator, combinatorOrBuild, buildOrOpts, maybeOpts) {
6634
6660
  const nodeType = def.type ?? missingInferredType();
6635
6661
  const cstOutput = cstOutputHost(ctx.build);
6636
6662
  const span = ctx.trackLines ? annotateSpanFromLineContext(r.span, ctx) : r.span;
6637
- const built = unwrap && children2.length === 1 ? unwrapChild(children2[0]) : collapse && children2.length === 1 ? children2[0] : (cstOutput || !build && project === void 0) && ctx.build?._parsemanCstCollapse && children2.length === 1 && rawChildren.length === 1 && ctx.build._parsemanCstCollapse(nodeType, children2[0], children2, rawChildren) ? children2[0] : project !== void 0 ? cstOutput && ctx.build ? ctx.build(nodeType, children2, fields, span, rawChildren, triviaLog, ctx.state, tags) : projectChild(children2, project, nodeType) : build ? cstOutput && ctx.build ? ctx.build(nodeType, children2, fields, span, rawChildren, triviaLog, ctx.state, tags) : build(children2, fields, span, rawChildren, triviaLog, st) : ctx.build ? ctx.build(nodeType, children2, fields, span, rawChildren, triviaLog, st, tags) : { _tag: "node", type: nodeType, span: ctx.trackLines ? { ...span } : { start: r.span.start, end: r.span.end }, state: st ?? null, children: children2 };
6663
+ const built = unwrap && children2.length === 1 ? unwrapChild(children2[0]) : collapse && children2.length === 1 ? children2[0] : (cstOutput || !build && project === void 0) && ctx.build?._parsemanCstCollapse && children2.length === 1 && rawChildren.length === 1 && ctx.build._parsemanCstCollapse(nodeType, children2[0], children2, rawChildren) ? children2[0] : project !== void 0 ? cstOutput && ctx.build ? ctx.build(nodeType, children2, fields, span, rawChildren, triviaLog, ctx.state, tags) : projectChild(children2, project, nodeType) : build ? cstOutput && ctx.build ? ctx.build(nodeType, children2, fields, span, rawChildren, triviaLog, ctx.state, tags) : build(children2, fields, span, rawChildren, triviaLog, st) : ctx.build ? ctx.build(nodeType, children2, fields, span, rawChildren, triviaLog, st, tags) : new PlainNode(nodeType, ctx.trackLines ? copySpan(span) : new PlainSpan7(r.span.start, r.span.end), st ?? null, [...children2]);
6638
6664
  const rawEntry2 = isCstChild(built) ? built : { _tag: "leaf", value: typeof built === "string" ? built : typeof built === "object" && built !== null ? input.slice(r.span.start, r.span.end) : "", span };
6639
6665
  if (saved.buf !== void 0 || saved.ch !== void 0) {
6640
6666
  pushCstChild(ctx, built, rawEntry2);
@@ -10103,7 +10129,14 @@ var EMITTED_PARAMS = [
10103
10129
  "skipDeferredTrivia",
10104
10130
  // Appended for the pass-through collapse (`run-support.ts`); old factories
10105
10131
  // ignore it.
10106
- "collapseEmpty"
10132
+ "collapseEmpty",
10133
+ // Appended for constructor-built tree objects (`cst/plain.d.ts`): a `new` call has
10134
+ // no allocation site, so V8 cannot pretenure them. Old factories ignore them.
10135
+ "_SP",
10136
+ "_LF",
10137
+ "_ND",
10138
+ "_FC",
10139
+ "_BUF"
10107
10140
  ];
10108
10141
  var RUNTIME_PRELUDE = `
10109
10142
  let _pfScan=null
@@ -10127,9 +10160,9 @@ if(s!==null)return skipTriviaScanned(s,input,cur,ctx)
10127
10160
  if(needsDeferredTriviaCommit(ctx))return skipDeferredTrivia(input,cur,ctx)
10128
10161
  return advanceTrivia(input,cur,ctx)
10129
10162
  }
10130
- function _pushLeaf(ctx,value,s,e){pushCstLeaf(ctx,{_tag:'leaf',value,span:{start:s,end:e}})}
10163
+ function _pushLeaf(ctx,value,s,e){pushCstLeaf(ctx,new _LF(value,new _SP(s,e)))}
10131
10164
  function _pushLeafBuf(ctx,value,s,e){
10132
- const l={_tag:'leaf',value,span:{start:s,end:e}}
10165
+ const l=new _LF(value,new _SP(s,e))
10133
10166
  const b=ctx._cstBuf
10134
10167
  if(b.ch!==undefined)b.ch.push(l)
10135
10168
  else if(b.single!==undefined){b.ch=[b.single,l];b.single=undefined}
@@ -10187,7 +10220,7 @@ if(ctx._rootTriviaLog!==undefined&&ctx._rootTriviaLog.length!==rt)ctx._rootTrivi
10187
10220
  `;
10188
10221
  var NO_RAW_RUNTIME_PRELUDE = `
10189
10222
  function _pushLeafNoRawBuf(ctx,value,s,e){
10190
- const l={_tag:'leaf',value,span:{start:s,end:e}}
10223
+ const l=new _LF(value,new _SP(s,e))
10191
10224
  const b=ctx._cstBuf
10192
10225
  if(b.ch!==undefined)b.ch.push(l)
10193
10226
  else if(b.single!==undefined){b.ch=[b.single,l];b.single=undefined}
@@ -10864,7 +10897,7 @@ try{return ${child}(input,pos,ctx)}finally{ctx.state=saved}
10864
10897
  return `${head}
10865
10898
  const v=${child}(input,pos,ctx)
10866
10899
  if(v===FAIL)return FAIL
10867
- return ${fn}(v,{start:pos,end:EC.e})
10900
+ return ${fn}(v,new _SP(pos,EC.e))
10868
10901
  }`;
10869
10902
  }
10870
10903
  case OP_LABEL: {
@@ -10885,7 +10918,7 @@ return v
10885
10918
  const v=${child}(input,pos,ctx)
10886
10919
  if(v===FAIL)return FAIL
10887
10920
  const f=ctx._fields
10888
- if(f!==undefined)f.push({name:${name},value:v,span:{start:pos,end:EC.e}})
10921
+ if(f!==undefined)f.push(new _FC(${name},v,new _SP(pos,EC.e)))
10889
10922
  return v
10890
10923
  }`;
10891
10924
  }
@@ -10910,7 +10943,7 @@ return v
10910
10943
  return `${head}
10911
10944
  const v=${child}(input,pos,ctx)
10912
10945
  if(v!==FAIL)return v
10913
- const err={_tag:'parseError',span:${prog.lines === 1 ? "spanLines(ctx,pos,pos)" : "{start:pos,end:pos}"},expected:${xf}}
10946
+ const err={_tag:'parseError',span:${prog.lines === 1 ? "spanLines(ctx,pos,pos)" : "new _SP(pos,pos)"},expected:${xf}}
10914
10947
  const es=ctx._errors
10915
10948
  if(es!==undefined)es.push(err)
10916
10949
  ${REC ? "if(ctx._tolerant===true)captureError(ctx,err)\n" : ""}ctx._fc=false
@@ -10921,7 +10954,7 @@ return err
10921
10954
  case OP_ROUTED: {
10922
10955
  const fb = code[ip + 1];
10923
10956
  const fallback = fb >= 0 ? link(fb) : void 0;
10924
- const push = `pushCstLeaf(ctx,{_tag:'leaf',value:it.value,span:it.span})`;
10957
+ const push = `pushCstLeaf(ctx,new _LF(it.value,it.span))`;
10925
10958
  return `${head}
10926
10959
  const it=ctx._routed
10927
10960
  if(it===undefined||pos!==it.span.start){
@@ -11002,8 +11035,8 @@ ctx._triviaLog=sOtl
11002
11035
  }
11003
11036
  if(v===FAIL)return FAIL
11004
11037
  const e=EC.e
11005
- const out=${isToken ? "input.slice(pos,e)" : `${fn}(v,{start:pos,end:e})`}
11006
- if(wasCap)pushCstLeaf(ctx,{_tag:'leaf',value:${capturesSource ? "input.slice(pos,e)" : "out"},span:{start:pos,end:e}})
11038
+ const out=${isToken ? "input.slice(pos,e)" : `${fn}(v,new _SP(pos,e))`}
11039
+ if(wasCap)pushCstLeaf(ctx,new _LF(${capturesSource ? "input.slice(pos,e)" : "out"},new _SP(pos,e)))
11007
11040
  EC.e=e
11008
11041
  return out
11009
11042
  }`;
@@ -11027,7 +11060,7 @@ ${hasSuffix && (lineFlags & 2) !== 0 ? "if(sm)_trackLines(ctx,input,e)" : ""}
11027
11060
  ${hasSuffix ? `if(!sm){ctx._fe=e;ctx._fx=${suffixExpected};if(ctx._probe!==undefined)failAt(ctx,${suffixExpected},e)}` : ""}
11028
11061
  const v=${pending ? "tp?_pfTokValue:" : ""}input.slice(pos,e)
11029
11062
  ${pending ? "if(tp){_pfTokBody=-1;_pfTokValue=undefined}" : ""}
11030
- if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,{_tag:'leaf',value:v,span:{start:pos,end:e}})
11063
+ if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
11031
11064
  EC.e=e
11032
11065
  return v
11033
11066
  }`;
@@ -11066,7 +11099,7 @@ ctx._rootTriviaLog=sRtl
11066
11099
  }
11067
11100
  if(e<0)return FAIL
11068
11101
  const v=input.slice(pos,e)
11069
- if(wasCap)pushCstLeaf(ctx,{_tag:'leaf',value:v,span:{start:pos,end:e}})
11102
+ if(wasCap)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
11070
11103
  EC.e=e
11071
11104
  return v
11072
11105
  }`;
@@ -11074,7 +11107,7 @@ return v
11074
11107
  const e=${run}(input,pos,ctx)
11075
11108
  if(e<0)return FAIL
11076
11109
  const v=input.slice(pos,e)
11077
- if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,{_tag:'leaf',value:v,span:{start:pos,end:e}})
11110
+ if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
11078
11111
  EC.e=e
11079
11112
  return v
11080
11113
  }`;
@@ -11188,7 +11221,7 @@ return v
11188
11221
  }` : `${parts.join("\n")}
11189
11222
  }`;
11190
11223
  if (n === 1) {
11191
- parts.push(fused ? projection === 0 ? "return v0" : `return ${fn}([v0],{start:pos,end:EC.e})` : wantValues ? "return [v0]" : "return undefined");
11224
+ parts.push(fused ? projection === 0 ? "return v0" : `return ${fn}([v0],new _SP(pos,EC.e))` : wantValues ? "return [v0]" : "return undefined");
11192
11225
  return close();
11193
11226
  }
11194
11227
  parts.push("let cur=EC.e");
@@ -11214,7 +11247,7 @@ return v
11214
11247
  names.push(vn);
11215
11248
  }
11216
11249
  parts.push("EC.e=cur");
11217
- parts.push(fused ? projection >= 0 ? `return ${names[projection]}` : `return ${fn}([${names.join(",")}],{start:pos,end:cur})` : wantValues ? `return [${names.join(",")}]` : "return undefined");
11250
+ parts.push(fused ? projection >= 0 ? `return ${names[projection]}` : `return ${fn}([${names.join(",")}],new _SP(pos,cur))` : wantValues ? `return [${names.join(",")}]` : "return undefined");
11218
11251
  return close();
11219
11252
  }
11220
11253
  case OP_CHOICE: {
@@ -11473,7 +11506,7 @@ ${spec.match.map((m, i) => `${i === 0 ? "" : "else "}if(${dispatchClaim(m)})arm=
11473
11506
  const routedCall = (target) => `{const savedRouted=ctx._routed
11474
11507
  ${emitRollback(m1, L.buf, L.raw, sinks)}
11475
11508
  ${emitMark(m2, L.buf, L.raw, sinks, false)}
11476
- ctx._routed={value:key,span:{start:pos,end:selEnd}}
11509
+ ctx._routed={value:key,span:new _SP(pos,selEnd)}
11477
11510
  try{v=${target}(input,pos,ctx)}finally{ctx._routed=savedRouted}
11478
11511
  break}`;
11479
11512
  const plainCall = (target) => `v=${target}(input,selEnd,ctx);break`;
@@ -11668,8 +11701,8 @@ return out
11668
11701
  const end=${recognize}(input,pos)
11669
11702
  if(end<0){ctx._fe=pos;ctx._fx=${xf};return FAIL}
11670
11703
  const value=${value2}
11671
- const leaf={_tag:'leaf',value,span:{start:pos,end}}
11672
- const kids=[leaf],rawKids=[leaf],span={start:pos,end}
11704
+ const leaf=new _LF(value,new _SP(pos,end))
11705
+ const kids=[leaf],rawKids=[leaf],span=new _SP(pos,end)
11673
11706
  EC.e=end
11674
11707
  const nd=${build2}(kids,undefined,span,rawKids,EMPTY_TL,undefined)
11675
11708
  ${L.buf && L.raw === RAW_OMIT ? "_pushNodeNoRawBuf(ctx,nd)" : L.buf && L.raw === RAW_CAPTURE ? "pushCstChild(ctx,nd,rawEntry(nd,input,pos,end))" : staticBuild ? "if(ctx._cstBuf!==undefined||ctx._cstChildren!==undefined)pushCstChild(ctx,nd,ctx._cstBuf!==undefined&&ctx._cstBuf.noRaw===true?undefined:ctx._cstBuf!==undefined||ctx._cstRawChildren!==undefined?rawEntry(nd,input,pos,end):undefined)" : "if(ctx._cstBuf!==undefined||ctx._cstChildren!==undefined)pushCstChild(ctx,nd,rawEntry(nd,input,pos,end))"}
@@ -11768,7 +11801,7 @@ ctx._cstTriviaLog=sTl
11768
11801
  ctx.captureTrivia=sCap
11769
11802
  if(v===FAIL)return FAIL
11770
11803
  const end=EC.e
11771
- ${collapseChildren ? `const nd=captured.length===1?captured[0]:${build}(captured,undefined,{start:pos,end},EMPTY_CH,EMPTY_TL,undefined)` : `const nd=${build}(captured,${fields ? "fieldMap" : "undefined"},{start:pos,end},EMPTY_CH,EMPTY_TL,undefined)`}
11804
+ ${collapseChildren ? `const nd=captured.length===1?captured[0]:${build}(captured,undefined,new _SP(pos,end),EMPTY_CH,EMPTY_TL,undefined)` : `const nd=${build}(captured,${fields ? "fieldMap" : "undefined"},new _SP(pos,end),EMPTY_CH,EMPTY_TL,undefined)`}
11772
11805
  ${publish}
11773
11806
  EC.e=end
11774
11807
  return nd
@@ -11791,20 +11824,20 @@ return nd
11791
11824
  const direct = `${build}(kids,fieldMap,span,rawKids,${captureWide ? "tlog" : "EMPTY_TL"},st)`;
11792
11825
  value = hostCst ? `nd=_pfHost!==undefined?${hostCall}:${direct}` : `nd=${direct}`;
11793
11826
  } else {
11794
- value = `nd=_pfHost!==undefined?_pfHost(${ty},hostKids,fieldMap,span,rawKids,tlog,st,${tags}):{_tag:'node',type:${ty},span,state:st??null,children:kids}`;
11827
+ value = `nd=_pfHost!==undefined?_pfHost(${ty},hostKids,fieldMap,span,rawKids,tlog,st,${tags}):new _ND(${ty},span,st??null,kids===EMPTY_CH?kids:[...kids])`;
11795
11828
  }
11796
11829
  const collapsible = keepChildren && (hostCst || build === void 0 && proj < 0);
11797
- const openCapture = omitsRaw ? `const buf={noRaw:true,rawLen:0}
11830
+ const openCapture = omitsRaw ? `const buf=new _BUF(undefined,true,0)
11798
11831
  ctx._cstBuf=buf
11799
11832
  ctx._cstChildren=undefined
11800
11833
  ctx._cstLeaves=undefined
11801
11834
  ctx._cstRawChildren=undefined
11802
- ctx._cstTriviaLog=undefined` : keepChildren ? `const buf={}
11835
+ ctx._cstTriviaLog=undefined` : keepChildren ? `const buf=new _BUF(undefined,undefined,0)
11803
11836
  ctx._cstBuf=buf
11804
11837
  ctx._cstChildren=undefined
11805
11838
  ctx._cstLeaves=undefined
11806
11839
  ctx._cstRawChildren=undefined
11807
- ctx._cstTriviaLog=undefined` : `const buf={rawOnly:true}
11840
+ ctx._cstTriviaLog=undefined` : `const buf=new _BUF(true,undefined,0)
11808
11841
  ctx._cstBuf=buf
11809
11842
  ctx._cstChildren=undefined
11810
11843
  ctx._cstLeaves=undefined
@@ -11842,7 +11875,7 @@ ctx._cstTriviaLog=sTl
11842
11875
  ctx.captureTrivia=sCap
11843
11876
  if(v===FAIL)return FAIL
11844
11877
  const end=EC.e
11845
- const span=${tracked ? "spanLines(ctx,pos,end)" : "{start:pos,end}"}
11878
+ const span=${tracked ? "spanLines(ctx,pos,end)" : "new _SP(pos,end)"}
11846
11879
  const st=${readsState ? "ctx.state" : "undefined"}
11847
11880
  let nd
11848
11881
  ${unwrap ? "if(kids.length===1)nd=unwrapChild(kids[0])\nelse " : ""}${collapse ? "if(kids.length===1)nd=kids[0]\nelse " : ""}${collapsible ? `if(_pfHost!==undefined&&_pfHost._parsemanCstCollapse!==undefined&&kids.length===1&&rawKids.length===1&&_pfHost._parsemanCstCollapse(${ty},kids[0],kids,rawKids))nd=kids[0]
@@ -12129,6 +12162,7 @@ function rebuildLineScan(s, subtree) {
12129
12162
  }
12130
12163
 
12131
12164
  // src/combinators/literal.ts
12165
+ import { PlainLeaf as PlainLeaf7, PlainSpan as PlainSpan8 } from "../cst/plain.js";
12132
12166
  function asciiFoldEq(a, b) {
12133
12167
  if (a.length !== b.length) return false;
12134
12168
  for (let i = 0; i < a.length; i++) {
@@ -12186,9 +12220,9 @@ function literal(value, opts = {}) {
12186
12220
  const code = value.charCodeAt(0);
12187
12221
  return function parse3(input, pos, ctx) {
12188
12222
  if (input.charCodeAt(pos) === code) {
12189
- const span = { start: pos, end: pos + 1 };
12223
+ const span = new PlainSpan8(pos, pos + 1);
12190
12224
  if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, span.end);
12191
- if (cstCaptureActive(ctx)) pushCstLeaf(ctx, { _tag: "leaf", value, span });
12225
+ if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf7(value, span));
12192
12226
  return { ok: true, value, span };
12193
12227
  }
12194
12228
  return failAt(ctx, expected, pos);
@@ -12200,9 +12234,9 @@ function literal(value, opts = {}) {
12200
12234
  }
12201
12235
  const matchedValue = caseInsensitive ? input.slice(pos, end) : value;
12202
12236
  if (caseInsensitive ? asciiFoldEq(matchedValue, value) : input.startsWith(value, pos)) {
12203
- const span = { start: pos, end };
12237
+ const span = new PlainSpan8(pos, end);
12204
12238
  if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, end);
12205
- if (cstCaptureActive(ctx)) pushCstLeaf(ctx, { _tag: "leaf", value: matchedValue, span });
12239
+ if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf7(matchedValue, span));
12206
12240
  return { ok: true, value: matchedValue, span };
12207
12241
  }
12208
12242
  return failAt(ctx, expected, pos);
@@ -12284,6 +12318,7 @@ function ref() {
12284
12318
  }
12285
12319
 
12286
12320
  // src/combinators/scanTo.ts
12321
+ import { PlainLeaf as PlainLeaf8, PlainSpan as PlainSpan9 } from "../cst/plain.js";
12287
12322
  function resolveScanSkip(explicitSkip, raw, ctx) {
12288
12323
  if (raw) return [];
12289
12324
  const trivia2 = ctx.trivia;
@@ -12321,7 +12356,7 @@ function scanTo(sentinel, { skip, raw = false, orEOF = false, recoverAt, stopAt
12321
12356
  probeCtx._errors = ctx._errors;
12322
12357
  const emit = (end) => {
12323
12358
  if (end > pos && cstCaptureActive(ctx)) {
12324
- const leaf2 = { _tag: "leaf", value: input.slice(pos, end), span: { start: pos, end } };
12359
+ const leaf2 = new PlainLeaf8(input.slice(pos, end), new PlainSpan9(pos, end));
12325
12360
  pushCstLeaf(ctx, leaf2);
12326
12361
  }
12327
12362
  };
@@ -12600,6 +12635,9 @@ function clearOf(ranges, input, from, to) {
12600
12635
  return true;
12601
12636
  }
12602
12637
 
12638
+ // src/table/assemble.ts
12639
+ import { PlainBuf as PlainBuf2, PlainField, PlainLeaf as PlainLeaf9, PlainNode as PlainNode2, PlainSpan as PlainSpan10 } from "../cst/plain.js";
12640
+
12603
12641
  // src/table/fail-clean.ts
12604
12642
  function passChild(code, ip) {
12605
12643
  switch (code[ip]) {
@@ -12914,7 +12952,7 @@ function assemble(t2, prog, cfg) {
12914
12952
  const NULLABLE = /* @__PURE__ */ new Map();
12915
12953
  const CLEAN = REC ? () => false : failCleanAnalysis(code);
12916
12954
  function pushLeaf(ctx, value, s, e) {
12917
- const lf = { _tag: "leaf", value, span: { start: s, end: e } };
12955
+ const lf = new PlainLeaf9(value, new PlainSpan10(s, e));
12918
12956
  pushCstLeaf(ctx, lf);
12919
12957
  }
12920
12958
  function plainBuildNode(child, build, trailing) {
@@ -12947,7 +12985,7 @@ function assemble(t2, prog, cfg) {
12947
12985
  ctx.captureTrivia = sCap;
12948
12986
  if (value === FAIL) return FAIL;
12949
12987
  const end = EC.e;
12950
- const span = { start: pos, end };
12988
+ const span = new PlainSpan10(pos, end);
12951
12989
  const node2 = build(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
12952
12990
  if (sBuf !== void 0 || sCh !== void 0) {
12953
12991
  pushCstChild(ctx, node2, rawEntry(node2, input, pos, end));
@@ -12992,7 +13030,7 @@ function assemble(t2, prog, cfg) {
12992
13030
  ctx.captureTrivia = sCap;
12993
13031
  if (value === FAIL) return FAIL;
12994
13032
  const end = EC.e;
12995
- const node2 = build(captured, void 0, { start: pos, end }, EMPTY_CH, EMPTY_TL2, void 0);
13033
+ const node2 = build(captured, void 0, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
12996
13034
  if (sBuf !== void 0 || sCh !== void 0) {
12997
13035
  pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
12998
13036
  }
@@ -13029,7 +13067,7 @@ function assemble(t2, prog, cfg) {
13029
13067
  ctx.captureTrivia = sCap;
13030
13068
  if (value === FAIL) return FAIL;
13031
13069
  const end = EC.e;
13032
- const node2 = build(captured, fieldMap, { start: pos, end }, EMPTY_CH, EMPTY_TL2, void 0);
13070
+ const node2 = build(captured, fieldMap, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
13033
13071
  if (sBuf !== void 0 || sCh !== void 0) {
13034
13072
  pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
13035
13073
  }
@@ -13066,7 +13104,7 @@ function assemble(t2, prog, cfg) {
13066
13104
  ctx.captureTrivia = sCap;
13067
13105
  if (value === FAIL) return FAIL;
13068
13106
  const end = EC.e;
13069
- const span = { start: pos, end };
13107
+ const span = new PlainSpan10(pos, end);
13070
13108
  const node2 = kids.length === 1 ? kids[0] : build(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
13071
13109
  if (sBuf !== void 0 || sCh !== void 0) {
13072
13110
  pushCstChild(ctx, node2, rawEntry(node2, input, pos, end));
@@ -13103,7 +13141,7 @@ function assemble(t2, prog, cfg) {
13103
13141
  ctx.captureTrivia = sCap;
13104
13142
  if (value === FAIL) return FAIL;
13105
13143
  const end = EC.e;
13106
- const node2 = captured.length === 1 ? captured[0] : build(captured, void 0, { start: pos, end }, EMPTY_CH, EMPTY_TL2, void 0);
13144
+ const node2 = captured.length === 1 ? captured[0] : build(captured, void 0, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
13107
13145
  if (sBuf !== void 0 || sCh !== void 0) {
13108
13146
  pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
13109
13147
  }
@@ -13536,7 +13574,7 @@ function assemble(t2, prog, cfg) {
13536
13574
  return (input, pos, selEnd, key, ctx, need, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot) => {
13537
13575
  const savedRouted = ctx._routed;
13538
13576
  if (need) rollbackTriviaAt(ctx, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot);
13539
- ctx._routed = { value: key, span: { start: pos, end: selEnd } };
13577
+ ctx._routed = { value: key, span: new PlainSpan10(pos, selEnd) };
13540
13578
  let v;
13541
13579
  try {
13542
13580
  v = child(input, pos, ctx);
@@ -13969,7 +14007,7 @@ function assemble(t2, prog, cfg) {
13969
14007
  case OP_EXPECT: {
13970
14008
  const child = link(code[ip + 1]);
13971
14009
  const xf = fx[code[ip + 2]];
13972
- const expectSpan = (ctx, pos) => prog.lines === 1 ? spanLines(ctx, pos, pos) : { start: pos, end: pos };
14010
+ const expectSpan = (ctx, pos) => prog.lines === 1 ? spanLines(ctx, pos, pos) : new PlainSpan10(pos, pos);
13973
14011
  if (REC) {
13974
14012
  return (input, pos, ctx) => {
13975
14013
  const v = child(input, pos, ctx);
@@ -14001,7 +14039,7 @@ function assemble(t2, prog, cfg) {
14001
14039
  return (input, pos, ctx) => {
14002
14040
  const v = child(input, pos, ctx);
14003
14041
  if (v === FAIL) return FAIL;
14004
- ctx._fields?.push({ name, value: v, span: { start: pos, end: EC.e } });
14042
+ ctx._fields?.push(new PlainField(name, v, new PlainSpan10(pos, EC.e)));
14005
14043
  return v;
14006
14044
  };
14007
14045
  }
@@ -14025,7 +14063,7 @@ function assemble(t2, prog, cfg) {
14025
14063
  return (input, pos, ctx) => {
14026
14064
  const v = child(input, pos, ctx);
14027
14065
  if (v === FAIL) return FAIL;
14028
- return fn(v, { start: pos, end: EC.e });
14066
+ return fn(v, new PlainSpan10(pos, EC.e));
14029
14067
  };
14030
14068
  }
14031
14069
  case OP_SCAN: {
@@ -14129,7 +14167,7 @@ function assemble(t2, prog, cfg) {
14129
14167
  ctx._fx = ROUTED_FX;
14130
14168
  return FAIL;
14131
14169
  }
14132
- if (cstCaptureActive(ctx)) pushCstLeaf(ctx, { _tag: "leaf", value: item.value, span: item.span });
14170
+ if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(item.value, item.span));
14133
14171
  EC.e = item.span.end;
14134
14172
  return item.value;
14135
14173
  };
@@ -14315,7 +14353,7 @@ function assemble(t2, prog, cfg) {
14315
14353
  if (v === FAIL) return FAIL;
14316
14354
  const end = EC.e;
14317
14355
  const value = input.slice(pos, end);
14318
- if (wasCapturing) pushCstLeaf(ctx, { _tag: "leaf", value, span: { start: pos, end } });
14356
+ if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
14319
14357
  EC.e = end;
14320
14358
  return value;
14321
14359
  };
@@ -14349,7 +14387,7 @@ function assemble(t2, prog, cfg) {
14349
14387
  if (ctx._probe !== void 0) failAt(ctx, suffixExpected, end);
14350
14388
  }
14351
14389
  const value = input.slice(pos, end);
14352
- if (cstCaptureActive(ctx)) pushCstLeaf(ctx, { _tag: "leaf", value, span: { start: pos, end } });
14390
+ if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
14353
14391
  EC.e = end;
14354
14392
  return value;
14355
14393
  };
@@ -14392,7 +14430,7 @@ function assemble(t2, prog, cfg) {
14392
14430
  }
14393
14431
  if (end < 0) return FAIL;
14394
14432
  const value = input.slice(pos, end);
14395
- if (wasCapturing) pushCstLeaf(ctx, { _tag: "leaf", value, span: { start: pos, end } });
14433
+ if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
14396
14434
  EC.e = end;
14397
14435
  return value;
14398
14436
  };
@@ -14401,7 +14439,7 @@ function assemble(t2, prog, cfg) {
14401
14439
  const end = run(input, pos, ctx);
14402
14440
  if (end < 0) return FAIL;
14403
14441
  const value = input.slice(pos, end);
14404
- if (cstCaptureActive(ctx)) pushCstLeaf(ctx, { _tag: "leaf", value, span: { start: pos, end } });
14442
+ if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
14405
14443
  EC.e = end;
14406
14444
  return value;
14407
14445
  };
@@ -14434,12 +14472,8 @@ function assemble(t2, prog, cfg) {
14434
14472
  }
14435
14473
  if (v === FAIL) return FAIL;
14436
14474
  const end = EC.e;
14437
- const out = fn(v, { start: pos, end });
14438
- if (wasCapturing) pushCstLeaf(ctx, {
14439
- _tag: "leaf",
14440
- value: op === OP_SOURCE_LEAF && hostCst ? input.slice(pos, end) : out,
14441
- span: { start: pos, end }
14442
- });
14475
+ const out = fn(v, new PlainSpan10(pos, end));
14476
+ if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(op === OP_SOURCE_LEAF && hostCst ? input.slice(pos, end) : out, new PlainSpan10(pos, end)));
14443
14477
  EC.e = end;
14444
14478
  return out;
14445
14479
  };
@@ -14574,7 +14608,7 @@ function assemble(t2, prog, cfg) {
14574
14608
  const cur = runSyncTerms(input, pos, ctx, values);
14575
14609
  if (cur < 0) return FAIL;
14576
14610
  EC.e = cur;
14577
- return projection >= 0 ? values[projection] : fn(values, { start: pos, end: cur });
14611
+ return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
14578
14612
  };
14579
14613
  }
14580
14614
  if (wantValues) {
@@ -14668,7 +14702,7 @@ function assemble(t2, prog, cfg) {
14668
14702
  const cur = runAdjTerms(input, pos, ctx, values);
14669
14703
  if (cur < 0) return FAIL;
14670
14704
  EC.e = cur;
14671
- return projection >= 0 ? values[projection] : fn(values, { start: pos, end: cur });
14705
+ return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
14672
14706
  };
14673
14707
  }
14674
14708
  if (wantValues) {
@@ -14693,7 +14727,7 @@ function assemble(t2, prog, cfg) {
14693
14727
  return (input, pos, ctx) => {
14694
14728
  const v = k0(input, pos, ctx);
14695
14729
  if (v === FAIL) return FAIL;
14696
- return projection === 0 ? v : fn([v], { start: pos, end: EC.e });
14730
+ return projection === 0 ? v : fn([v], new PlainSpan10(pos, EC.e));
14697
14731
  };
14698
14732
  }
14699
14733
  if (wantValues) {
@@ -14718,7 +14752,7 @@ function assemble(t2, prog, cfg) {
14718
14752
  const cur = step(k1, input, EC.e, ctx);
14719
14753
  if (cur < 0) return FAIL;
14720
14754
  EC.e = cur;
14721
- return projection === 0 ? v0 : projection === 1 ? TERMV : fn([v0, TERMV], { start: pos, end: cur });
14755
+ return projection === 0 ? v0 : projection === 1 ? TERMV : fn([v0, TERMV], new PlainSpan10(pos, cur));
14722
14756
  };
14723
14757
  }
14724
14758
  if (wantValues) {
@@ -14752,7 +14786,7 @@ function assemble(t2, prog, cfg) {
14752
14786
  cur = step(k2, input, cur, ctx);
14753
14787
  if (cur < 0) return FAIL;
14754
14788
  EC.e = cur;
14755
- return projection === 0 ? v0 : projection === 1 ? v1 : projection === 2 ? TERMV : fn([v0, v1, TERMV], { start: pos, end: cur });
14789
+ return projection === 0 ? v0 : projection === 1 ? v1 : projection === 2 ? TERMV : fn([v0, v1, TERMV], new PlainSpan10(pos, cur));
14756
14790
  };
14757
14791
  }
14758
14792
  if (wantValues) {
@@ -14849,7 +14883,7 @@ function assemble(t2, prog, cfg) {
14849
14883
  const cur = runDirectTerms(input, pos, ctx, values);
14850
14884
  if (cur < 0) return FAIL;
14851
14885
  EC.e = cur;
14852
- return projection >= 0 ? values[projection] : fn(values, { start: pos, end: cur });
14886
+ return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
14853
14887
  };
14854
14888
  }
14855
14889
  if (wantValues) {
@@ -15747,10 +15781,10 @@ function assemble(t2, prog, cfg) {
15747
15781
  return FAIL;
15748
15782
  }
15749
15783
  const value = regexValue ? input.slice(pos, end) : spec;
15750
- const leaf2 = { _tag: "leaf", value, span: { start: pos, end } };
15784
+ const leaf2 = new PlainLeaf9(value, new PlainSpan10(pos, end));
15751
15785
  const kids = [leaf2];
15752
15786
  const rawKids = [leaf2];
15753
- const span = { start: pos, end };
15787
+ const span = new PlainSpan10(pos, end);
15754
15788
  EC.e = end;
15755
15789
  const nd = build2(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
15756
15790
  if (ctx._cstBuf !== void 0 || ctx._cstChildren !== void 0) {
@@ -15832,7 +15866,7 @@ function assemble(t2, prog, cfg) {
15832
15866
  const sCh = ctx._cstChildren;
15833
15867
  const sCap = ctx.captureTrivia;
15834
15868
  const sBuf = ctx._cstBuf;
15835
- const buf = rawOnly ? { rawOnly: true } : omitsRaw ? { noRaw: true, rawLen: 0 } : {};
15869
+ const buf = rawOnly ? new PlainBuf2(true, void 0, 0) : omitsRaw ? new PlainBuf2(void 0, true, 0) : new PlainBuf2(void 0, void 0, 0);
15836
15870
  ctx._cstBuf = buf;
15837
15871
  ctx.captureTrivia = captureWide;
15838
15872
  const savedFields = ctx._fields;
@@ -15854,7 +15888,7 @@ function assemble(t2, prog, cfg) {
15854
15888
  ctx.captureTrivia = sCap;
15855
15889
  if (v === FAIL) return FAIL;
15856
15890
  const end = EC.e;
15857
- const span = tracked ? spanLines(ctx, pos, end) : { start: pos, end };
15891
+ const span = tracked ? spanLines(ctx, pos, end) : new PlainSpan10(pos, end);
15858
15892
  const st = readsState ? ctx.state : void 0;
15859
15893
  let nd;
15860
15894
  if (unwrap && kids.length === 1) {
@@ -15878,7 +15912,7 @@ function assemble(t2, prog, cfg) {
15878
15912
  } else if (host !== void 0) {
15879
15913
  nd = host(type, hostKids, fieldMap, span, rawKids, tlog, st, tags);
15880
15914
  } else {
15881
- nd = { _tag: "node", type, span, state: st ?? null, children: kids };
15915
+ nd = new PlainNode2(type, span, st ?? null, kids === EMPTY_CH ? kids : [...kids]);
15882
15916
  }
15883
15917
  if (sBuf !== void 0 || sCh !== void 0) {
15884
15918
  pushCstChild(ctx, nd, rawEntry(nd, input, pos, end));
@@ -15904,7 +15938,7 @@ function assemble(t2, prog, cfg) {
15904
15938
  const at = fe === void 0 || fe < 0 ? pos : fe;
15905
15939
  return { ok: false, expected: ctx._fx ?? EMPTY_FX2, span: { start: at, end: at } };
15906
15940
  }
15907
- return { ok: true, value: v, span: { start: pos, end: EC.e } };
15941
+ return { ok: true, value: v, span: new PlainSpan10(pos, EC.e) };
15908
15942
  }
15909
15943
  };
15910
15944
  }
@@ -16019,7 +16053,12 @@ function assemble(t2, prog, cfg) {
16019
16053
  LEAD,
16020
16054
  triviaFieldCapture,
16021
16055
  skipDeferredTrivia,
16022
- collapseEmpty
16056
+ collapseEmpty,
16057
+ PlainSpan10,
16058
+ PlainLeaf9,
16059
+ PlainNode2,
16060
+ PlainField,
16061
+ PlainBuf2
16023
16062
  );
16024
16063
  emitReached = new Set(pre.reached);
16025
16064
  if (emitted.ext !== void 0) HYBRID = emitted;
@@ -16106,7 +16145,12 @@ function assemble(t2, prog, cfg) {
16106
16145
  LEAD,
16107
16146
  triviaFieldCapture,
16108
16147
  skipDeferredTrivia,
16109
- collapseEmpty
16148
+ collapseEmpty,
16149
+ PlainSpan10,
16150
+ PlainLeaf9,
16151
+ PlainNode2,
16152
+ PlainField,
16153
+ PlainBuf2
16110
16154
  );
16111
16155
  emitReached = em.reached;
16112
16156
  } catch (e) {
@@ -16364,7 +16408,11 @@ function tableRules(source, metadataOrEntry = {}) {
16364
16408
  return map[entry];
16365
16409
  }
16366
16410
 
16411
+ // src/version.ts
16412
+ var PARSEMAN_VERSION = "0.59.0";
16413
+
16367
16414
  // src/table/emit.ts
16415
+ var FACTORY_ARITY_GUARD = `if(arguments.length<${EMITTED_PARAMS.length})throw new Error(${JSON.stringify(`parseman: this parser was printed by parseman ${PARSEMAN_VERSION}; upgrade the parseman runtime to at least that version`)});`;
16368
16416
  function jsString(s) {
16369
16417
  return JSON.stringify(s);
16370
16418
  }
@@ -16439,7 +16487,7 @@ function emitAssemblies(prog, cfgs) {
16439
16487
  throw e;
16440
16488
  }
16441
16489
  const plan = em.plan;
16442
- out.push(`{key:${key},factory:function(${EMITTED_PARAMS.join(",")}){${em.source}
16490
+ out.push(`{key:${key},factory:function(${EMITTED_PARAMS.join(",")}){${FACTORY_ARITY_GUARD}${em.source}
16443
16491
  },plan:{classes:[${plan.classes.map((r) => `[${r.join(",")}]`).join(",")}],armExpected:[${plan.armExpected.map((r) => `[${r.join(",")}]`).join(",")}],masks:[${plan.masks.join(",")}]},reached:[${[...em.reached].join(",")}]}`);
16444
16492
  }
16445
16493
  return [`a:[${out.join(",")}],`];