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.
- package/dist/analysis/diagnostics.js +159 -137
- package/dist/analysis/diagnostics.js.map +3 -3
- package/dist/cli/index.js +161 -138
- package/dist/cli/index.js.map +3 -3
- package/dist/combinators/choice.d.ts +0 -5
- package/dist/combinators/choice.d.ts.map +1 -1
- package/dist/combinators/dispatch.d.ts.map +1 -1
- package/dist/combinators/field-trivia.d.ts.map +1 -1
- package/dist/combinators/keywords.d.ts.map +1 -1
- package/dist/combinators/literal.d.ts.map +1 -1
- package/dist/combinators/node.d.ts.map +1 -1
- package/dist/combinators/regex.d.ts.map +1 -1
- package/dist/combinators/scanTo.d.ts +1 -16
- package/dist/combinators/scanTo.d.ts.map +1 -1
- package/dist/combinators/token.d.ts.map +1 -1
- package/dist/compiler/ir-serialize.d.ts.map +1 -1
- package/dist/compiler/linker.d.ts +0 -3
- package/dist/compiler/linker.d.ts.map +1 -1
- package/dist/compiler/token-alphabet.d.ts +5 -25
- package/dist/compiler/token-alphabet.d.ts.map +1 -1
- package/dist/compiler/token-capability.js.map +1 -1
- package/dist/compiler/token-dispatch.d.ts +8 -79
- package/dist/compiler/token-dispatch.d.ts.map +1 -1
- package/dist/cst/capture-buffer.d.ts.map +1 -1
- package/dist/cst/plain.js +69 -0
- package/dist/cst/plain.js.map +6 -0
- package/dist/cst/root-trivia-scope.d.ts +0 -3
- package/dist/cst/root-trivia-scope.d.ts.map +1 -1
- package/dist/cst/trivia-entries.d.ts +0 -2
- package/dist/cst/trivia-entries.d.ts.map +1 -1
- package/dist/cst/trivia-kinds.d.ts +0 -5
- package/dist/cst/trivia-kinds.d.ts.map +1 -1
- package/dist/index.js +163 -143
- package/dist/index.js.map +3 -3
- package/dist/language-service/index.js +19 -2
- package/dist/language-service/index.js.map +2 -2
- package/dist/line-index.d.ts +13 -0
- package/dist/line-index.d.ts.map +1 -1
- package/dist/plugin/entry-supercompiler.d.ts.map +1 -1
- package/dist/plugin/index.js +165 -145
- package/dist/plugin/index.js.map +3 -3
- package/dist/recovery/scan.d.ts.map +1 -1
- package/dist/run/index.js +4 -1
- package/dist/run/index.js.map +2 -2
- package/dist/spec/index.js +18 -1
- package/dist/spec/index.js.map +2 -2
- package/dist/spec/model.d.ts +0 -8
- package/dist/spec/model.d.ts.map +1 -1
- package/dist/table/assemble.d.ts.map +1 -1
- package/dist/table/emit-assembly.d.ts +1 -1
- package/dist/table/emit-assembly.d.ts.map +1 -1
- package/dist/table/emit.d.ts +6 -0
- package/dist/table/emit.d.ts.map +1 -1
- package/dist/table/encode.d.ts.map +1 -1
- package/dist/table/index.js +142 -133
- package/dist/table/index.js.map +3 -3
- package/dist/table/program.d.ts +0 -1
- package/dist/table/program.d.ts.map +1 -1
- package/dist/table/run-support.d.ts.map +1 -1
- package/dist/table/scalar-terminal.d.ts +0 -7
- package/dist/table/scalar-terminal.d.ts.map +1 -1
- package/dist/table/scan-shapes.d.ts +0 -8
- package/dist/table/scan-shapes.d.ts.map +1 -1
- package/dist/table/site-labels.d.ts +0 -2
- package/dist/table/site-labels.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -1
- package/src/combinators/choice.ts +1 -1
- package/src/combinators/dispatch.ts +2 -1
- package/src/combinators/field-trivia.ts +6 -5
- package/src/combinators/keywords.ts +3 -2
- package/src/combinators/literal.ts +5 -4
- package/src/combinators/node.ts +3 -1
- package/src/combinators/regex.ts +5 -4
- package/src/combinators/scanTo.ts +3 -2
- package/src/combinators/token.ts +3 -6
- package/src/compiler/ir-serialize.ts +2 -1
- package/src/compiler/linker.ts +5 -3
- package/src/compiler/token-alphabet.ts +14 -10
- package/src/compiler/token-dispatch.ts +10 -313
- package/src/compiler/token-scanner.ts +2 -2
- package/src/cst/capture-buffer.ts +13 -5
- package/src/cst/plain.d.ts +35 -0
- package/src/cst/plain.js +74 -0
- package/src/cst/root-trivia-scope.ts +1 -1
- package/src/cst/trivia-entries.ts +1 -1
- package/src/cst/trivia-kinds.ts +1 -1
- package/src/line-index.ts +37 -0
- package/src/plugin/entry-supercompiler.ts +3 -2
- package/src/recovery/scan.ts +2 -1
- package/src/spec/model.ts +1 -1
- package/src/table/assemble.ts +33 -35
- package/src/table/emit-assembly.ts +27 -24
- package/src/table/emit.ts +9 -1
- package/src/table/encode.ts +16 -39
- package/src/table/program.ts +1 -1
- package/src/table/run-support.ts +4 -7
- package/src/table/scalar-terminal.ts +1 -1
- package/src/table/scan-shapes.ts +15 -46
- package/src/table/site-labels.ts +1 -1
- 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 =
|
|
728
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
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 =
|
|
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
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
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 =
|
|
3974
|
+
const span2 = new PlainSpan5(pos, scanEnd);
|
|
3945
3975
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, scanEnd);
|
|
3946
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
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 =
|
|
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,
|
|
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
|
|
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,
|
|
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,
|
|
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) :
|
|
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);
|
|
@@ -7426,18 +7452,10 @@ var Encoder = class {
|
|
|
7426
7452
|
/** TOKEN bodies are an all-program decision. A complete occurrence inside an
|
|
7427
7453
|
* otherwise incomplete final graph stays on CHARACTER with every sibling. */
|
|
7428
7454
|
selectLexicalBodies;
|
|
7429
|
-
/**
|
|
7430
|
-
* Decides the extra operands laid down below. ALWAYS TRUE — see
|
|
7431
|
-
* `TableSettings.recovery`. Kept as a field rather than folded away because it
|
|
7432
|
-
* is what every emit site reads, and the emit sites are where the shape of the
|
|
7433
|
-
* row is stated.
|
|
7434
|
-
*/
|
|
7435
|
-
rec;
|
|
7436
7455
|
constructor(settings, selectLexicalBodies) {
|
|
7437
7456
|
this.settings = settings;
|
|
7438
7457
|
this.track = settings.trackLines === true;
|
|
7439
7458
|
this.selectLexicalBodies = selectLexicalBodies;
|
|
7440
|
-
this.rec = true;
|
|
7441
7459
|
this.plan = settings.coverage;
|
|
7442
7460
|
this.cov = settings.coverage === void 0 ? void 0 : settings.coverage.definitions.map((d) => [d.id, covKindCode(d.kind)]);
|
|
7443
7461
|
this.covIndex = new Map((this.cov ?? []).map((d, i) => [d[0], i]));
|
|
@@ -7939,12 +7957,10 @@ var Encoder = class {
|
|
|
7939
7957
|
}
|
|
7940
7958
|
case "sequence": {
|
|
7941
7959
|
const kids = d.parsers.map((c) => this.node(c).ip);
|
|
7942
|
-
const head = this.emitHead(d.valueUnused ? OP_SEQV : OP_SEQ, 1 +
|
|
7960
|
+
const head = this.emitHead(d.valueUnused ? OP_SEQV : OP_SEQ, 1 + 2 * kids.length);
|
|
7943
7961
|
this.code[head + 1] = kids.length;
|
|
7944
7962
|
for (let i = 0; i < kids.length; i++) this.code[head + 2 + i] = kids[i];
|
|
7945
|
-
|
|
7946
|
-
for (let i = 0; i < kids.length; i++) this.code[head + 2 + kids.length + i] = this.followClass(d.parsers, i);
|
|
7947
|
-
}
|
|
7963
|
+
for (let i = 0; i < kids.length; i++) this.code[head + 2 + kids.length + i] = this.followClass(d.parsers, i);
|
|
7948
7964
|
return head;
|
|
7949
7965
|
}
|
|
7950
7966
|
case "choice": {
|
|
@@ -8046,25 +8062,22 @@ var Encoder = class {
|
|
|
8046
8062
|
const itemClass = matchesEmpty(d.parser, /* @__PURE__ */ new Set(), rr) ? -1 : this.charClass(firstSetOf(d.parser, /* @__PURE__ */ new Set(), rr, this.activeTrivia));
|
|
8047
8063
|
const op = d.valueUnused ? OP_REPV : OP_REP;
|
|
8048
8064
|
const min = d.tag === "many" ? 0 : d.min;
|
|
8049
|
-
return this.
|
|
8065
|
+
return this.emit(op, child, min, d.max ?? -1, -1, 0, this.expected(deriveExpected(d.parser)), itemClass);
|
|
8050
8066
|
}
|
|
8051
8067
|
case "sepBy": {
|
|
8052
8068
|
const child = this.node(d.parser).ip;
|
|
8053
8069
|
const sep = this.node(d.separator).ip;
|
|
8054
8070
|
const flags = (d.trailing === "allow" ? 1 : 0) | (d.keepSeparators === true ? 2 : 0) | (d.min >= 2 ? 4 : 0);
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
);
|
|
8066
|
-
}
|
|
8067
|
-
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);
|
|
8071
|
+
return this.emit(
|
|
8072
|
+
OP_REP,
|
|
8073
|
+
child,
|
|
8074
|
+
d.min,
|
|
8075
|
+
d.max ?? -1,
|
|
8076
|
+
sep,
|
|
8077
|
+
flags,
|
|
8078
|
+
this.expected(deriveExpected(d.parser)),
|
|
8079
|
+
this.charClass(firstSetOf(d.separator, /* @__PURE__ */ new Set(), this.refResolver(), this.activeTrivia))
|
|
8080
|
+
);
|
|
8068
8081
|
}
|
|
8069
8082
|
case "optional": {
|
|
8070
8083
|
const head = this.emit(OP_OPT, this.lookaheadGate(d.parser, this.node(d.parser).ip));
|
|
@@ -8075,14 +8088,12 @@ var Encoder = class {
|
|
|
8075
8088
|
const inner = d.parser._def;
|
|
8076
8089
|
if (inner.tag === "sequence" && !this.memo.has(d.parser) && !this.pending.has(d.parser)) {
|
|
8077
8090
|
const kids = inner.parsers.map((c) => this.node(c).ip);
|
|
8078
|
-
const head = this.emitHead(OP_SEQX, 2 +
|
|
8091
|
+
const head = this.emitHead(OP_SEQX, 2 + 2 * kids.length);
|
|
8079
8092
|
const projection = directArrayProjection(d.fn, d.fnSrc, kids.length);
|
|
8080
8093
|
this.code[head + 1] = projection === null ? this.fn(d.fn, d.fnSrc ?? null) : ~projection;
|
|
8081
8094
|
this.code[head + 2] = kids.length;
|
|
8082
8095
|
for (let i = 0; i < kids.length; i++) this.code[head + 3 + i] = kids[i];
|
|
8083
|
-
|
|
8084
|
-
for (let i = 0; i < kids.length; i++) this.code[head + 3 + kids.length + i] = this.followClass(inner.parsers, i);
|
|
8085
|
-
}
|
|
8096
|
+
for (let i = 0; i < kids.length; i++) this.code[head + 3 + kids.length + i] = this.followClass(inner.parsers, i);
|
|
8086
8097
|
return head;
|
|
8087
8098
|
}
|
|
8088
8099
|
const child = this.node(d.parser).ip;
|
|
@@ -8405,7 +8416,7 @@ var Encoder = class {
|
|
|
8405
8416
|
...this.settings.hostMode === void 0 ? {} : { hostMode: this.settings.hostMode },
|
|
8406
8417
|
...this.runtimeOnly.size === 0 ? {} : { runtimeOnly: [...this.runtimeOnly].sort() },
|
|
8407
8418
|
...this.triviaSpecs.length === 0 ? {} : { triviaSpecs: this.triviaSpecs },
|
|
8408
|
-
|
|
8419
|
+
rec: 1,
|
|
8409
8420
|
...this.cov === void 0 ? {} : { cov: this.cov },
|
|
8410
8421
|
lines: this.track ? 1 : 0
|
|
8411
8422
|
}, void 0, {
|
|
@@ -9169,7 +9180,6 @@ function caseFoldLiteralOrAlt(source) {
|
|
|
9169
9180
|
}
|
|
9170
9181
|
return { kind: "alt", arms: litArms, disjoint: false, firsts: litArms.map(() => null) };
|
|
9171
9182
|
}
|
|
9172
|
-
var scanToIndexOfEnabled = () => process.env.PARSEMAN_SCANTO === "indexof";
|
|
9173
9183
|
var classCond = (cVar, ranges) => ranges.map(([lo, hi]) => lo === hi ? `${cVar} === ${lo}` : `(${cVar} >= ${lo} && ${cVar} <= ${hi})`).join(" || ");
|
|
9174
9184
|
var litCond = (base, cps, firstVar) => cps.map(
|
|
9175
9185
|
(cp, k) => k === 0 && firstVar ? `${firstVar} === ${cp}` : `input.charCodeAt(${base}${k ? ` + ${k}` : ""}) === ${cp}`
|
|
@@ -9399,13 +9409,7 @@ function emitShapeMatch(shape, start, mint, ind, firstChar) {
|
|
|
9399
9409
|
const j2 = mint("_j");
|
|
9400
9410
|
const openLen2 = shape.open.length;
|
|
9401
9411
|
const openChk2 = openLen2 === 1 ? `${codeAt(start, firstChar)} === ${shape.open[0]}` : litCond(start, shape.open, firstChar);
|
|
9402
|
-
const
|
|
9403
|
-
const scanLine = stopCp !== null && stopCp <= 65535 && scanToIndexOfEnabled() ? (
|
|
9404
|
-
// No temp is minted: a temp would renumber every later variable in the
|
|
9405
|
-
// function and show up as an artifact-size delta that is counter
|
|
9406
|
-
// renumbering rather than this change (the §9.1.4 / §9.2 effect).
|
|
9407
|
-
`${ind} ${j2} = input.indexOf(${JSON.stringify(String.fromCharCode(stopCp))}, ${j2}); if (${j2} < 0) ${j2} = input.length`
|
|
9408
|
-
) : `${ind} while (${j2} < input.length && !(${classCond(`input.charCodeAt(${j2})`, shape.stop)})) ${j2}++`;
|
|
9412
|
+
const scanLine = `${ind} while (${j2} < input.length && !(${classCond(`input.charCodeAt(${j2})`, shape.stop)})) ${j2}++`;
|
|
9409
9413
|
return {
|
|
9410
9414
|
setup: [
|
|
9411
9415
|
`${ind}let ${j2} = ${start}`,
|
|
@@ -9463,11 +9467,7 @@ function emitShapeMatch(shape, start, mint, ind, firstChar) {
|
|
|
9463
9467
|
const closeLen = shape.close.length;
|
|
9464
9468
|
const openChk = openLen === 1 ? `${codeAt(start, firstChar)} === ${shape.open[0]}` : litCond(start, shape.open, firstChar);
|
|
9465
9469
|
const closeChk = litCond(j, shape.close);
|
|
9466
|
-
const
|
|
9467
|
-
const scanLines = scanToIndexOfEnabled() ? [
|
|
9468
|
-
`${ind} ${j} = input.indexOf(${JSON.stringify(closeStr)}, ${j}); if (${j} < 0) ${j} = input.length`,
|
|
9469
|
-
`${ind} if (${j} + ${closeLen} <= input.length) ${endV} = ${j} + ${closeLen}`
|
|
9470
|
-
] : [
|
|
9470
|
+
const scanLines = [
|
|
9471
9471
|
`${ind} while (${j} + ${closeLen - 1} < input.length && !(${closeChk})) ${j}++`,
|
|
9472
9472
|
`${ind} if (${j} + ${closeLen} <= input.length && (${closeChk})) ${endV} = ${j} + ${closeLen}`
|
|
9473
9473
|
];
|
|
@@ -10103,7 +10103,14 @@ var EMITTED_PARAMS = [
|
|
|
10103
10103
|
"skipDeferredTrivia",
|
|
10104
10104
|
// Appended for the pass-through collapse (`run-support.ts`); old factories
|
|
10105
10105
|
// ignore it.
|
|
10106
|
-
"collapseEmpty"
|
|
10106
|
+
"collapseEmpty",
|
|
10107
|
+
// Appended for constructor-built tree objects (`cst/plain.d.ts`): a `new` call has
|
|
10108
|
+
// no allocation site, so V8 cannot pretenure them. Old factories ignore them.
|
|
10109
|
+
"_SP",
|
|
10110
|
+
"_LF",
|
|
10111
|
+
"_ND",
|
|
10112
|
+
"_FC",
|
|
10113
|
+
"_BUF"
|
|
10107
10114
|
];
|
|
10108
10115
|
var RUNTIME_PRELUDE = `
|
|
10109
10116
|
let _pfScan=null
|
|
@@ -10127,9 +10134,9 @@ if(s!==null)return skipTriviaScanned(s,input,cur,ctx)
|
|
|
10127
10134
|
if(needsDeferredTriviaCommit(ctx))return skipDeferredTrivia(input,cur,ctx)
|
|
10128
10135
|
return advanceTrivia(input,cur,ctx)
|
|
10129
10136
|
}
|
|
10130
|
-
function _pushLeaf(ctx,value,s,e){pushCstLeaf(ctx,
|
|
10137
|
+
function _pushLeaf(ctx,value,s,e){pushCstLeaf(ctx,new _LF(value,new _SP(s,e)))}
|
|
10131
10138
|
function _pushLeafBuf(ctx,value,s,e){
|
|
10132
|
-
const l=
|
|
10139
|
+
const l=new _LF(value,new _SP(s,e))
|
|
10133
10140
|
const b=ctx._cstBuf
|
|
10134
10141
|
if(b.ch!==undefined)b.ch.push(l)
|
|
10135
10142
|
else if(b.single!==undefined){b.ch=[b.single,l];b.single=undefined}
|
|
@@ -10187,7 +10194,7 @@ if(ctx._rootTriviaLog!==undefined&&ctx._rootTriviaLog.length!==rt)ctx._rootTrivi
|
|
|
10187
10194
|
`;
|
|
10188
10195
|
var NO_RAW_RUNTIME_PRELUDE = `
|
|
10189
10196
|
function _pushLeafNoRawBuf(ctx,value,s,e){
|
|
10190
|
-
const l=
|
|
10197
|
+
const l=new _LF(value,new _SP(s,e))
|
|
10191
10198
|
const b=ctx._cstBuf
|
|
10192
10199
|
if(b.ch!==undefined)b.ch.push(l)
|
|
10193
10200
|
else if(b.single!==undefined){b.ch=[b.single,l];b.single=undefined}
|
|
@@ -10864,7 +10871,7 @@ try{return ${child}(input,pos,ctx)}finally{ctx.state=saved}
|
|
|
10864
10871
|
return `${head}
|
|
10865
10872
|
const v=${child}(input,pos,ctx)
|
|
10866
10873
|
if(v===FAIL)return FAIL
|
|
10867
|
-
return ${fn}(v,
|
|
10874
|
+
return ${fn}(v,new _SP(pos,EC.e))
|
|
10868
10875
|
}`;
|
|
10869
10876
|
}
|
|
10870
10877
|
case OP_LABEL: {
|
|
@@ -10885,7 +10892,7 @@ return v
|
|
|
10885
10892
|
const v=${child}(input,pos,ctx)
|
|
10886
10893
|
if(v===FAIL)return FAIL
|
|
10887
10894
|
const f=ctx._fields
|
|
10888
|
-
if(f!==undefined)f.push({name
|
|
10895
|
+
if(f!==undefined)f.push(new _FC(${name},v,new _SP(pos,EC.e)))
|
|
10889
10896
|
return v
|
|
10890
10897
|
}`;
|
|
10891
10898
|
}
|
|
@@ -10910,7 +10917,7 @@ return v
|
|
|
10910
10917
|
return `${head}
|
|
10911
10918
|
const v=${child}(input,pos,ctx)
|
|
10912
10919
|
if(v!==FAIL)return v
|
|
10913
|
-
const err={_tag:'parseError',span:${prog.lines === 1 ? "spanLines(ctx,pos,pos)" : "
|
|
10920
|
+
const err={_tag:'parseError',span:${prog.lines === 1 ? "spanLines(ctx,pos,pos)" : "new _SP(pos,pos)"},expected:${xf}}
|
|
10914
10921
|
const es=ctx._errors
|
|
10915
10922
|
if(es!==undefined)es.push(err)
|
|
10916
10923
|
${REC ? "if(ctx._tolerant===true)captureError(ctx,err)\n" : ""}ctx._fc=false
|
|
@@ -10921,7 +10928,7 @@ return err
|
|
|
10921
10928
|
case OP_ROUTED: {
|
|
10922
10929
|
const fb = code[ip + 1];
|
|
10923
10930
|
const fallback = fb >= 0 ? link(fb) : void 0;
|
|
10924
|
-
const push = `pushCstLeaf(ctx,
|
|
10931
|
+
const push = `pushCstLeaf(ctx,new _LF(it.value,it.span))`;
|
|
10925
10932
|
return `${head}
|
|
10926
10933
|
const it=ctx._routed
|
|
10927
10934
|
if(it===undefined||pos!==it.span.start){
|
|
@@ -11002,8 +11009,8 @@ ctx._triviaLog=sOtl
|
|
|
11002
11009
|
}
|
|
11003
11010
|
if(v===FAIL)return FAIL
|
|
11004
11011
|
const e=EC.e
|
|
11005
|
-
const out=${isToken ? "input.slice(pos,e)" : `${fn}(v,
|
|
11006
|
-
if(wasCap)pushCstLeaf(ctx,{
|
|
11012
|
+
const out=${isToken ? "input.slice(pos,e)" : `${fn}(v,new _SP(pos,e))`}
|
|
11013
|
+
if(wasCap)pushCstLeaf(ctx,new _LF(${capturesSource ? "input.slice(pos,e)" : "out"},new _SP(pos,e)))
|
|
11007
11014
|
EC.e=e
|
|
11008
11015
|
return out
|
|
11009
11016
|
}`;
|
|
@@ -11027,7 +11034,7 @@ ${hasSuffix && (lineFlags & 2) !== 0 ? "if(sm)_trackLines(ctx,input,e)" : ""}
|
|
|
11027
11034
|
${hasSuffix ? `if(!sm){ctx._fe=e;ctx._fx=${suffixExpected};if(ctx._probe!==undefined)failAt(ctx,${suffixExpected},e)}` : ""}
|
|
11028
11035
|
const v=${pending ? "tp?_pfTokValue:" : ""}input.slice(pos,e)
|
|
11029
11036
|
${pending ? "if(tp){_pfTokBody=-1;_pfTokValue=undefined}" : ""}
|
|
11030
|
-
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,
|
|
11037
|
+
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
11031
11038
|
EC.e=e
|
|
11032
11039
|
return v
|
|
11033
11040
|
}`;
|
|
@@ -11066,7 +11073,7 @@ ctx._rootTriviaLog=sRtl
|
|
|
11066
11073
|
}
|
|
11067
11074
|
if(e<0)return FAIL
|
|
11068
11075
|
const v=input.slice(pos,e)
|
|
11069
|
-
if(wasCap)pushCstLeaf(ctx,
|
|
11076
|
+
if(wasCap)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
11070
11077
|
EC.e=e
|
|
11071
11078
|
return v
|
|
11072
11079
|
}`;
|
|
@@ -11074,7 +11081,7 @@ return v
|
|
|
11074
11081
|
const e=${run}(input,pos,ctx)
|
|
11075
11082
|
if(e<0)return FAIL
|
|
11076
11083
|
const v=input.slice(pos,e)
|
|
11077
|
-
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,
|
|
11084
|
+
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
11078
11085
|
EC.e=e
|
|
11079
11086
|
return v
|
|
11080
11087
|
}`;
|
|
@@ -11188,7 +11195,7 @@ return v
|
|
|
11188
11195
|
}` : `${parts.join("\n")}
|
|
11189
11196
|
}`;
|
|
11190
11197
|
if (n === 1) {
|
|
11191
|
-
parts.push(fused ? projection === 0 ? "return v0" : `return ${fn}([v0],
|
|
11198
|
+
parts.push(fused ? projection === 0 ? "return v0" : `return ${fn}([v0],new _SP(pos,EC.e))` : wantValues ? "return [v0]" : "return undefined");
|
|
11192
11199
|
return close();
|
|
11193
11200
|
}
|
|
11194
11201
|
parts.push("let cur=EC.e");
|
|
@@ -11214,7 +11221,7 @@ return v
|
|
|
11214
11221
|
names.push(vn);
|
|
11215
11222
|
}
|
|
11216
11223
|
parts.push("EC.e=cur");
|
|
11217
|
-
parts.push(fused ? projection >= 0 ? `return ${names[projection]}` : `return ${fn}([${names.join(",")}],
|
|
11224
|
+
parts.push(fused ? projection >= 0 ? `return ${names[projection]}` : `return ${fn}([${names.join(",")}],new _SP(pos,cur))` : wantValues ? `return [${names.join(",")}]` : "return undefined");
|
|
11218
11225
|
return close();
|
|
11219
11226
|
}
|
|
11220
11227
|
case OP_CHOICE: {
|
|
@@ -11473,7 +11480,7 @@ ${spec.match.map((m, i) => `${i === 0 ? "" : "else "}if(${dispatchClaim(m)})arm=
|
|
|
11473
11480
|
const routedCall = (target) => `{const savedRouted=ctx._routed
|
|
11474
11481
|
${emitRollback(m1, L.buf, L.raw, sinks)}
|
|
11475
11482
|
${emitMark(m2, L.buf, L.raw, sinks, false)}
|
|
11476
|
-
ctx._routed={value:key,span:
|
|
11483
|
+
ctx._routed={value:key,span:new _SP(pos,selEnd)}
|
|
11477
11484
|
try{v=${target}(input,pos,ctx)}finally{ctx._routed=savedRouted}
|
|
11478
11485
|
break}`;
|
|
11479
11486
|
const plainCall = (target) => `v=${target}(input,selEnd,ctx);break`;
|
|
@@ -11668,8 +11675,8 @@ return out
|
|
|
11668
11675
|
const end=${recognize}(input,pos)
|
|
11669
11676
|
if(end<0){ctx._fe=pos;ctx._fx=${xf};return FAIL}
|
|
11670
11677
|
const value=${value2}
|
|
11671
|
-
const leaf=
|
|
11672
|
-
const kids=[leaf],rawKids=[leaf],span=
|
|
11678
|
+
const leaf=new _LF(value,new _SP(pos,end))
|
|
11679
|
+
const kids=[leaf],rawKids=[leaf],span=new _SP(pos,end)
|
|
11673
11680
|
EC.e=end
|
|
11674
11681
|
const nd=${build2}(kids,undefined,span,rawKids,EMPTY_TL,undefined)
|
|
11675
11682
|
${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 +11775,7 @@ ctx._cstTriviaLog=sTl
|
|
|
11768
11775
|
ctx.captureTrivia=sCap
|
|
11769
11776
|
if(v===FAIL)return FAIL
|
|
11770
11777
|
const end=EC.e
|
|
11771
|
-
${collapseChildren ? `const nd=captured.length===1?captured[0]:${build}(captured,undefined,
|
|
11778
|
+
${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
11779
|
${publish}
|
|
11773
11780
|
EC.e=end
|
|
11774
11781
|
return nd
|
|
@@ -11791,20 +11798,20 @@ return nd
|
|
|
11791
11798
|
const direct = `${build}(kids,fieldMap,span,rawKids,${captureWide ? "tlog" : "EMPTY_TL"},st)`;
|
|
11792
11799
|
value = hostCst ? `nd=_pfHost!==undefined?${hostCall}:${direct}` : `nd=${direct}`;
|
|
11793
11800
|
} else {
|
|
11794
|
-
value = `nd=_pfHost!==undefined?_pfHost(${ty},hostKids,fieldMap,span,rawKids,tlog,st,${tags}):{
|
|
11801
|
+
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
11802
|
}
|
|
11796
11803
|
const collapsible = keepChildren && (hostCst || build === void 0 && proj < 0);
|
|
11797
|
-
const openCapture = omitsRaw ? `const buf=
|
|
11804
|
+
const openCapture = omitsRaw ? `const buf=new _BUF(undefined,true,0)
|
|
11798
11805
|
ctx._cstBuf=buf
|
|
11799
11806
|
ctx._cstChildren=undefined
|
|
11800
11807
|
ctx._cstLeaves=undefined
|
|
11801
11808
|
ctx._cstRawChildren=undefined
|
|
11802
|
-
ctx._cstTriviaLog=undefined` : keepChildren ? `const buf=
|
|
11809
|
+
ctx._cstTriviaLog=undefined` : keepChildren ? `const buf=new _BUF(undefined,undefined,0)
|
|
11803
11810
|
ctx._cstBuf=buf
|
|
11804
11811
|
ctx._cstChildren=undefined
|
|
11805
11812
|
ctx._cstLeaves=undefined
|
|
11806
11813
|
ctx._cstRawChildren=undefined
|
|
11807
|
-
ctx._cstTriviaLog=undefined` : `const buf=
|
|
11814
|
+
ctx._cstTriviaLog=undefined` : `const buf=new _BUF(true,undefined,0)
|
|
11808
11815
|
ctx._cstBuf=buf
|
|
11809
11816
|
ctx._cstChildren=undefined
|
|
11810
11817
|
ctx._cstLeaves=undefined
|
|
@@ -11842,7 +11849,7 @@ ctx._cstTriviaLog=sTl
|
|
|
11842
11849
|
ctx.captureTrivia=sCap
|
|
11843
11850
|
if(v===FAIL)return FAIL
|
|
11844
11851
|
const end=EC.e
|
|
11845
|
-
const span=${tracked ? "spanLines(ctx,pos,end)" : "
|
|
11852
|
+
const span=${tracked ? "spanLines(ctx,pos,end)" : "new _SP(pos,end)"}
|
|
11846
11853
|
const st=${readsState ? "ctx.state" : "undefined"}
|
|
11847
11854
|
let nd
|
|
11848
11855
|
${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 +12136,7 @@ function rebuildLineScan(s, subtree) {
|
|
|
12129
12136
|
}
|
|
12130
12137
|
|
|
12131
12138
|
// src/combinators/literal.ts
|
|
12139
|
+
import { PlainLeaf as PlainLeaf7, PlainSpan as PlainSpan8 } from "../cst/plain.js";
|
|
12132
12140
|
function asciiFoldEq(a, b) {
|
|
12133
12141
|
if (a.length !== b.length) return false;
|
|
12134
12142
|
for (let i = 0; i < a.length; i++) {
|
|
@@ -12186,9 +12194,9 @@ function literal(value, opts = {}) {
|
|
|
12186
12194
|
const code = value.charCodeAt(0);
|
|
12187
12195
|
return function parse3(input, pos, ctx) {
|
|
12188
12196
|
if (input.charCodeAt(pos) === code) {
|
|
12189
|
-
const span =
|
|
12197
|
+
const span = new PlainSpan8(pos, pos + 1);
|
|
12190
12198
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, span.end);
|
|
12191
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
12199
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf7(value, span));
|
|
12192
12200
|
return { ok: true, value, span };
|
|
12193
12201
|
}
|
|
12194
12202
|
return failAt(ctx, expected, pos);
|
|
@@ -12200,9 +12208,9 @@ function literal(value, opts = {}) {
|
|
|
12200
12208
|
}
|
|
12201
12209
|
const matchedValue = caseInsensitive ? input.slice(pos, end) : value;
|
|
12202
12210
|
if (caseInsensitive ? asciiFoldEq(matchedValue, value) : input.startsWith(value, pos)) {
|
|
12203
|
-
const span =
|
|
12211
|
+
const span = new PlainSpan8(pos, end);
|
|
12204
12212
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, end);
|
|
12205
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
12213
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf7(matchedValue, span));
|
|
12206
12214
|
return { ok: true, value: matchedValue, span };
|
|
12207
12215
|
}
|
|
12208
12216
|
return failAt(ctx, expected, pos);
|
|
@@ -12284,6 +12292,7 @@ function ref() {
|
|
|
12284
12292
|
}
|
|
12285
12293
|
|
|
12286
12294
|
// src/combinators/scanTo.ts
|
|
12295
|
+
import { PlainLeaf as PlainLeaf8, PlainSpan as PlainSpan9 } from "../cst/plain.js";
|
|
12287
12296
|
function resolveScanSkip(explicitSkip, raw, ctx) {
|
|
12288
12297
|
if (raw) return [];
|
|
12289
12298
|
const trivia2 = ctx.trivia;
|
|
@@ -12321,7 +12330,7 @@ function scanTo(sentinel, { skip, raw = false, orEOF = false, recoverAt, stopAt
|
|
|
12321
12330
|
probeCtx._errors = ctx._errors;
|
|
12322
12331
|
const emit = (end) => {
|
|
12323
12332
|
if (end > pos && cstCaptureActive(ctx)) {
|
|
12324
|
-
const leaf2 =
|
|
12333
|
+
const leaf2 = new PlainLeaf8(input.slice(pos, end), new PlainSpan9(pos, end));
|
|
12325
12334
|
pushCstLeaf(ctx, leaf2);
|
|
12326
12335
|
}
|
|
12327
12336
|
};
|
|
@@ -12600,6 +12609,9 @@ function clearOf(ranges, input, from, to) {
|
|
|
12600
12609
|
return true;
|
|
12601
12610
|
}
|
|
12602
12611
|
|
|
12612
|
+
// src/table/assemble.ts
|
|
12613
|
+
import { PlainBuf as PlainBuf2, PlainField, PlainLeaf as PlainLeaf9, PlainNode as PlainNode2, PlainSpan as PlainSpan10 } from "../cst/plain.js";
|
|
12614
|
+
|
|
12603
12615
|
// src/table/fail-clean.ts
|
|
12604
12616
|
function passChild(code, ip) {
|
|
12605
12617
|
switch (code[ip]) {
|
|
@@ -12914,7 +12926,7 @@ function assemble(t2, prog, cfg) {
|
|
|
12914
12926
|
const NULLABLE = /* @__PURE__ */ new Map();
|
|
12915
12927
|
const CLEAN = REC ? () => false : failCleanAnalysis(code);
|
|
12916
12928
|
function pushLeaf(ctx, value, s, e) {
|
|
12917
|
-
const lf =
|
|
12929
|
+
const lf = new PlainLeaf9(value, new PlainSpan10(s, e));
|
|
12918
12930
|
pushCstLeaf(ctx, lf);
|
|
12919
12931
|
}
|
|
12920
12932
|
function plainBuildNode(child, build, trailing) {
|
|
@@ -12947,7 +12959,7 @@ function assemble(t2, prog, cfg) {
|
|
|
12947
12959
|
ctx.captureTrivia = sCap;
|
|
12948
12960
|
if (value === FAIL) return FAIL;
|
|
12949
12961
|
const end = EC.e;
|
|
12950
|
-
const span =
|
|
12962
|
+
const span = new PlainSpan10(pos, end);
|
|
12951
12963
|
const node2 = build(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
|
|
12952
12964
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
12953
12965
|
pushCstChild(ctx, node2, rawEntry(node2, input, pos, end));
|
|
@@ -12992,7 +13004,7 @@ function assemble(t2, prog, cfg) {
|
|
|
12992
13004
|
ctx.captureTrivia = sCap;
|
|
12993
13005
|
if (value === FAIL) return FAIL;
|
|
12994
13006
|
const end = EC.e;
|
|
12995
|
-
const node2 = build(captured, void 0,
|
|
13007
|
+
const node2 = build(captured, void 0, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
|
|
12996
13008
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
12997
13009
|
pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
|
|
12998
13010
|
}
|
|
@@ -13029,7 +13041,7 @@ function assemble(t2, prog, cfg) {
|
|
|
13029
13041
|
ctx.captureTrivia = sCap;
|
|
13030
13042
|
if (value === FAIL) return FAIL;
|
|
13031
13043
|
const end = EC.e;
|
|
13032
|
-
const node2 = build(captured, fieldMap,
|
|
13044
|
+
const node2 = build(captured, fieldMap, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
|
|
13033
13045
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13034
13046
|
pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
|
|
13035
13047
|
}
|
|
@@ -13066,7 +13078,7 @@ function assemble(t2, prog, cfg) {
|
|
|
13066
13078
|
ctx.captureTrivia = sCap;
|
|
13067
13079
|
if (value === FAIL) return FAIL;
|
|
13068
13080
|
const end = EC.e;
|
|
13069
|
-
const span =
|
|
13081
|
+
const span = new PlainSpan10(pos, end);
|
|
13070
13082
|
const node2 = kids.length === 1 ? kids[0] : build(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
|
|
13071
13083
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13072
13084
|
pushCstChild(ctx, node2, rawEntry(node2, input, pos, end));
|
|
@@ -13103,7 +13115,7 @@ function assemble(t2, prog, cfg) {
|
|
|
13103
13115
|
ctx.captureTrivia = sCap;
|
|
13104
13116
|
if (value === FAIL) return FAIL;
|
|
13105
13117
|
const end = EC.e;
|
|
13106
|
-
const node2 = captured.length === 1 ? captured[0] : build(captured, void 0,
|
|
13118
|
+
const node2 = captured.length === 1 ? captured[0] : build(captured, void 0, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
|
|
13107
13119
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13108
13120
|
pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
|
|
13109
13121
|
}
|
|
@@ -13536,7 +13548,7 @@ function assemble(t2, prog, cfg) {
|
|
|
13536
13548
|
return (input, pos, selEnd, key, ctx, need, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot) => {
|
|
13537
13549
|
const savedRouted = ctx._routed;
|
|
13538
13550
|
if (need) rollbackTriviaAt(ctx, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot);
|
|
13539
|
-
ctx._routed = { value: key, span:
|
|
13551
|
+
ctx._routed = { value: key, span: new PlainSpan10(pos, selEnd) };
|
|
13540
13552
|
let v;
|
|
13541
13553
|
try {
|
|
13542
13554
|
v = child(input, pos, ctx);
|
|
@@ -13969,7 +13981,7 @@ function assemble(t2, prog, cfg) {
|
|
|
13969
13981
|
case OP_EXPECT: {
|
|
13970
13982
|
const child = link(code[ip + 1]);
|
|
13971
13983
|
const xf = fx[code[ip + 2]];
|
|
13972
|
-
const expectSpan = (ctx, pos) => prog.lines === 1 ? spanLines(ctx, pos, pos) :
|
|
13984
|
+
const expectSpan = (ctx, pos) => prog.lines === 1 ? spanLines(ctx, pos, pos) : new PlainSpan10(pos, pos);
|
|
13973
13985
|
if (REC) {
|
|
13974
13986
|
return (input, pos, ctx) => {
|
|
13975
13987
|
const v = child(input, pos, ctx);
|
|
@@ -14001,7 +14013,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14001
14013
|
return (input, pos, ctx) => {
|
|
14002
14014
|
const v = child(input, pos, ctx);
|
|
14003
14015
|
if (v === FAIL) return FAIL;
|
|
14004
|
-
ctx._fields?.push(
|
|
14016
|
+
ctx._fields?.push(new PlainField(name, v, new PlainSpan10(pos, EC.e)));
|
|
14005
14017
|
return v;
|
|
14006
14018
|
};
|
|
14007
14019
|
}
|
|
@@ -14025,7 +14037,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14025
14037
|
return (input, pos, ctx) => {
|
|
14026
14038
|
const v = child(input, pos, ctx);
|
|
14027
14039
|
if (v === FAIL) return FAIL;
|
|
14028
|
-
return fn(v,
|
|
14040
|
+
return fn(v, new PlainSpan10(pos, EC.e));
|
|
14029
14041
|
};
|
|
14030
14042
|
}
|
|
14031
14043
|
case OP_SCAN: {
|
|
@@ -14129,7 +14141,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14129
14141
|
ctx._fx = ROUTED_FX;
|
|
14130
14142
|
return FAIL;
|
|
14131
14143
|
}
|
|
14132
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
14144
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(item.value, item.span));
|
|
14133
14145
|
EC.e = item.span.end;
|
|
14134
14146
|
return item.value;
|
|
14135
14147
|
};
|
|
@@ -14315,7 +14327,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14315
14327
|
if (v === FAIL) return FAIL;
|
|
14316
14328
|
const end = EC.e;
|
|
14317
14329
|
const value = input.slice(pos, end);
|
|
14318
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
14330
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
|
|
14319
14331
|
EC.e = end;
|
|
14320
14332
|
return value;
|
|
14321
14333
|
};
|
|
@@ -14349,7 +14361,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14349
14361
|
if (ctx._probe !== void 0) failAt(ctx, suffixExpected, end);
|
|
14350
14362
|
}
|
|
14351
14363
|
const value = input.slice(pos, end);
|
|
14352
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
14364
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
|
|
14353
14365
|
EC.e = end;
|
|
14354
14366
|
return value;
|
|
14355
14367
|
};
|
|
@@ -14392,7 +14404,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14392
14404
|
}
|
|
14393
14405
|
if (end < 0) return FAIL;
|
|
14394
14406
|
const value = input.slice(pos, end);
|
|
14395
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
14407
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
|
|
14396
14408
|
EC.e = end;
|
|
14397
14409
|
return value;
|
|
14398
14410
|
};
|
|
@@ -14401,7 +14413,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14401
14413
|
const end = run(input, pos, ctx);
|
|
14402
14414
|
if (end < 0) return FAIL;
|
|
14403
14415
|
const value = input.slice(pos, end);
|
|
14404
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
14416
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
|
|
14405
14417
|
EC.e = end;
|
|
14406
14418
|
return value;
|
|
14407
14419
|
};
|
|
@@ -14434,12 +14446,8 @@ function assemble(t2, prog, cfg) {
|
|
|
14434
14446
|
}
|
|
14435
14447
|
if (v === FAIL) return FAIL;
|
|
14436
14448
|
const end = EC.e;
|
|
14437
|
-
const out = fn(v,
|
|
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
|
-
});
|
|
14449
|
+
const out = fn(v, new PlainSpan10(pos, end));
|
|
14450
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(op === OP_SOURCE_LEAF && hostCst ? input.slice(pos, end) : out, new PlainSpan10(pos, end)));
|
|
14443
14451
|
EC.e = end;
|
|
14444
14452
|
return out;
|
|
14445
14453
|
};
|
|
@@ -14574,7 +14582,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14574
14582
|
const cur = runSyncTerms(input, pos, ctx, values);
|
|
14575
14583
|
if (cur < 0) return FAIL;
|
|
14576
14584
|
EC.e = cur;
|
|
14577
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
14585
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
|
|
14578
14586
|
};
|
|
14579
14587
|
}
|
|
14580
14588
|
if (wantValues) {
|
|
@@ -14668,7 +14676,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14668
14676
|
const cur = runAdjTerms(input, pos, ctx, values);
|
|
14669
14677
|
if (cur < 0) return FAIL;
|
|
14670
14678
|
EC.e = cur;
|
|
14671
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
14679
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
|
|
14672
14680
|
};
|
|
14673
14681
|
}
|
|
14674
14682
|
if (wantValues) {
|
|
@@ -14693,7 +14701,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14693
14701
|
return (input, pos, ctx) => {
|
|
14694
14702
|
const v = k0(input, pos, ctx);
|
|
14695
14703
|
if (v === FAIL) return FAIL;
|
|
14696
|
-
return projection === 0 ? v : fn([v],
|
|
14704
|
+
return projection === 0 ? v : fn([v], new PlainSpan10(pos, EC.e));
|
|
14697
14705
|
};
|
|
14698
14706
|
}
|
|
14699
14707
|
if (wantValues) {
|
|
@@ -14718,7 +14726,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14718
14726
|
const cur = step(k1, input, EC.e, ctx);
|
|
14719
14727
|
if (cur < 0) return FAIL;
|
|
14720
14728
|
EC.e = cur;
|
|
14721
|
-
return projection === 0 ? v0 : projection === 1 ? TERMV : fn([v0, TERMV],
|
|
14729
|
+
return projection === 0 ? v0 : projection === 1 ? TERMV : fn([v0, TERMV], new PlainSpan10(pos, cur));
|
|
14722
14730
|
};
|
|
14723
14731
|
}
|
|
14724
14732
|
if (wantValues) {
|
|
@@ -14752,7 +14760,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14752
14760
|
cur = step(k2, input, cur, ctx);
|
|
14753
14761
|
if (cur < 0) return FAIL;
|
|
14754
14762
|
EC.e = cur;
|
|
14755
|
-
return projection === 0 ? v0 : projection === 1 ? v1 : projection === 2 ? TERMV : fn([v0, v1, TERMV],
|
|
14763
|
+
return projection === 0 ? v0 : projection === 1 ? v1 : projection === 2 ? TERMV : fn([v0, v1, TERMV], new PlainSpan10(pos, cur));
|
|
14756
14764
|
};
|
|
14757
14765
|
}
|
|
14758
14766
|
if (wantValues) {
|
|
@@ -14849,7 +14857,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14849
14857
|
const cur = runDirectTerms(input, pos, ctx, values);
|
|
14850
14858
|
if (cur < 0) return FAIL;
|
|
14851
14859
|
EC.e = cur;
|
|
14852
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
14860
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
|
|
14853
14861
|
};
|
|
14854
14862
|
}
|
|
14855
14863
|
if (wantValues) {
|
|
@@ -15747,10 +15755,10 @@ function assemble(t2, prog, cfg) {
|
|
|
15747
15755
|
return FAIL;
|
|
15748
15756
|
}
|
|
15749
15757
|
const value = regexValue ? input.slice(pos, end) : spec;
|
|
15750
|
-
const leaf2 =
|
|
15758
|
+
const leaf2 = new PlainLeaf9(value, new PlainSpan10(pos, end));
|
|
15751
15759
|
const kids = [leaf2];
|
|
15752
15760
|
const rawKids = [leaf2];
|
|
15753
|
-
const span =
|
|
15761
|
+
const span = new PlainSpan10(pos, end);
|
|
15754
15762
|
EC.e = end;
|
|
15755
15763
|
const nd = build2(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
|
|
15756
15764
|
if (ctx._cstBuf !== void 0 || ctx._cstChildren !== void 0) {
|
|
@@ -15832,7 +15840,7 @@ function assemble(t2, prog, cfg) {
|
|
|
15832
15840
|
const sCh = ctx._cstChildren;
|
|
15833
15841
|
const sCap = ctx.captureTrivia;
|
|
15834
15842
|
const sBuf = ctx._cstBuf;
|
|
15835
|
-
const buf = rawOnly ?
|
|
15843
|
+
const buf = rawOnly ? new PlainBuf2(true, void 0, 0) : omitsRaw ? new PlainBuf2(void 0, true, 0) : new PlainBuf2(void 0, void 0, 0);
|
|
15836
15844
|
ctx._cstBuf = buf;
|
|
15837
15845
|
ctx.captureTrivia = captureWide;
|
|
15838
15846
|
const savedFields = ctx._fields;
|
|
@@ -15854,7 +15862,7 @@ function assemble(t2, prog, cfg) {
|
|
|
15854
15862
|
ctx.captureTrivia = sCap;
|
|
15855
15863
|
if (v === FAIL) return FAIL;
|
|
15856
15864
|
const end = EC.e;
|
|
15857
|
-
const span = tracked ? spanLines(ctx, pos, end) :
|
|
15865
|
+
const span = tracked ? spanLines(ctx, pos, end) : new PlainSpan10(pos, end);
|
|
15858
15866
|
const st = readsState ? ctx.state : void 0;
|
|
15859
15867
|
let nd;
|
|
15860
15868
|
if (unwrap && kids.length === 1) {
|
|
@@ -15878,7 +15886,7 @@ function assemble(t2, prog, cfg) {
|
|
|
15878
15886
|
} else if (host !== void 0) {
|
|
15879
15887
|
nd = host(type, hostKids, fieldMap, span, rawKids, tlog, st, tags);
|
|
15880
15888
|
} else {
|
|
15881
|
-
nd =
|
|
15889
|
+
nd = new PlainNode2(type, span, st ?? null, kids === EMPTY_CH ? kids : [...kids]);
|
|
15882
15890
|
}
|
|
15883
15891
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
15884
15892
|
pushCstChild(ctx, nd, rawEntry(nd, input, pos, end));
|
|
@@ -15904,7 +15912,7 @@ function assemble(t2, prog, cfg) {
|
|
|
15904
15912
|
const at = fe === void 0 || fe < 0 ? pos : fe;
|
|
15905
15913
|
return { ok: false, expected: ctx._fx ?? EMPTY_FX2, span: { start: at, end: at } };
|
|
15906
15914
|
}
|
|
15907
|
-
return { ok: true, value: v, span:
|
|
15915
|
+
return { ok: true, value: v, span: new PlainSpan10(pos, EC.e) };
|
|
15908
15916
|
}
|
|
15909
15917
|
};
|
|
15910
15918
|
}
|
|
@@ -16019,7 +16027,12 @@ function assemble(t2, prog, cfg) {
|
|
|
16019
16027
|
LEAD,
|
|
16020
16028
|
triviaFieldCapture,
|
|
16021
16029
|
skipDeferredTrivia,
|
|
16022
|
-
collapseEmpty
|
|
16030
|
+
collapseEmpty,
|
|
16031
|
+
PlainSpan10,
|
|
16032
|
+
PlainLeaf9,
|
|
16033
|
+
PlainNode2,
|
|
16034
|
+
PlainField,
|
|
16035
|
+
PlainBuf2
|
|
16023
16036
|
);
|
|
16024
16037
|
emitReached = new Set(pre.reached);
|
|
16025
16038
|
if (emitted.ext !== void 0) HYBRID = emitted;
|
|
@@ -16106,7 +16119,12 @@ function assemble(t2, prog, cfg) {
|
|
|
16106
16119
|
LEAD,
|
|
16107
16120
|
triviaFieldCapture,
|
|
16108
16121
|
skipDeferredTrivia,
|
|
16109
|
-
collapseEmpty
|
|
16122
|
+
collapseEmpty,
|
|
16123
|
+
PlainSpan10,
|
|
16124
|
+
PlainLeaf9,
|
|
16125
|
+
PlainNode2,
|
|
16126
|
+
PlainField,
|
|
16127
|
+
PlainBuf2
|
|
16110
16128
|
);
|
|
16111
16129
|
emitReached = em.reached;
|
|
16112
16130
|
} catch (e) {
|
|
@@ -16364,7 +16382,11 @@ function tableRules(source, metadataOrEntry = {}) {
|
|
|
16364
16382
|
return map[entry];
|
|
16365
16383
|
}
|
|
16366
16384
|
|
|
16385
|
+
// src/version.ts
|
|
16386
|
+
var PARSEMAN_VERSION = "0.59.1";
|
|
16387
|
+
|
|
16367
16388
|
// src/table/emit.ts
|
|
16389
|
+
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
16390
|
function jsString(s) {
|
|
16369
16391
|
return JSON.stringify(s);
|
|
16370
16392
|
}
|
|
@@ -16439,7 +16461,7 @@ function emitAssemblies(prog, cfgs) {
|
|
|
16439
16461
|
throw e;
|
|
16440
16462
|
}
|
|
16441
16463
|
const plan = em.plan;
|
|
16442
|
-
out.push(`{key:${key},factory:function(${EMITTED_PARAMS.join(",")}){${em.source}
|
|
16464
|
+
out.push(`{key:${key},factory:function(${EMITTED_PARAMS.join(",")}){${FACTORY_ARITY_GUARD}${em.source}
|
|
16443
16465
|
},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
16466
|
}
|
|
16445
16467
|
return [`a:[${out.join(",")}],`];
|