parseman 0.58.3 → 0.59.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.
Files changed (101) hide show
  1. package/dist/analysis/diagnostics.js +159 -137
  2. package/dist/analysis/diagnostics.js.map +3 -3
  3. package/dist/cli/index.js +161 -138
  4. package/dist/cli/index.js.map +3 -3
  5. package/dist/combinators/choice.d.ts +0 -5
  6. package/dist/combinators/choice.d.ts.map +1 -1
  7. package/dist/combinators/dispatch.d.ts.map +1 -1
  8. package/dist/combinators/field-trivia.d.ts.map +1 -1
  9. package/dist/combinators/keywords.d.ts.map +1 -1
  10. package/dist/combinators/literal.d.ts.map +1 -1
  11. package/dist/combinators/node.d.ts.map +1 -1
  12. package/dist/combinators/regex.d.ts.map +1 -1
  13. package/dist/combinators/scanTo.d.ts +1 -16
  14. package/dist/combinators/scanTo.d.ts.map +1 -1
  15. package/dist/combinators/token.d.ts.map +1 -1
  16. package/dist/compiler/ir-serialize.d.ts.map +1 -1
  17. package/dist/compiler/linker.d.ts +0 -3
  18. package/dist/compiler/linker.d.ts.map +1 -1
  19. package/dist/compiler/token-alphabet.d.ts +5 -25
  20. package/dist/compiler/token-alphabet.d.ts.map +1 -1
  21. package/dist/compiler/token-capability.js.map +1 -1
  22. package/dist/compiler/token-dispatch.d.ts +8 -79
  23. package/dist/compiler/token-dispatch.d.ts.map +1 -1
  24. package/dist/cst/capture-buffer.d.ts.map +1 -1
  25. package/dist/cst/plain.js +69 -0
  26. package/dist/cst/plain.js.map +6 -0
  27. package/dist/cst/root-trivia-scope.d.ts +0 -3
  28. package/dist/cst/root-trivia-scope.d.ts.map +1 -1
  29. package/dist/cst/trivia-entries.d.ts +0 -2
  30. package/dist/cst/trivia-entries.d.ts.map +1 -1
  31. package/dist/cst/trivia-kinds.d.ts +0 -5
  32. package/dist/cst/trivia-kinds.d.ts.map +1 -1
  33. package/dist/index.js +163 -143
  34. package/dist/index.js.map +3 -3
  35. package/dist/language-service/index.js +19 -2
  36. package/dist/language-service/index.js.map +2 -2
  37. package/dist/line-index.d.ts +13 -0
  38. package/dist/line-index.d.ts.map +1 -1
  39. package/dist/plugin/entry-supercompiler.d.ts.map +1 -1
  40. package/dist/plugin/index.js +165 -145
  41. package/dist/plugin/index.js.map +3 -3
  42. package/dist/recovery/scan.d.ts.map +1 -1
  43. package/dist/run/index.js +4 -1
  44. package/dist/run/index.js.map +2 -2
  45. package/dist/spec/index.js +18 -1
  46. package/dist/spec/index.js.map +2 -2
  47. package/dist/spec/model.d.ts +0 -8
  48. package/dist/spec/model.d.ts.map +1 -1
  49. package/dist/table/assemble.d.ts.map +1 -1
  50. package/dist/table/emit-assembly.d.ts +1 -1
  51. package/dist/table/emit-assembly.d.ts.map +1 -1
  52. package/dist/table/emit.d.ts +6 -0
  53. package/dist/table/emit.d.ts.map +1 -1
  54. package/dist/table/encode.d.ts.map +1 -1
  55. package/dist/table/index.js +142 -133
  56. package/dist/table/index.js.map +3 -3
  57. package/dist/table/program.d.ts +0 -1
  58. package/dist/table/program.d.ts.map +1 -1
  59. package/dist/table/run-support.d.ts.map +1 -1
  60. package/dist/table/scalar-terminal.d.ts +0 -7
  61. package/dist/table/scalar-terminal.d.ts.map +1 -1
  62. package/dist/table/scan-shapes.d.ts +0 -8
  63. package/dist/table/scan-shapes.d.ts.map +1 -1
  64. package/dist/table/site-labels.d.ts +0 -2
  65. package/dist/table/site-labels.d.ts.map +1 -1
  66. package/dist/version.d.ts +1 -1
  67. package/package.json +2 -1
  68. package/src/combinators/choice.ts +1 -1
  69. package/src/combinators/dispatch.ts +2 -1
  70. package/src/combinators/field-trivia.ts +6 -5
  71. package/src/combinators/keywords.ts +3 -2
  72. package/src/combinators/literal.ts +5 -4
  73. package/src/combinators/node.ts +3 -1
  74. package/src/combinators/regex.ts +5 -4
  75. package/src/combinators/scanTo.ts +3 -2
  76. package/src/combinators/token.ts +3 -6
  77. package/src/compiler/ir-serialize.ts +2 -1
  78. package/src/compiler/linker.ts +5 -3
  79. package/src/compiler/token-alphabet.ts +14 -10
  80. package/src/compiler/token-dispatch.ts +10 -313
  81. package/src/compiler/token-scanner.ts +2 -2
  82. package/src/cst/capture-buffer.ts +13 -5
  83. package/src/cst/plain.d.ts +35 -0
  84. package/src/cst/plain.js +74 -0
  85. package/src/cst/root-trivia-scope.ts +1 -1
  86. package/src/cst/trivia-entries.ts +1 -1
  87. package/src/cst/trivia-kinds.ts +1 -1
  88. package/src/line-index.ts +37 -0
  89. package/src/plugin/entry-supercompiler.ts +3 -2
  90. package/src/recovery/scan.ts +2 -1
  91. package/src/spec/model.ts +1 -1
  92. package/src/table/assemble.ts +33 -35
  93. package/src/table/emit-assembly.ts +27 -24
  94. package/src/table/emit.ts +9 -1
  95. package/src/table/encode.ts +16 -39
  96. package/src/table/program.ts +1 -1
  97. package/src/table/run-support.ts +4 -7
  98. package/src/table/scalar-terminal.ts +1 -1
  99. package/src/table/scan-shapes.ts +15 -46
  100. package/src/table/site-labels.ts +1 -1
  101. package/src/version.ts +1 -1
package/dist/index.js CHANGED
@@ -349,6 +349,7 @@ function failAt(ctx, expected, pos) {
349
349
  }
350
350
 
351
351
  // src/line-index.ts
352
+ import { PlainLineSpan, PlainSpan } from "./cst/plain.js";
352
353
  function createLineIndex() {
353
354
  return { lineStarts: [0] };
354
355
  }
@@ -408,6 +409,27 @@ function annotateSpan(span, index) {
408
409
  endColumn: e.col
409
410
  };
410
411
  }
412
+ var SPAN_KEYS = ["start", "end", "startLine", "startColumn", "endLine", "endColumn"];
413
+ function copySpan(span) {
414
+ let n = 0;
415
+ for (const key in span) {
416
+ if (key !== SPAN_KEYS[n]) return { ...span };
417
+ n++;
418
+ }
419
+ if (n === 2) return new PlainSpan(span.start, span.end);
420
+ if (n === 6 && span.startLine !== void 0 && span.startColumn !== void 0 && span.endLine !== void 0 && span.endColumn !== void 0) {
421
+ return new PlainLineSpan(span.start, span.end, span.startLine, span.startColumn, span.endLine, span.endColumn);
422
+ }
423
+ return { ...span };
424
+ }
425
+ function lineSpanFromContext(span, ctx) {
426
+ if (!ctx.trackLines) return span;
427
+ const index = ctx._lineIndex ?? (ctx._lineStarts ? { lineStarts: ctx._lineStarts } : void 0);
428
+ if (!index) return span;
429
+ const s = offsetToLineCol(index, span.start);
430
+ const e = offsetToLineCol(index, span.end);
431
+ return new PlainLineSpan(span.start, span.end, s.line, s.col, e.line, e.col);
432
+ }
411
433
  function annotateSpanFromLineContext(span, ctx) {
412
434
  if (!ctx.trackLines) return span;
413
435
  const index = ctx._lineIndex ?? (ctx._lineStarts ? { lineStarts: ctx._lineStarts } : void 0);
@@ -430,6 +452,7 @@ function annotateTreeSpans(value, index, seen = /* @__PURE__ */ new WeakSet()) {
430
452
  }
431
453
 
432
454
  // src/cst/capture-buffer.ts
455
+ import { PlainBuf, PlainLeaf } from "./cst/plain.js";
433
456
  var EMPTY = [];
434
457
  var EMPTY_TL = [];
435
458
  function cstCaptureActive(ctx) {
@@ -444,7 +467,7 @@ function beginCstNodeCapture(ctx) {
444
467
  cap: ctx.captureTrivia,
445
468
  buf: ctx._cstBuf
446
469
  };
447
- ctx._cstBuf = {};
470
+ ctx._cstBuf = new PlainBuf(void 0, void 0, 0);
448
471
  ctx._cstChildren = void 0;
449
472
  ctx._cstLeaves = void 0;
450
473
  ctx._cstRawChildren = void 0;
@@ -469,12 +492,15 @@ function endCstNodeCapture(ctx, saved) {
469
492
  ctx.captureTrivia = saved.cap;
470
493
  return materialized;
471
494
  }
495
+ function isLeaf(v) {
496
+ return typeof v === "object" && v !== null && v._tag === "leaf";
497
+ }
472
498
  function pushCstLeaf(ctx, leaf2) {
473
499
  if (!ctx.trackLines) {
474
500
  pushCstChild(ctx, leaf2, leaf2);
475
501
  return;
476
502
  }
477
- const annotated = leaf2 && typeof leaf2 === "object" && leaf2.span ? { ...leaf2, span: annotateSpanFromLineContext(leaf2.span, ctx) } : leaf2;
503
+ 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;
478
504
  pushCstChild(ctx, annotated, annotated);
479
505
  }
480
506
  function pushCstChild(ctx, built, rawEntry2) {
@@ -663,6 +689,7 @@ function assertionFailureExpected(positive, childTag) {
663
689
  }
664
690
 
665
691
  // src/combinators/literal.ts
692
+ import { PlainLeaf as PlainLeaf2, PlainSpan as PlainSpan2 } from "./cst/plain.js";
666
693
  function asciiFoldEq(a, b) {
667
694
  if (a.length !== b.length) return false;
668
695
  for (let i = 0; i < a.length; i++) {
@@ -720,9 +747,9 @@ function literal(value, opts = {}) {
720
747
  const code = value.charCodeAt(0);
721
748
  return function parse3(input, pos, ctx) {
722
749
  if (input.charCodeAt(pos) === code) {
723
- const span = { start: pos, end: pos + 1 };
750
+ const span = new PlainSpan2(pos, pos + 1);
724
751
  if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, span.end);
725
- if (cstCaptureActive(ctx)) pushCstLeaf(ctx, { _tag: "leaf", value, span });
752
+ if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf2(value, span));
726
753
  return { ok: true, value, span };
727
754
  }
728
755
  return failAt(ctx, expected, pos);
@@ -734,9 +761,9 @@ function literal(value, opts = {}) {
734
761
  }
735
762
  const matchedValue = caseInsensitive ? input.slice(pos, end) : value;
736
763
  if (caseInsensitive ? asciiFoldEq(matchedValue, value) : input.startsWith(value, pos)) {
737
- const span = { start: pos, end };
764
+ const span = new PlainSpan2(pos, end);
738
765
  if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, end);
739
- if (cstCaptureActive(ctx)) pushCstLeaf(ctx, { _tag: "leaf", value: matchedValue, span });
766
+ if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf2(matchedValue, span));
740
767
  return { ok: true, value: matchedValue, span };
741
768
  }
742
769
  return failAt(ctx, expected, pos);
@@ -1198,6 +1225,7 @@ function firstSetFromRegex(source, flags = "") {
1198
1225
  }
1199
1226
 
1200
1227
  // src/combinators/regex.ts
1228
+ import { PlainLeaf as PlainLeaf3, PlainSpan as PlainSpan3 } from "./cst/plain.js";
1201
1229
  var SCAN_BAIL_AT = 64;
1202
1230
  function inRanges(cp, ranges) {
1203
1231
  for (let i = 0; i < ranges.length; i++) {
@@ -1310,9 +1338,9 @@ function regex(pattern, flags = "") {
1310
1338
  if (scanEnd !== void 0) {
1311
1339
  if (scanEnd === null) return failAt(ctx, directTerminalFailureExpected(def), pos);
1312
1340
  const value = input.slice(pos, scanEnd);
1313
- const span2 = { start: pos, end: scanEnd };
1341
+ const span2 = new PlainSpan3(pos, scanEnd);
1314
1342
  if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, scanEnd);
1315
- if (cstCaptureActive(ctx)) pushCstLeaf(ctx, { _tag: "leaf", value, span: span2 });
1343
+ if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf3(value, span2));
1316
1344
  return { ok: true, value, span: span2 };
1317
1345
  }
1318
1346
  anchored.lastIndex = pos;
@@ -1320,9 +1348,9 @@ function regex(pattern, flags = "") {
1320
1348
  if (m === null) {
1321
1349
  return failAt(ctx, directTerminalFailureExpected(def), pos);
1322
1350
  }
1323
- const span = { start: pos, end: pos + m[0].length };
1351
+ const span = new PlainSpan3(pos, pos + m[0].length);
1324
1352
  if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, span.end);
1325
- if (cstCaptureActive(ctx)) pushCstLeaf(ctx, { _tag: "leaf", value: m[0], span });
1353
+ if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf3(m[0], span));
1326
1354
  return { ok: true, value: m[0], span };
1327
1355
  }
1328
1356
  };
@@ -1364,6 +1392,7 @@ function caseFoldVariants(cp) {
1364
1392
  }
1365
1393
 
1366
1394
  // src/combinators/keywords.ts
1395
+ import { PlainLeaf as PlainLeaf4, PlainSpan as PlainSpan4 } from "./cst/plain.js";
1367
1396
  function word(str, boundaryOrOpts, opts) {
1368
1397
  const boundary = typeof boundaryOrOpts === "string" ? boundaryOrOpts : "_0-9A-Za-z";
1369
1398
  const rest = typeof boundaryOrOpts === "object" && boundaryOrOpts !== null ? boundaryOrOpts : opts;
@@ -1422,8 +1451,8 @@ function keywords(words, opts = {}) {
1422
1451
  const m = re.exec(input);
1423
1452
  if (m === null) return failAt(ctx, directTerminalFailureExpected(def), pos);
1424
1453
  const value = m[0];
1425
- const span = { start: pos, end: pos + value.length };
1426
- if (cstCaptureActive(ctx)) pushCstLeaf(ctx, { _tag: "leaf", value, span });
1454
+ const span = new PlainSpan4(pos, pos + value.length);
1455
+ if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf4(value, span));
1427
1456
  return { ok: true, value, span };
1428
1457
  }
1429
1458
  };
@@ -2711,6 +2740,7 @@ function altStarSource(source) {
2711
2740
  }
2712
2741
 
2713
2742
  // src/recovery/scan.ts
2743
+ import { PlainSpan as PlainSpan5 } from "./cst/plain.js";
2714
2744
  function probeAt(sentinel, input, pos, ctx) {
2715
2745
  const s = {
2716
2746
  _probe: ctx._probe,
@@ -2787,7 +2817,7 @@ function firstSetSentinel(fs) {
2787
2817
  function recoverScan(input, from, ctx, sync, expected) {
2788
2818
  let scanPos = from;
2789
2819
  while (scanPos < input.length && !probeAt(sync, input, scanPos, ctx)) scanPos++;
2790
- const span = { start: from, end: scanPos };
2820
+ const span = new PlainSpan5(from, scanPos);
2791
2821
  if (ctx.trackLines) recordLineRangeFromContext(ctx, input, from, scanPos);
2792
2822
  const error = { _tag: "parseError", span: ctx.trackLines ? annotateSpanFromLineContext(span, ctx) : span, expected };
2793
2823
  ctx._errors?.push(error);
@@ -2889,17 +2919,18 @@ function scalarRootOf(combinator) {
2889
2919
  }
2890
2920
 
2891
2921
  // src/combinators/field-trivia.ts
2922
+ import { PlainSpan as PlainSpan6, PlainTriviaField } from "./cst/plain.js";
2892
2923
  var LEAD = { at: -1 };
2893
2924
  var FIELD_LEADING_TRIVIA = 1;
2894
2925
  var FIELD_TRAILING_TRIVIA = 2;
2895
2926
  function triviaFieldCapture(name, value, input, start, end, leadFrom, trailEnd) {
2896
- return {
2927
+ return new PlainTriviaField(
2897
2928
  name,
2898
2929
  value,
2899
- span: { start, end },
2900
- leading: leadFrom >= 0 && leadFrom < start ? input.slice(leadFrom, start) : "",
2901
- trailing: trailEnd > end ? input.slice(end, trailEnd) : ""
2902
- };
2930
+ new PlainSpan6(start, end),
2931
+ leadFrom >= 0 && leadFrom < start ? input.slice(leadFrom, start) : "",
2932
+ trailEnd > end ? input.slice(end, trailEnd) : ""
2933
+ );
2903
2934
  }
2904
2935
  function leadsTrivia(p) {
2905
2936
  return p._def.tag === "field" && p._def.leadingTrivia === true;
@@ -3481,6 +3512,7 @@ function buildAsciiDispatch(parsers) {
3481
3512
  }
3482
3513
 
3483
3514
  // src/combinators/dispatch.ts
3515
+ import { PlainLeaf as PlainLeaf5 } from "./cst/plain.js";
3484
3516
  function parserUsesRouted(parser2, seen = /* @__PURE__ */ new Set()) {
3485
3517
  if (seen.has(parser2)) return false;
3486
3518
  seen.add(parser2);
@@ -3620,7 +3652,7 @@ function routed(fallback) {
3620
3652
  return { ok: false, expected: ["routed()"], span: { start: pos, end: pos } };
3621
3653
  }
3622
3654
  if (cstCaptureActive(ctx)) {
3623
- pushCstLeaf(ctx, { _tag: "leaf", value: item.value, span: item.span });
3655
+ pushCstLeaf(ctx, new PlainLeaf5(item.value, item.span));
3624
3656
  }
3625
3657
  return { ok: true, value: item.value, span: item.span };
3626
3658
  }
@@ -5132,6 +5164,7 @@ function buildFieldMap(captures) {
5132
5164
  }
5133
5165
 
5134
5166
  // src/combinators/node.ts
5167
+ import { PlainNode, PlainSpan as PlainSpan7 } from "./cst/plain.js";
5135
5168
  function unwrapChild(child) {
5136
5169
  return child !== null && typeof child === "object" && child._tag === "leaf" ? child.value : child;
5137
5170
  }
@@ -5237,7 +5270,7 @@ function node(typeOrCombinator, combinatorOrBuild, buildOrOpts, maybeOpts) {
5237
5270
  const nodeType = def.type ?? missingInferredType();
5238
5271
  const cstOutput2 = cstOutputHost(ctx.build);
5239
5272
  const span = ctx.trackLines ? annotateSpanFromLineContext(r.span, ctx) : r.span;
5240
- const built = unwrap && children2.length === 1 ? unwrapChild(children2[0]) : collapse && children2.length === 1 ? children2[0] : (cstOutput2 || !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 ? cstOutput2 && ctx.build ? ctx.build(nodeType, children2, fields, span, rawChildren, triviaLog, ctx.state, tags) : projectChild(children2, project, nodeType) : build ? cstOutput2 && 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 };
5273
+ const built = unwrap && children2.length === 1 ? unwrapChild(children2[0]) : collapse && children2.length === 1 ? children2[0] : (cstOutput2 || !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 ? cstOutput2 && ctx.build ? ctx.build(nodeType, children2, fields, span, rawChildren, triviaLog, ctx.state, tags) : projectChild(children2, project, nodeType) : build ? cstOutput2 && 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]);
5241
5274
  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 };
5242
5275
  if (saved.buf !== void 0 || saved.ch !== void 0) {
5243
5276
  pushCstChild(ctx, built, rawEntry2);
@@ -5393,6 +5426,7 @@ function field(name, combinator, opts) {
5393
5426
  }
5394
5427
 
5395
5428
  // src/combinators/token.ts
5429
+ import { PlainLeaf as PlainLeaf6 } from "./cst/plain.js";
5396
5430
  function semanticLeafValue(_ctx, _input, _start, _end, value) {
5397
5431
  return value;
5398
5432
  }
@@ -5446,7 +5480,7 @@ function token(root) {
5446
5480
  if (!result.ok) return result;
5447
5481
  const span = result.span;
5448
5482
  const value = input.slice(pos, span.end);
5449
- if (wasCapturing) pushCstLeaf(ctx, { _tag: "leaf", value, span });
5483
+ if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf6(value, span));
5450
5484
  return { ok: true, value, span };
5451
5485
  }
5452
5486
  };
@@ -5494,11 +5528,7 @@ function makeLeaf(root, fn, sourceCstValue) {
5494
5528
  }
5495
5529
  if (!result.ok) return result;
5496
5530
  const value = fn(result.value, result.span);
5497
- if (wasCapturing) pushCstLeaf(ctx, {
5498
- _tag: "leaf",
5499
- value: cstValue(ctx, input, pos, result.span.end, value),
5500
- span: result.span
5501
- });
5531
+ if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf6(cstValue(ctx, input, pos, result.span.end, value), result.span));
5502
5532
  return { ok: true, value, span: result.span };
5503
5533
  }
5504
5534
  };
@@ -5531,6 +5561,7 @@ function buildLexBodyRecognizer(spec, constants) {
5531
5561
  }
5532
5562
 
5533
5563
  // src/table/run-support.ts
5564
+ import { PlainLeaf as PlainLeaf7, PlainLineSpan as PlainLineSpan2, PlainSpan as PlainSpan8 } from "./cst/plain.js";
5534
5565
  function lineCol(ctx, offset) {
5535
5566
  const starts = ctx._lineStarts ?? [0];
5536
5567
  let lo = 0, hi = starts.length - 1;
@@ -5543,18 +5574,14 @@ function lineCol(ctx, offset) {
5543
5574
  }
5544
5575
  function spanLines(ctx, start, end) {
5545
5576
  const s = lineCol(ctx, start), e = lineCol(ctx, end);
5546
- return { start, end, startLine: s[0], startColumn: s[1], endLine: e[0], endColumn: e[1] };
5577
+ return new PlainLineSpan2(start, end, s[0], s[1], e[0], e[1]);
5547
5578
  }
5548
5579
  function rawEntry(v, input, s, e) {
5549
5580
  if (typeof v === "object" && v !== null) {
5550
5581
  const tg = v._tag;
5551
5582
  if (tg === "node" || tg === "leaf" || tg === "parseError") return v;
5552
5583
  }
5553
- return {
5554
- _tag: "leaf",
5555
- value: typeof v === "string" ? v : typeof v === "object" && v !== null ? input.slice(s, e) : "",
5556
- span: { start: s, end: e }
5557
- };
5584
+ return new PlainLeaf7(typeof v === "string" ? v : typeof v === "object" && v !== null ? input.slice(s, e) : "", new PlainSpan8(s, e));
5558
5585
  }
5559
5586
  function lead(input, pos) {
5560
5587
  if (pos >= input.length) return -1;
@@ -5568,7 +5595,7 @@ function collapseEmpty(ctx, build, input, pos, end, readsRaw) {
5568
5595
  const collected = ctx._cstBuf !== void 0 || ctx._cstChildren !== void 0;
5569
5596
  if (collected) popCstChild(ctx);
5570
5597
  const raw = readsRaw ? [rawEntry(void 0, input, pos, end)] : EMPTY_KIDS;
5571
- const nd = build(EMPTY_KIDS, void 0, { start: pos, end }, raw, EMPTY_TRIVIA, void 0);
5598
+ const nd = build(EMPTY_KIDS, void 0, new PlainSpan8(pos, end), raw, EMPTY_TRIVIA, void 0);
5572
5599
  if (collected) pushCstChild(ctx, nd, ctx._cstBuf?.noRaw === true ? void 0 : rawEntry(nd, input, pos, end));
5573
5600
  return nd;
5574
5601
  }
@@ -8171,18 +8198,10 @@ var Encoder = class {
8171
8198
  /** TOKEN bodies are an all-program decision. A complete occurrence inside an
8172
8199
  * otherwise incomplete final graph stays on CHARACTER with every sibling. */
8173
8200
  selectLexicalBodies;
8174
- /**
8175
- * Decides the extra operands laid down below. ALWAYS TRUE — see
8176
- * `TableSettings.recovery`. Kept as a field rather than folded away because it
8177
- * is what every emit site reads, and the emit sites are where the shape of the
8178
- * row is stated.
8179
- */
8180
- rec;
8181
8201
  constructor(settings, selectLexicalBodies) {
8182
8202
  this.settings = settings;
8183
8203
  this.track = settings.trackLines === true;
8184
8204
  this.selectLexicalBodies = selectLexicalBodies;
8185
- this.rec = true;
8186
8205
  this.plan = settings.coverage;
8187
8206
  this.cov = settings.coverage === void 0 ? void 0 : settings.coverage.definitions.map((d) => [d.id, covKindCode(d.kind)]);
8188
8207
  this.covIndex = new Map((this.cov ?? []).map((d, i) => [d[0], i]));
@@ -8684,12 +8703,10 @@ var Encoder = class {
8684
8703
  }
8685
8704
  case "sequence": {
8686
8705
  const kids = d.parsers.map((c) => this.node(c).ip);
8687
- const head = this.emitHead(d.valueUnused ? OP_SEQV : OP_SEQ, 1 + kids.length + (this.rec ? kids.length : 0));
8706
+ const head = this.emitHead(d.valueUnused ? OP_SEQV : OP_SEQ, 1 + 2 * kids.length);
8688
8707
  this.code[head + 1] = kids.length;
8689
8708
  for (let i = 0; i < kids.length; i++) this.code[head + 2 + i] = kids[i];
8690
- if (this.rec) {
8691
- for (let i = 0; i < kids.length; i++) this.code[head + 2 + kids.length + i] = this.followClass(d.parsers, i);
8692
- }
8709
+ for (let i = 0; i < kids.length; i++) this.code[head + 2 + kids.length + i] = this.followClass(d.parsers, i);
8693
8710
  return head;
8694
8711
  }
8695
8712
  case "choice": {
@@ -8791,25 +8808,22 @@ var Encoder = class {
8791
8808
  const itemClass = matchesEmpty(d.parser, /* @__PURE__ */ new Set(), rr) ? -1 : this.charClass(firstSetOf(d.parser, /* @__PURE__ */ new Set(), rr, this.activeTrivia));
8792
8809
  const op = d.valueUnused ? OP_REPV : OP_REP;
8793
8810
  const min = d.tag === "many" ? 0 : d.min;
8794
- return this.rec ? this.emit(op, child, min, d.max ?? -1, -1, 0, this.expected(deriveExpected(d.parser)), itemClass) : this.emit(op, child, min, d.max ?? -1, -1, 0);
8811
+ return this.emit(op, child, min, d.max ?? -1, -1, 0, this.expected(deriveExpected(d.parser)), itemClass);
8795
8812
  }
8796
8813
  case "sepBy": {
8797
8814
  const child = this.node(d.parser).ip;
8798
8815
  const sep = this.node(d.separator).ip;
8799
8816
  const flags = (d.trailing === "allow" ? 1 : 0) | (d.keepSeparators === true ? 2 : 0) | (d.min >= 2 ? 4 : 0);
8800
- if (this.rec) {
8801
- return this.emit(
8802
- OP_REP,
8803
- child,
8804
- d.min,
8805
- d.max ?? -1,
8806
- sep,
8807
- flags,
8808
- this.expected(deriveExpected(d.parser)),
8809
- this.charClass(firstSetOf(d.separator, /* @__PURE__ */ new Set(), this.refResolver(), this.activeTrivia))
8810
- );
8811
- }
8812
- return d.min >= 2 ? this.emit(OP_REP, child, d.min, d.max ?? -1, sep, flags, this.expected(deriveExpected(d.parser))) : this.emit(OP_REP, child, d.min, d.max ?? -1, sep, flags);
8817
+ return this.emit(
8818
+ OP_REP,
8819
+ child,
8820
+ d.min,
8821
+ d.max ?? -1,
8822
+ sep,
8823
+ flags,
8824
+ this.expected(deriveExpected(d.parser)),
8825
+ this.charClass(firstSetOf(d.separator, /* @__PURE__ */ new Set(), this.refResolver(), this.activeTrivia))
8826
+ );
8813
8827
  }
8814
8828
  case "optional": {
8815
8829
  const head = this.emit(OP_OPT, this.lookaheadGate(d.parser, this.node(d.parser).ip));
@@ -8820,14 +8834,12 @@ var Encoder = class {
8820
8834
  const inner = d.parser._def;
8821
8835
  if (inner.tag === "sequence" && !this.memo.has(d.parser) && !this.pending.has(d.parser)) {
8822
8836
  const kids = inner.parsers.map((c) => this.node(c).ip);
8823
- const head = this.emitHead(OP_SEQX, 2 + kids.length + (this.rec ? kids.length : 0));
8837
+ const head = this.emitHead(OP_SEQX, 2 + 2 * kids.length);
8824
8838
  const projection = directArrayProjection(d.fn, d.fnSrc, kids.length);
8825
8839
  this.code[head + 1] = projection === null ? this.fn(d.fn, d.fnSrc ?? null) : ~projection;
8826
8840
  this.code[head + 2] = kids.length;
8827
8841
  for (let i = 0; i < kids.length; i++) this.code[head + 3 + i] = kids[i];
8828
- if (this.rec) {
8829
- for (let i = 0; i < kids.length; i++) this.code[head + 3 + kids.length + i] = this.followClass(inner.parsers, i);
8830
- }
8842
+ for (let i = 0; i < kids.length; i++) this.code[head + 3 + kids.length + i] = this.followClass(inner.parsers, i);
8831
8843
  return head;
8832
8844
  }
8833
8845
  const child = this.node(d.parser).ip;
@@ -9150,7 +9162,7 @@ var Encoder = class {
9150
9162
  ...this.settings.hostMode === void 0 ? {} : { hostMode: this.settings.hostMode },
9151
9163
  ...this.runtimeOnly.size === 0 ? {} : { runtimeOnly: [...this.runtimeOnly].sort() },
9152
9164
  ...this.triviaSpecs.length === 0 ? {} : { triviaSpecs: this.triviaSpecs },
9153
- ...this.rec ? { rec: 1 } : {},
9165
+ rec: 1,
9154
9166
  ...this.cov === void 0 ? {} : { cov: this.cov },
9155
9167
  lines: this.track ? 1 : 0
9156
9168
  }, void 0, {
@@ -9917,7 +9929,6 @@ function caseFoldLiteralOrAlt(source) {
9917
9929
  }
9918
9930
  return { kind: "alt", arms: litArms, disjoint: false, firsts: litArms.map(() => null) };
9919
9931
  }
9920
- var scanToIndexOfEnabled = () => process.env.PARSEMAN_SCANTO === "indexof";
9921
9932
  var classCond = (cVar, ranges) => ranges.map(([lo, hi]) => lo === hi ? `${cVar} === ${lo}` : `(${cVar} >= ${lo} && ${cVar} <= ${hi})`).join(" || ");
9922
9933
  var litCond = (base, cps, firstVar) => cps.map(
9923
9934
  (cp, k) => k === 0 && firstVar ? `${firstVar} === ${cp}` : `input.charCodeAt(${base}${k ? ` + ${k}` : ""}) === ${cp}`
@@ -10147,13 +10158,7 @@ function emitShapeMatch(shape, start, mint, ind, firstChar) {
10147
10158
  const j2 = mint("_j");
10148
10159
  const openLen2 = shape.open.length;
10149
10160
  const openChk2 = openLen2 === 1 ? `${codeAt(start, firstChar)} === ${shape.open[0]}` : litCond(start, shape.open, firstChar);
10150
- const stopCp = shape.stop.length === 1 && shape.stop[0][0] === shape.stop[0][1] ? shape.stop[0][0] : null;
10151
- const scanLine = stopCp !== null && stopCp <= 65535 && scanToIndexOfEnabled() ? (
10152
- // No temp is minted: a temp would renumber every later variable in the
10153
- // function and show up as an artifact-size delta that is counter
10154
- // renumbering rather than this change (the §9.1.4 / §9.2 effect).
10155
- `${ind} ${j2} = input.indexOf(${JSON.stringify(String.fromCharCode(stopCp))}, ${j2}); if (${j2} < 0) ${j2} = input.length`
10156
- ) : `${ind} while (${j2} < input.length && !(${classCond(`input.charCodeAt(${j2})`, shape.stop)})) ${j2}++`;
10161
+ const scanLine = `${ind} while (${j2} < input.length && !(${classCond(`input.charCodeAt(${j2})`, shape.stop)})) ${j2}++`;
10157
10162
  return {
10158
10163
  setup: [
10159
10164
  `${ind}let ${j2} = ${start}`,
@@ -10211,11 +10216,7 @@ function emitShapeMatch(shape, start, mint, ind, firstChar) {
10211
10216
  const closeLen = shape.close.length;
10212
10217
  const openChk = openLen === 1 ? `${codeAt(start, firstChar)} === ${shape.open[0]}` : litCond(start, shape.open, firstChar);
10213
10218
  const closeChk = litCond(j, shape.close);
10214
- const closeStr = String.fromCharCode(...shape.close);
10215
- const scanLines = scanToIndexOfEnabled() ? [
10216
- `${ind} ${j} = input.indexOf(${JSON.stringify(closeStr)}, ${j}); if (${j} < 0) ${j} = input.length`,
10217
- `${ind} if (${j} + ${closeLen} <= input.length) ${endV} = ${j} + ${closeLen}`
10218
- ] : [
10219
+ const scanLines = [
10219
10220
  `${ind} while (${j} + ${closeLen - 1} < input.length && !(${closeChk})) ${j}++`,
10220
10221
  `${ind} if (${j} + ${closeLen} <= input.length && (${closeChk})) ${endV} = ${j} + ${closeLen}`
10221
10222
  ];
@@ -10851,7 +10852,14 @@ var EMITTED_PARAMS = [
10851
10852
  "skipDeferredTrivia",
10852
10853
  // Appended for the pass-through collapse (`run-support.ts`); old factories
10853
10854
  // ignore it.
10854
- "collapseEmpty"
10855
+ "collapseEmpty",
10856
+ // Appended for constructor-built tree objects (`cst/plain.d.ts`): a `new` call has
10857
+ // no allocation site, so V8 cannot pretenure them. Old factories ignore them.
10858
+ "_SP",
10859
+ "_LF",
10860
+ "_ND",
10861
+ "_FC",
10862
+ "_BUF"
10855
10863
  ];
10856
10864
  var RUNTIME_PRELUDE = `
10857
10865
  let _pfScan=null
@@ -10875,9 +10883,9 @@ if(s!==null)return skipTriviaScanned(s,input,cur,ctx)
10875
10883
  if(needsDeferredTriviaCommit(ctx))return skipDeferredTrivia(input,cur,ctx)
10876
10884
  return advanceTrivia(input,cur,ctx)
10877
10885
  }
10878
- function _pushLeaf(ctx,value,s,e){pushCstLeaf(ctx,{_tag:'leaf',value,span:{start:s,end:e}})}
10886
+ function _pushLeaf(ctx,value,s,e){pushCstLeaf(ctx,new _LF(value,new _SP(s,e)))}
10879
10887
  function _pushLeafBuf(ctx,value,s,e){
10880
- const l={_tag:'leaf',value,span:{start:s,end:e}}
10888
+ const l=new _LF(value,new _SP(s,e))
10881
10889
  const b=ctx._cstBuf
10882
10890
  if(b.ch!==undefined)b.ch.push(l)
10883
10891
  else if(b.single!==undefined){b.ch=[b.single,l];b.single=undefined}
@@ -10935,7 +10943,7 @@ if(ctx._rootTriviaLog!==undefined&&ctx._rootTriviaLog.length!==rt)ctx._rootTrivi
10935
10943
  `;
10936
10944
  var NO_RAW_RUNTIME_PRELUDE = `
10937
10945
  function _pushLeafNoRawBuf(ctx,value,s,e){
10938
- const l={_tag:'leaf',value,span:{start:s,end:e}}
10946
+ const l=new _LF(value,new _SP(s,e))
10939
10947
  const b=ctx._cstBuf
10940
10948
  if(b.ch!==undefined)b.ch.push(l)
10941
10949
  else if(b.single!==undefined){b.ch=[b.single,l];b.single=undefined}
@@ -11612,7 +11620,7 @@ try{return ${child}(input,pos,ctx)}finally{ctx.state=saved}
11612
11620
  return `${head}
11613
11621
  const v=${child}(input,pos,ctx)
11614
11622
  if(v===FAIL)return FAIL
11615
- return ${fn}(v,{start:pos,end:EC.e})
11623
+ return ${fn}(v,new _SP(pos,EC.e))
11616
11624
  }`;
11617
11625
  }
11618
11626
  case OP_LABEL: {
@@ -11633,7 +11641,7 @@ return v
11633
11641
  const v=${child}(input,pos,ctx)
11634
11642
  if(v===FAIL)return FAIL
11635
11643
  const f=ctx._fields
11636
- if(f!==undefined)f.push({name:${name},value:v,span:{start:pos,end:EC.e}})
11644
+ if(f!==undefined)f.push(new _FC(${name},v,new _SP(pos,EC.e)))
11637
11645
  return v
11638
11646
  }`;
11639
11647
  }
@@ -11658,7 +11666,7 @@ return v
11658
11666
  return `${head}
11659
11667
  const v=${child}(input,pos,ctx)
11660
11668
  if(v!==FAIL)return v
11661
- const err={_tag:'parseError',span:${prog.lines === 1 ? "spanLines(ctx,pos,pos)" : "{start:pos,end:pos}"},expected:${xf}}
11669
+ const err={_tag:'parseError',span:${prog.lines === 1 ? "spanLines(ctx,pos,pos)" : "new _SP(pos,pos)"},expected:${xf}}
11662
11670
  const es=ctx._errors
11663
11671
  if(es!==undefined)es.push(err)
11664
11672
  ${REC2 ? "if(ctx._tolerant===true)captureError(ctx,err)\n" : ""}ctx._fc=false
@@ -11669,7 +11677,7 @@ return err
11669
11677
  case OP_ROUTED: {
11670
11678
  const fb = code[ip + 1];
11671
11679
  const fallback = fb >= 0 ? link(fb) : void 0;
11672
- const push = `pushCstLeaf(ctx,{_tag:'leaf',value:it.value,span:it.span})`;
11680
+ const push = `pushCstLeaf(ctx,new _LF(it.value,it.span))`;
11673
11681
  return `${head}
11674
11682
  const it=ctx._routed
11675
11683
  if(it===undefined||pos!==it.span.start){
@@ -11750,8 +11758,8 @@ ctx._triviaLog=sOtl
11750
11758
  }
11751
11759
  if(v===FAIL)return FAIL
11752
11760
  const e=EC.e
11753
- const out=${isToken ? "input.slice(pos,e)" : `${fn}(v,{start:pos,end:e})`}
11754
- if(wasCap)pushCstLeaf(ctx,{_tag:'leaf',value:${capturesSource ? "input.slice(pos,e)" : "out"},span:{start:pos,end:e}})
11761
+ const out=${isToken ? "input.slice(pos,e)" : `${fn}(v,new _SP(pos,e))`}
11762
+ if(wasCap)pushCstLeaf(ctx,new _LF(${capturesSource ? "input.slice(pos,e)" : "out"},new _SP(pos,e)))
11755
11763
  EC.e=e
11756
11764
  return out
11757
11765
  }`;
@@ -11775,7 +11783,7 @@ ${hasSuffix && (lineFlags & 2) !== 0 ? "if(sm)_trackLines(ctx,input,e)" : ""}
11775
11783
  ${hasSuffix ? `if(!sm){ctx._fe=e;ctx._fx=${suffixExpected};if(ctx._probe!==undefined)failAt(ctx,${suffixExpected},e)}` : ""}
11776
11784
  const v=${pending ? "tp?_pfTokValue:" : ""}input.slice(pos,e)
11777
11785
  ${pending ? "if(tp){_pfTokBody=-1;_pfTokValue=undefined}" : ""}
11778
- if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,{_tag:'leaf',value:v,span:{start:pos,end:e}})
11786
+ if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
11779
11787
  EC.e=e
11780
11788
  return v
11781
11789
  }`;
@@ -11814,7 +11822,7 @@ ctx._rootTriviaLog=sRtl
11814
11822
  }
11815
11823
  if(e<0)return FAIL
11816
11824
  const v=input.slice(pos,e)
11817
- if(wasCap)pushCstLeaf(ctx,{_tag:'leaf',value:v,span:{start:pos,end:e}})
11825
+ if(wasCap)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
11818
11826
  EC.e=e
11819
11827
  return v
11820
11828
  }`;
@@ -11822,7 +11830,7 @@ return v
11822
11830
  const e=${run3}(input,pos,ctx)
11823
11831
  if(e<0)return FAIL
11824
11832
  const v=input.slice(pos,e)
11825
- if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,{_tag:'leaf',value:v,span:{start:pos,end:e}})
11833
+ if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
11826
11834
  EC.e=e
11827
11835
  return v
11828
11836
  }`;
@@ -11936,7 +11944,7 @@ return v
11936
11944
  }` : `${parts.join("\n")}
11937
11945
  }`;
11938
11946
  if (n === 1) {
11939
- parts.push(fused ? projection === 0 ? "return v0" : `return ${fn}([v0],{start:pos,end:EC.e})` : wantValues ? "return [v0]" : "return undefined");
11947
+ parts.push(fused ? projection === 0 ? "return v0" : `return ${fn}([v0],new _SP(pos,EC.e))` : wantValues ? "return [v0]" : "return undefined");
11940
11948
  return close();
11941
11949
  }
11942
11950
  parts.push("let cur=EC.e");
@@ -11962,7 +11970,7 @@ return v
11962
11970
  names.push(vn);
11963
11971
  }
11964
11972
  parts.push("EC.e=cur");
11965
- parts.push(fused ? projection >= 0 ? `return ${names[projection]}` : `return ${fn}([${names.join(",")}],{start:pos,end:cur})` : wantValues ? `return [${names.join(",")}]` : "return undefined");
11973
+ parts.push(fused ? projection >= 0 ? `return ${names[projection]}` : `return ${fn}([${names.join(",")}],new _SP(pos,cur))` : wantValues ? `return [${names.join(",")}]` : "return undefined");
11966
11974
  return close();
11967
11975
  }
11968
11976
  case OP_CHOICE: {
@@ -12221,7 +12229,7 @@ ${spec.match.map((m, i) => `${i === 0 ? "" : "else "}if(${dispatchClaim(m)})arm=
12221
12229
  const routedCall = (target) => `{const savedRouted=ctx._routed
12222
12230
  ${emitRollback(m1, L.buf, L.raw, sinks)}
12223
12231
  ${emitMark(m2, L.buf, L.raw, sinks, false)}
12224
- ctx._routed={value:key,span:{start:pos,end:selEnd}}
12232
+ ctx._routed={value:key,span:new _SP(pos,selEnd)}
12225
12233
  try{v=${target}(input,pos,ctx)}finally{ctx._routed=savedRouted}
12226
12234
  break}`;
12227
12235
  const plainCall = (target) => `v=${target}(input,selEnd,ctx);break`;
@@ -12416,8 +12424,8 @@ return out
12416
12424
  const end=${recognize}(input,pos)
12417
12425
  if(end<0){ctx._fe=pos;ctx._fx=${xf};return FAIL}
12418
12426
  const value=${value2}
12419
- const leaf={_tag:'leaf',value,span:{start:pos,end}}
12420
- const kids=[leaf],rawKids=[leaf],span={start:pos,end}
12427
+ const leaf=new _LF(value,new _SP(pos,end))
12428
+ const kids=[leaf],rawKids=[leaf],span=new _SP(pos,end)
12421
12429
  EC.e=end
12422
12430
  const nd=${build2}(kids,undefined,span,rawKids,EMPTY_TL,undefined)
12423
12431
  ${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))"}
@@ -12516,7 +12524,7 @@ ctx._cstTriviaLog=sTl
12516
12524
  ctx.captureTrivia=sCap
12517
12525
  if(v===FAIL)return FAIL
12518
12526
  const end=EC.e
12519
- ${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)`}
12527
+ ${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)`}
12520
12528
  ${publish}
12521
12529
  EC.e=end
12522
12530
  return nd
@@ -12539,20 +12547,20 @@ return nd
12539
12547
  const direct = `${build}(kids,fieldMap,span,rawKids,${captureWide ? "tlog" : "EMPTY_TL"},st)`;
12540
12548
  value = hostCst ? `nd=_pfHost!==undefined?${hostCall}:${direct}` : `nd=${direct}`;
12541
12549
  } else {
12542
- value = `nd=_pfHost!==undefined?_pfHost(${ty},hostKids,fieldMap,span,rawKids,tlog,st,${tags}):{_tag:'node',type:${ty},span,state:st??null,children:kids}`;
12550
+ value = `nd=_pfHost!==undefined?_pfHost(${ty},hostKids,fieldMap,span,rawKids,tlog,st,${tags}):new _ND(${ty},span,st??null,kids===EMPTY_CH?kids:[...kids])`;
12543
12551
  }
12544
12552
  const collapsible = keepChildren && (hostCst || build === void 0 && proj < 0);
12545
- const openCapture = omitsRaw ? `const buf={noRaw:true,rawLen:0}
12553
+ const openCapture = omitsRaw ? `const buf=new _BUF(undefined,true,0)
12546
12554
  ctx._cstBuf=buf
12547
12555
  ctx._cstChildren=undefined
12548
12556
  ctx._cstLeaves=undefined
12549
12557
  ctx._cstRawChildren=undefined
12550
- ctx._cstTriviaLog=undefined` : keepChildren ? `const buf={}
12558
+ ctx._cstTriviaLog=undefined` : keepChildren ? `const buf=new _BUF(undefined,undefined,0)
12551
12559
  ctx._cstBuf=buf
12552
12560
  ctx._cstChildren=undefined
12553
12561
  ctx._cstLeaves=undefined
12554
12562
  ctx._cstRawChildren=undefined
12555
- ctx._cstTriviaLog=undefined` : `const buf={rawOnly:true}
12563
+ ctx._cstTriviaLog=undefined` : `const buf=new _BUF(true,undefined,0)
12556
12564
  ctx._cstBuf=buf
12557
12565
  ctx._cstChildren=undefined
12558
12566
  ctx._cstLeaves=undefined
@@ -12590,7 +12598,7 @@ ctx._cstTriviaLog=sTl
12590
12598
  ctx.captureTrivia=sCap
12591
12599
  if(v===FAIL)return FAIL
12592
12600
  const end=EC.e
12593
- const span=${tracked ? "spanLines(ctx,pos,end)" : "{start:pos,end}"}
12601
+ const span=${tracked ? "spanLines(ctx,pos,end)" : "new _SP(pos,end)"}
12594
12602
  const st=${readsState ? "ctx.state" : "undefined"}
12595
12603
  let nd
12596
12604
  ${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]
@@ -12877,6 +12885,7 @@ function rebuildLineScan(s, subtree) {
12877
12885
  }
12878
12886
 
12879
12887
  // src/combinators/scanTo.ts
12888
+ import { PlainLeaf as PlainLeaf8, PlainSpan as PlainSpan9 } from "./cst/plain.js";
12880
12889
  function resolveScanSkip(explicitSkip, raw, ctx) {
12881
12890
  if (raw) return [];
12882
12891
  const trivia2 = ctx.trivia;
@@ -12914,7 +12923,7 @@ function scanTo(sentinel, { skip, raw = false, orEOF = false, recoverAt, stopAt
12914
12923
  probeCtx._errors = ctx._errors;
12915
12924
  const emit = (end) => {
12916
12925
  if (end > pos && cstCaptureActive(ctx)) {
12917
- const leaf2 = { _tag: "leaf", value: input.slice(pos, end), span: { start: pos, end } };
12926
+ const leaf2 = new PlainLeaf8(input.slice(pos, end), new PlainSpan9(pos, end));
12918
12927
  pushCstLeaf(ctx, leaf2);
12919
12928
  }
12920
12929
  };
@@ -13193,6 +13202,9 @@ function clearOf(ranges, input, from, to) {
13193
13202
  return true;
13194
13203
  }
13195
13204
 
13205
+ // src/table/assemble.ts
13206
+ import { PlainBuf as PlainBuf2, PlainField, PlainLeaf as PlainLeaf9, PlainNode as PlainNode2, PlainSpan as PlainSpan10 } from "./cst/plain.js";
13207
+
13196
13208
  // src/table/fail-clean.ts
13197
13209
  function passChild(code, ip) {
13198
13210
  switch (code[ip]) {
@@ -13520,7 +13532,7 @@ function assemble(t, prog, cfg) {
13520
13532
  const NULLABLE = /* @__PURE__ */ new Map();
13521
13533
  const CLEAN = REC2 ? () => false : failCleanAnalysis(code);
13522
13534
  function pushLeaf(ctx, value, s, e) {
13523
- const lf = { _tag: "leaf", value, span: { start: s, end: e } };
13535
+ const lf = new PlainLeaf9(value, new PlainSpan10(s, e));
13524
13536
  pushCstLeaf(ctx, lf);
13525
13537
  }
13526
13538
  function plainBuildNode(child, build, trailing) {
@@ -13553,7 +13565,7 @@ function assemble(t, prog, cfg) {
13553
13565
  ctx.captureTrivia = sCap;
13554
13566
  if (value === FAIL) return FAIL;
13555
13567
  const end = EC.e;
13556
- const span = { start: pos, end };
13568
+ const span = new PlainSpan10(pos, end);
13557
13569
  const node2 = build(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
13558
13570
  if (sBuf !== void 0 || sCh !== void 0) {
13559
13571
  pushCstChild(ctx, node2, rawEntry(node2, input, pos, end));
@@ -13598,7 +13610,7 @@ function assemble(t, prog, cfg) {
13598
13610
  ctx.captureTrivia = sCap;
13599
13611
  if (value === FAIL) return FAIL;
13600
13612
  const end = EC.e;
13601
- const node2 = build(captured, void 0, { start: pos, end }, EMPTY_CH, EMPTY_TL2, void 0);
13613
+ const node2 = build(captured, void 0, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
13602
13614
  if (sBuf !== void 0 || sCh !== void 0) {
13603
13615
  pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
13604
13616
  }
@@ -13635,7 +13647,7 @@ function assemble(t, prog, cfg) {
13635
13647
  ctx.captureTrivia = sCap;
13636
13648
  if (value === FAIL) return FAIL;
13637
13649
  const end = EC.e;
13638
- const node2 = build(captured, fieldMap, { start: pos, end }, EMPTY_CH, EMPTY_TL2, void 0);
13650
+ const node2 = build(captured, fieldMap, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
13639
13651
  if (sBuf !== void 0 || sCh !== void 0) {
13640
13652
  pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
13641
13653
  }
@@ -13672,7 +13684,7 @@ function assemble(t, prog, cfg) {
13672
13684
  ctx.captureTrivia = sCap;
13673
13685
  if (value === FAIL) return FAIL;
13674
13686
  const end = EC.e;
13675
- const span = { start: pos, end };
13687
+ const span = new PlainSpan10(pos, end);
13676
13688
  const node2 = kids.length === 1 ? kids[0] : build(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
13677
13689
  if (sBuf !== void 0 || sCh !== void 0) {
13678
13690
  pushCstChild(ctx, node2, rawEntry(node2, input, pos, end));
@@ -13709,7 +13721,7 @@ function assemble(t, prog, cfg) {
13709
13721
  ctx.captureTrivia = sCap;
13710
13722
  if (value === FAIL) return FAIL;
13711
13723
  const end = EC.e;
13712
- const node2 = captured.length === 1 ? captured[0] : build(captured, void 0, { start: pos, end }, EMPTY_CH, EMPTY_TL2, void 0);
13724
+ const node2 = captured.length === 1 ? captured[0] : build(captured, void 0, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
13713
13725
  if (sBuf !== void 0 || sCh !== void 0) {
13714
13726
  pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
13715
13727
  }
@@ -14142,7 +14154,7 @@ function assemble(t, prog, cfg) {
14142
14154
  return (input, pos, selEnd, key, ctx, need, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot) => {
14143
14155
  const savedRouted = ctx._routed;
14144
14156
  if (need) rollbackTriviaAt(ctx, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot);
14145
- ctx._routed = { value: key, span: { start: pos, end: selEnd } };
14157
+ ctx._routed = { value: key, span: new PlainSpan10(pos, selEnd) };
14146
14158
  let v;
14147
14159
  try {
14148
14160
  v = child(input, pos, ctx);
@@ -14575,7 +14587,7 @@ function assemble(t, prog, cfg) {
14575
14587
  case OP_EXPECT: {
14576
14588
  const child = link(code[ip + 1]);
14577
14589
  const xf = fx[code[ip + 2]];
14578
- const expectSpan = (ctx, pos) => prog.lines === 1 ? spanLines(ctx, pos, pos) : { start: pos, end: pos };
14590
+ const expectSpan = (ctx, pos) => prog.lines === 1 ? spanLines(ctx, pos, pos) : new PlainSpan10(pos, pos);
14579
14591
  if (REC2) {
14580
14592
  return (input, pos, ctx) => {
14581
14593
  const v = child(input, pos, ctx);
@@ -14607,7 +14619,7 @@ function assemble(t, prog, cfg) {
14607
14619
  return (input, pos, ctx) => {
14608
14620
  const v = child(input, pos, ctx);
14609
14621
  if (v === FAIL) return FAIL;
14610
- ctx._fields?.push({ name, value: v, span: { start: pos, end: EC.e } });
14622
+ ctx._fields?.push(new PlainField(name, v, new PlainSpan10(pos, EC.e)));
14611
14623
  return v;
14612
14624
  };
14613
14625
  }
@@ -14631,7 +14643,7 @@ function assemble(t, prog, cfg) {
14631
14643
  return (input, pos, ctx) => {
14632
14644
  const v = child(input, pos, ctx);
14633
14645
  if (v === FAIL) return FAIL;
14634
- return fn(v, { start: pos, end: EC.e });
14646
+ return fn(v, new PlainSpan10(pos, EC.e));
14635
14647
  };
14636
14648
  }
14637
14649
  case OP_SCAN: {
@@ -14735,7 +14747,7 @@ function assemble(t, prog, cfg) {
14735
14747
  ctx._fx = ROUTED_FX;
14736
14748
  return FAIL;
14737
14749
  }
14738
- if (cstCaptureActive(ctx)) pushCstLeaf(ctx, { _tag: "leaf", value: item.value, span: item.span });
14750
+ if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(item.value, item.span));
14739
14751
  EC.e = item.span.end;
14740
14752
  return item.value;
14741
14753
  };
@@ -14921,7 +14933,7 @@ function assemble(t, prog, cfg) {
14921
14933
  if (v === FAIL) return FAIL;
14922
14934
  const end = EC.e;
14923
14935
  const value = input.slice(pos, end);
14924
- if (wasCapturing) pushCstLeaf(ctx, { _tag: "leaf", value, span: { start: pos, end } });
14936
+ if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
14925
14937
  EC.e = end;
14926
14938
  return value;
14927
14939
  };
@@ -14955,7 +14967,7 @@ function assemble(t, prog, cfg) {
14955
14967
  if (ctx._probe !== void 0) failAt(ctx, suffixExpected, end);
14956
14968
  }
14957
14969
  const value = input.slice(pos, end);
14958
- if (cstCaptureActive(ctx)) pushCstLeaf(ctx, { _tag: "leaf", value, span: { start: pos, end } });
14970
+ if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
14959
14971
  EC.e = end;
14960
14972
  return value;
14961
14973
  };
@@ -14998,7 +15010,7 @@ function assemble(t, prog, cfg) {
14998
15010
  }
14999
15011
  if (end < 0) return FAIL;
15000
15012
  const value = input.slice(pos, end);
15001
- if (wasCapturing) pushCstLeaf(ctx, { _tag: "leaf", value, span: { start: pos, end } });
15013
+ if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
15002
15014
  EC.e = end;
15003
15015
  return value;
15004
15016
  };
@@ -15007,7 +15019,7 @@ function assemble(t, prog, cfg) {
15007
15019
  const end = run3(input, pos, ctx);
15008
15020
  if (end < 0) return FAIL;
15009
15021
  const value = input.slice(pos, end);
15010
- if (cstCaptureActive(ctx)) pushCstLeaf(ctx, { _tag: "leaf", value, span: { start: pos, end } });
15022
+ if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
15011
15023
  EC.e = end;
15012
15024
  return value;
15013
15025
  };
@@ -15040,12 +15052,8 @@ function assemble(t, prog, cfg) {
15040
15052
  }
15041
15053
  if (v === FAIL) return FAIL;
15042
15054
  const end = EC.e;
15043
- const out = fn(v, { start: pos, end });
15044
- if (wasCapturing) pushCstLeaf(ctx, {
15045
- _tag: "leaf",
15046
- value: op === OP_SOURCE_LEAF && hostCst ? input.slice(pos, end) : out,
15047
- span: { start: pos, end }
15048
- });
15055
+ const out = fn(v, new PlainSpan10(pos, end));
15056
+ if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(op === OP_SOURCE_LEAF && hostCst ? input.slice(pos, end) : out, new PlainSpan10(pos, end)));
15049
15057
  EC.e = end;
15050
15058
  return out;
15051
15059
  };
@@ -15180,7 +15188,7 @@ function assemble(t, prog, cfg) {
15180
15188
  const cur = runSyncTerms(input, pos, ctx, values);
15181
15189
  if (cur < 0) return FAIL;
15182
15190
  EC.e = cur;
15183
- return projection >= 0 ? values[projection] : fn(values, { start: pos, end: cur });
15191
+ return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
15184
15192
  };
15185
15193
  }
15186
15194
  if (wantValues) {
@@ -15274,7 +15282,7 @@ function assemble(t, prog, cfg) {
15274
15282
  const cur = runAdjTerms(input, pos, ctx, values);
15275
15283
  if (cur < 0) return FAIL;
15276
15284
  EC.e = cur;
15277
- return projection >= 0 ? values[projection] : fn(values, { start: pos, end: cur });
15285
+ return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
15278
15286
  };
15279
15287
  }
15280
15288
  if (wantValues) {
@@ -15299,7 +15307,7 @@ function assemble(t, prog, cfg) {
15299
15307
  return (input, pos, ctx) => {
15300
15308
  const v = k0(input, pos, ctx);
15301
15309
  if (v === FAIL) return FAIL;
15302
- return projection === 0 ? v : fn([v], { start: pos, end: EC.e });
15310
+ return projection === 0 ? v : fn([v], new PlainSpan10(pos, EC.e));
15303
15311
  };
15304
15312
  }
15305
15313
  if (wantValues) {
@@ -15324,7 +15332,7 @@ function assemble(t, prog, cfg) {
15324
15332
  const cur = step(k1, input, EC.e, ctx);
15325
15333
  if (cur < 0) return FAIL;
15326
15334
  EC.e = cur;
15327
- return projection === 0 ? v0 : projection === 1 ? TERMV : fn([v0, TERMV], { start: pos, end: cur });
15335
+ return projection === 0 ? v0 : projection === 1 ? TERMV : fn([v0, TERMV], new PlainSpan10(pos, cur));
15328
15336
  };
15329
15337
  }
15330
15338
  if (wantValues) {
@@ -15358,7 +15366,7 @@ function assemble(t, prog, cfg) {
15358
15366
  cur = step(k2, input, cur, ctx);
15359
15367
  if (cur < 0) return FAIL;
15360
15368
  EC.e = cur;
15361
- return projection === 0 ? v0 : projection === 1 ? v1 : projection === 2 ? TERMV : fn([v0, v1, TERMV], { start: pos, end: cur });
15369
+ return projection === 0 ? v0 : projection === 1 ? v1 : projection === 2 ? TERMV : fn([v0, v1, TERMV], new PlainSpan10(pos, cur));
15362
15370
  };
15363
15371
  }
15364
15372
  if (wantValues) {
@@ -15455,7 +15463,7 @@ function assemble(t, prog, cfg) {
15455
15463
  const cur = runDirectTerms(input, pos, ctx, values);
15456
15464
  if (cur < 0) return FAIL;
15457
15465
  EC.e = cur;
15458
- return projection >= 0 ? values[projection] : fn(values, { start: pos, end: cur });
15466
+ return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
15459
15467
  };
15460
15468
  }
15461
15469
  if (wantValues) {
@@ -16353,10 +16361,10 @@ function assemble(t, prog, cfg) {
16353
16361
  return FAIL;
16354
16362
  }
16355
16363
  const value = regexValue ? input.slice(pos, end) : spec;
16356
- const leaf2 = { _tag: "leaf", value, span: { start: pos, end } };
16364
+ const leaf2 = new PlainLeaf9(value, new PlainSpan10(pos, end));
16357
16365
  const kids = [leaf2];
16358
16366
  const rawKids = [leaf2];
16359
- const span = { start: pos, end };
16367
+ const span = new PlainSpan10(pos, end);
16360
16368
  EC.e = end;
16361
16369
  const nd = build2(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
16362
16370
  if (ctx._cstBuf !== void 0 || ctx._cstChildren !== void 0) {
@@ -16438,7 +16446,7 @@ function assemble(t, prog, cfg) {
16438
16446
  const sCh = ctx._cstChildren;
16439
16447
  const sCap = ctx.captureTrivia;
16440
16448
  const sBuf = ctx._cstBuf;
16441
- const buf = rawOnly ? { rawOnly: true } : omitsRaw ? { noRaw: true, rawLen: 0 } : {};
16449
+ const buf = rawOnly ? new PlainBuf2(true, void 0, 0) : omitsRaw ? new PlainBuf2(void 0, true, 0) : new PlainBuf2(void 0, void 0, 0);
16442
16450
  ctx._cstBuf = buf;
16443
16451
  ctx.captureTrivia = captureWide;
16444
16452
  const savedFields = ctx._fields;
@@ -16460,7 +16468,7 @@ function assemble(t, prog, cfg) {
16460
16468
  ctx.captureTrivia = sCap;
16461
16469
  if (v === FAIL) return FAIL;
16462
16470
  const end = EC.e;
16463
- const span = tracked ? spanLines(ctx, pos, end) : { start: pos, end };
16471
+ const span = tracked ? spanLines(ctx, pos, end) : new PlainSpan10(pos, end);
16464
16472
  const st = readsState ? ctx.state : void 0;
16465
16473
  let nd;
16466
16474
  if (unwrap && kids.length === 1) {
@@ -16484,7 +16492,7 @@ function assemble(t, prog, cfg) {
16484
16492
  } else if (host !== void 0) {
16485
16493
  nd = host(type, hostKids, fieldMap, span, rawKids, tlog, st, tags);
16486
16494
  } else {
16487
- nd = { _tag: "node", type, span, state: st ?? null, children: kids };
16495
+ nd = new PlainNode2(type, span, st ?? null, kids === EMPTY_CH ? kids : [...kids]);
16488
16496
  }
16489
16497
  if (sBuf !== void 0 || sCh !== void 0) {
16490
16498
  pushCstChild(ctx, nd, rawEntry(nd, input, pos, end));
@@ -16510,7 +16518,7 @@ function assemble(t, prog, cfg) {
16510
16518
  const at = fe === void 0 || fe < 0 ? pos : fe;
16511
16519
  return { ok: false, expected: ctx._fx ?? EMPTY_FX2, span: { start: at, end: at } };
16512
16520
  }
16513
- return { ok: true, value: v, span: { start: pos, end: EC.e } };
16521
+ return { ok: true, value: v, span: new PlainSpan10(pos, EC.e) };
16514
16522
  }
16515
16523
  };
16516
16524
  }
@@ -16625,7 +16633,12 @@ function assemble(t, prog, cfg) {
16625
16633
  LEAD,
16626
16634
  triviaFieldCapture,
16627
16635
  skipDeferredTrivia,
16628
- collapseEmpty
16636
+ collapseEmpty,
16637
+ PlainSpan10,
16638
+ PlainLeaf9,
16639
+ PlainNode2,
16640
+ PlainField,
16641
+ PlainBuf2
16629
16642
  );
16630
16643
  emitReached = new Set(pre.reached);
16631
16644
  if (emitted.ext !== void 0) HYBRID = emitted;
@@ -16712,7 +16725,12 @@ function assemble(t, prog, cfg) {
16712
16725
  LEAD,
16713
16726
  triviaFieldCapture,
16714
16727
  skipDeferredTrivia,
16715
- collapseEmpty
16728
+ collapseEmpty,
16729
+ PlainSpan10,
16730
+ PlainLeaf9,
16731
+ PlainNode2,
16732
+ PlainField,
16733
+ PlainBuf2
16716
16734
  );
16717
16735
  emitReached = em.reached;
16718
16736
  } catch (e) {
@@ -16970,7 +16988,11 @@ function tableRules(source, metadataOrEntry = {}) {
16970
16988
  return map[entry];
16971
16989
  }
16972
16990
 
16991
+ // src/version.ts
16992
+ var PARSEMAN_VERSION = "0.59.1";
16993
+
16973
16994
  // src/table/emit.ts
16995
+ 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`)});`;
16974
16996
  function jsString(s) {
16975
16997
  return JSON.stringify(s);
16976
16998
  }
@@ -17056,7 +17078,7 @@ function emitAssemblies(prog, cfgs) {
17056
17078
  throw e;
17057
17079
  }
17058
17080
  const plan = em.plan;
17059
- out.push(`{key:${key},factory:function(${EMITTED_PARAMS.join(",")}){${em.source}
17081
+ out.push(`{key:${key},factory:function(${EMITTED_PARAMS.join(",")}){${FACTORY_ARITY_GUARD}${em.source}
17060
17082
  },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(",")}]}`);
17061
17083
  }
17062
17084
  return [`a:[${out.join(",")}],`];
@@ -19068,7 +19090,7 @@ function serializeRuleMap(ruleMap, scanSkip) {
19068
19090
  return new Serializer(ruleMap, scanSkip ?? []).run();
19069
19091
  } catch (e) {
19070
19092
  if (e instanceof Unserializable) {
19071
- if (process.env.PARSEMAN_IR_DEBUG) console.error(`[ir] fallback: ${e.message}`);
19093
+ if (typeof process !== "undefined" && process.env?.PARSEMAN_IR_DEBUG) console.error(`[ir] fallback: ${e.message}`);
19072
19094
  return null;
19073
19095
  }
19074
19096
  throw e;
@@ -19413,9 +19435,6 @@ function fieldOptionsSrc(def) {
19413
19435
  return `, { ${[def.leadingTrivia === true ? "leadingTrivia: true" : "", def.trailingTrivia === true ? "trailingTrivia: true" : ""].filter(Boolean).join(", ")} }`;
19414
19436
  }
19415
19437
 
19416
- // src/version.ts
19417
- var PARSEMAN_VERSION = "0.58.3";
19418
-
19419
19438
  // src/compiler/compile-linkable-table.ts
19420
19439
  function isLocal(rule) {
19421
19440
  const d = rule._def;
@@ -19482,6 +19501,7 @@ function compileLinkableTable(ruleMapArg, ns, opts = {}) {
19482
19501
  }
19483
19502
 
19484
19503
  // src/compiler/linker.ts
19504
+ import { PlainNode as PlainNode3, PlainTaggedNode } from "./cst/plain.js";
19485
19505
  function normalizeCstCollapse(collapse) {
19486
19506
  if (collapse === true) return () => true;
19487
19507
  if (Array.isArray(collapse)) {
@@ -19491,7 +19511,7 @@ function normalizeCstCollapse(collapse) {
19491
19511
  return typeof collapse === "function" ? collapse : void 0;
19492
19512
  }
19493
19513
  function buildCstNode(type, children2, _fields, span, _rawChildren, _triviaLog, state, tags) {
19494
- return tags !== void 0 && tags.length > 0 ? { _tag: "node", type, tags, span: { ...span }, state: state ?? null, children: [...children2] } : { _tag: "node", type, span: { ...span }, state: state ?? null, children: [...children2] };
19514
+ return tags !== void 0 && tags.length > 0 ? new PlainTaggedNode(type, tags, copySpan(span), state ?? null, [...children2]) : new PlainNode3(type, copySpan(span), state ?? null, [...children2]);
19495
19515
  }
19496
19516
  function cstBuildHost(typeOrOptions, children2, _fields, span, rawChildren, triviaLog, state, _tags) {
19497
19517
  if (typeof typeOrOptions === "string") {