parseman 0.58.3 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analysis/diagnostics.js +141 -93
- package/dist/analysis/diagnostics.js.map +3 -3
- package/dist/cli/index.js +143 -94
- package/dist/cli/index.js.map +3 -3
- 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.map +1 -1
- package/dist/combinators/token.d.ts.map +1 -1
- package/dist/compiler/linker.d.ts.map +1 -1
- package/dist/compiler/token-capability.js.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/index.js +144 -98
- 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 +146 -100
- 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/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/index.js +124 -89
- package/dist/table/index.js.map +3 -3
- package/dist/table/run-support.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -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 +2 -1
- package/src/combinators/token.ts +3 -6
- package/src/compiler/linker.ts +4 -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/line-index.ts +37 -0
- package/src/plugin/entry-supercompiler.ts +3 -2
- package/src/recovery/scan.ts +2 -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/run-support.ts +4 -7
- package/src/version.ts +1 -1
package/dist/table/index.js
CHANGED
|
@@ -383,6 +383,7 @@ function createDetachedParseContext(trackLines, state) {
|
|
|
383
383
|
}
|
|
384
384
|
|
|
385
385
|
// src/line-index.ts
|
|
386
|
+
import { PlainLineSpan, PlainSpan } from "../cst/plain.js";
|
|
386
387
|
function createLineIndex() {
|
|
387
388
|
return { lineStarts: [0] };
|
|
388
389
|
}
|
|
@@ -435,6 +436,14 @@ function annotateSpan(span, index) {
|
|
|
435
436
|
endColumn: e.col
|
|
436
437
|
};
|
|
437
438
|
}
|
|
439
|
+
function lineSpanFromContext(span, ctx) {
|
|
440
|
+
if (!ctx.trackLines) return span;
|
|
441
|
+
const index = ctx._lineIndex ?? (ctx._lineStarts ? { lineStarts: ctx._lineStarts } : void 0);
|
|
442
|
+
if (!index) return span;
|
|
443
|
+
const s = offsetToLineCol(index, span.start);
|
|
444
|
+
const e = offsetToLineCol(index, span.end);
|
|
445
|
+
return new PlainLineSpan(span.start, span.end, s.line, s.col, e.line, e.col);
|
|
446
|
+
}
|
|
438
447
|
function annotateSpanFromLineContext(span, ctx) {
|
|
439
448
|
if (!ctx.trackLines) return span;
|
|
440
449
|
const index = ctx._lineIndex ?? (ctx._lineStarts ? { lineStarts: ctx._lineStarts } : void 0);
|
|
@@ -639,15 +648,19 @@ function rebuildLineScan(s, subtree) {
|
|
|
639
648
|
}
|
|
640
649
|
|
|
641
650
|
// src/cst/capture-buffer.ts
|
|
651
|
+
import { PlainBuf, PlainLeaf } from "../cst/plain.js";
|
|
642
652
|
function cstCaptureActive(ctx) {
|
|
643
653
|
return ctx._cstBuf !== void 0 || ctx._cstLeaves !== void 0;
|
|
644
654
|
}
|
|
655
|
+
function isLeaf(v) {
|
|
656
|
+
return typeof v === "object" && v !== null && v._tag === "leaf";
|
|
657
|
+
}
|
|
645
658
|
function pushCstLeaf(ctx, leaf2) {
|
|
646
659
|
if (!ctx.trackLines) {
|
|
647
660
|
pushCstChild(ctx, leaf2, leaf2);
|
|
648
661
|
return;
|
|
649
662
|
}
|
|
650
|
-
const annotated = leaf2 && typeof leaf2 === "object" && leaf2.span ? { ...leaf2, span: annotateSpanFromLineContext(leaf2.span, ctx) } : leaf2;
|
|
663
|
+
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;
|
|
651
664
|
pushCstChild(ctx, annotated, annotated);
|
|
652
665
|
}
|
|
653
666
|
function pushCstChild(ctx, built, rawEntry2) {
|
|
@@ -1562,6 +1575,7 @@ function triviaKindMask(labels, keep) {
|
|
|
1562
1575
|
}
|
|
1563
1576
|
|
|
1564
1577
|
// src/recovery/scan.ts
|
|
1578
|
+
import { PlainSpan as PlainSpan2 } from "../cst/plain.js";
|
|
1565
1579
|
function probeAt(sentinel, input, pos, ctx) {
|
|
1566
1580
|
const s = {
|
|
1567
1581
|
_probe: ctx._probe,
|
|
@@ -1638,7 +1652,7 @@ function firstSetSentinel(fs) {
|
|
|
1638
1652
|
function recoverScan(input, from, ctx, sync, expected) {
|
|
1639
1653
|
let scanPos = from;
|
|
1640
1654
|
while (scanPos < input.length && !probeAt(sync, input, scanPos, ctx)) scanPos++;
|
|
1641
|
-
const span =
|
|
1655
|
+
const span = new PlainSpan2(from, scanPos);
|
|
1642
1656
|
if (ctx.trackLines) recordLineRangeFromContext(ctx, input, from, scanPos);
|
|
1643
1657
|
const error = { _tag: "parseError", span: ctx.trackLines ? annotateSpanFromLineContext(span, ctx) : span, expected };
|
|
1644
1658
|
ctx._errors?.push(error);
|
|
@@ -2741,17 +2755,18 @@ function buildAsciiDispatch(parsers) {
|
|
|
2741
2755
|
}
|
|
2742
2756
|
|
|
2743
2757
|
// src/combinators/field-trivia.ts
|
|
2758
|
+
import { PlainSpan as PlainSpan3, PlainTriviaField } from "../cst/plain.js";
|
|
2744
2759
|
var LEAD = { at: -1 };
|
|
2745
2760
|
var FIELD_LEADING_TRIVIA = 1;
|
|
2746
2761
|
var FIELD_TRAILING_TRIVIA = 2;
|
|
2747
2762
|
function triviaFieldCapture(name, value, input, start, end, leadFrom, trailEnd) {
|
|
2748
|
-
return
|
|
2763
|
+
return new PlainTriviaField(
|
|
2749
2764
|
name,
|
|
2750
2765
|
value,
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2766
|
+
new PlainSpan3(start, end),
|
|
2767
|
+
leadFrom >= 0 && leadFrom < start ? input.slice(leadFrom, start) : "",
|
|
2768
|
+
trailEnd > end ? input.slice(end, trailEnd) : ""
|
|
2769
|
+
);
|
|
2755
2770
|
}
|
|
2756
2771
|
function leadsTrivia(p) {
|
|
2757
2772
|
return p._def.tag === "field" && p._def.leadingTrivia === true;
|
|
@@ -3366,6 +3381,7 @@ function firstSetFromRegex(source, flags = "") {
|
|
|
3366
3381
|
}
|
|
3367
3382
|
|
|
3368
3383
|
// src/combinators/regex.ts
|
|
3384
|
+
import { PlainLeaf as PlainLeaf2, PlainSpan as PlainSpan4 } from "../cst/plain.js";
|
|
3369
3385
|
var SCAN_BAIL_AT = 64;
|
|
3370
3386
|
function inRanges3(cp, ranges) {
|
|
3371
3387
|
for (let i = 0; i < ranges.length; i++) {
|
|
@@ -3478,9 +3494,9 @@ function regex(pattern, flags = "") {
|
|
|
3478
3494
|
if (scanEnd !== void 0) {
|
|
3479
3495
|
if (scanEnd === null) return failAt(ctx, directTerminalFailureExpected(def), pos);
|
|
3480
3496
|
const value = input.slice(pos, scanEnd);
|
|
3481
|
-
const span2 =
|
|
3497
|
+
const span2 = new PlainSpan4(pos, scanEnd);
|
|
3482
3498
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, scanEnd);
|
|
3483
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
3499
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf2(value, span2));
|
|
3484
3500
|
return { ok: true, value, span: span2 };
|
|
3485
3501
|
}
|
|
3486
3502
|
anchored.lastIndex = pos;
|
|
@@ -3488,9 +3504,9 @@ function regex(pattern, flags = "") {
|
|
|
3488
3504
|
if (m === null) {
|
|
3489
3505
|
return failAt(ctx, directTerminalFailureExpected(def), pos);
|
|
3490
3506
|
}
|
|
3491
|
-
const span =
|
|
3507
|
+
const span = new PlainSpan4(pos, pos + m[0].length);
|
|
3492
3508
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, span.end);
|
|
3493
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
3509
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf2(m[0], span));
|
|
3494
3510
|
return { ok: true, value: m[0], span };
|
|
3495
3511
|
}
|
|
3496
3512
|
};
|
|
@@ -3517,6 +3533,7 @@ function buildLexBodyRecognizer(spec, constants) {
|
|
|
3517
3533
|
}
|
|
3518
3534
|
|
|
3519
3535
|
// src/table/run-support.ts
|
|
3536
|
+
import { PlainLeaf as PlainLeaf3, PlainLineSpan as PlainLineSpan2, PlainSpan as PlainSpan5 } from "../cst/plain.js";
|
|
3520
3537
|
function lineCol(ctx, offset) {
|
|
3521
3538
|
const starts = ctx._lineStarts ?? [0];
|
|
3522
3539
|
let lo = 0, hi = starts.length - 1;
|
|
@@ -3529,18 +3546,14 @@ function lineCol(ctx, offset) {
|
|
|
3529
3546
|
}
|
|
3530
3547
|
function spanLines(ctx, start, end) {
|
|
3531
3548
|
const s = lineCol(ctx, start), e = lineCol(ctx, end);
|
|
3532
|
-
return
|
|
3549
|
+
return new PlainLineSpan2(start, end, s[0], s[1], e[0], e[1]);
|
|
3533
3550
|
}
|
|
3534
3551
|
function rawEntry(v, input, s, e) {
|
|
3535
3552
|
if (typeof v === "object" && v !== null) {
|
|
3536
3553
|
const tg = v._tag;
|
|
3537
3554
|
if (tg === "node" || tg === "leaf" || tg === "parseError") return v;
|
|
3538
3555
|
}
|
|
3539
|
-
return
|
|
3540
|
-
_tag: "leaf",
|
|
3541
|
-
value: typeof v === "string" ? v : typeof v === "object" && v !== null ? input.slice(s, e) : "",
|
|
3542
|
-
span: { start: s, end: e }
|
|
3543
|
-
};
|
|
3556
|
+
return new PlainLeaf3(typeof v === "string" ? v : typeof v === "object" && v !== null ? input.slice(s, e) : "", new PlainSpan5(s, e));
|
|
3544
3557
|
}
|
|
3545
3558
|
function lead(input, pos) {
|
|
3546
3559
|
if (pos >= input.length) return -1;
|
|
@@ -3554,7 +3567,7 @@ function collapseEmpty(ctx, build, input, pos, end, readsRaw) {
|
|
|
3554
3567
|
const collected = ctx._cstBuf !== void 0 || ctx._cstChildren !== void 0;
|
|
3555
3568
|
if (collected) popCstChild(ctx);
|
|
3556
3569
|
const raw = readsRaw ? [rawEntry(void 0, input, pos, end)] : EMPTY_KIDS;
|
|
3557
|
-
const nd = build(EMPTY_KIDS, void 0,
|
|
3570
|
+
const nd = build(EMPTY_KIDS, void 0, new PlainSpan5(pos, end), raw, EMPTY_TRIVIA, void 0);
|
|
3558
3571
|
if (collected) pushCstChild(ctx, nd, ctx._cstBuf?.noRaw === true ? void 0 : rawEntry(nd, input, pos, end));
|
|
3559
3572
|
return nd;
|
|
3560
3573
|
}
|
|
@@ -4435,6 +4448,7 @@ function expandCompactFolded(f) {
|
|
|
4435
4448
|
}
|
|
4436
4449
|
|
|
4437
4450
|
// src/combinators/literal.ts
|
|
4451
|
+
import { PlainLeaf as PlainLeaf4, PlainSpan as PlainSpan6 } from "../cst/plain.js";
|
|
4438
4452
|
function asciiFoldEq(a, b) {
|
|
4439
4453
|
if (a.length !== b.length) return false;
|
|
4440
4454
|
for (let i = 0; i < a.length; i++) {
|
|
@@ -4492,9 +4506,9 @@ function literal(value, opts = {}) {
|
|
|
4492
4506
|
const code = value.charCodeAt(0);
|
|
4493
4507
|
return function parse2(input, pos, ctx) {
|
|
4494
4508
|
if (input.charCodeAt(pos) === code) {
|
|
4495
|
-
const span =
|
|
4509
|
+
const span = new PlainSpan6(pos, pos + 1);
|
|
4496
4510
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, span.end);
|
|
4497
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
4511
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf4(value, span));
|
|
4498
4512
|
return { ok: true, value, span };
|
|
4499
4513
|
}
|
|
4500
4514
|
return failAt(ctx, expected, pos);
|
|
@@ -4506,9 +4520,9 @@ function literal(value, opts = {}) {
|
|
|
4506
4520
|
}
|
|
4507
4521
|
const matchedValue = caseInsensitive ? input.slice(pos, end) : value;
|
|
4508
4522
|
if (caseInsensitive ? asciiFoldEq(matchedValue, value) : input.startsWith(value, pos)) {
|
|
4509
|
-
const span =
|
|
4523
|
+
const span = new PlainSpan6(pos, end);
|
|
4510
4524
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, end);
|
|
4511
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
4525
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf4(matchedValue, span));
|
|
4512
4526
|
return { ok: true, value: matchedValue, span };
|
|
4513
4527
|
}
|
|
4514
4528
|
return failAt(ctx, expected, pos);
|
|
@@ -5049,6 +5063,7 @@ function buildReadsState(def) {
|
|
|
5049
5063
|
}
|
|
5050
5064
|
|
|
5051
5065
|
// src/combinators/token.ts
|
|
5066
|
+
import { PlainLeaf as PlainLeaf5 } from "../cst/plain.js";
|
|
5052
5067
|
function semanticLeafValue(_ctx, _input, _start, _end, value) {
|
|
5053
5068
|
return value;
|
|
5054
5069
|
}
|
|
@@ -5102,7 +5117,7 @@ function token(root) {
|
|
|
5102
5117
|
if (!result.ok) return result;
|
|
5103
5118
|
const span = result.span;
|
|
5104
5119
|
const value = input.slice(pos, span.end);
|
|
5105
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
5120
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf5(value, span));
|
|
5106
5121
|
return { ok: true, value, span };
|
|
5107
5122
|
}
|
|
5108
5123
|
};
|
|
@@ -5150,11 +5165,7 @@ function makeLeaf(root, fn, sourceCstValue) {
|
|
|
5150
5165
|
}
|
|
5151
5166
|
if (!result.ok) return result;
|
|
5152
5167
|
const value = fn(result.value, result.span);
|
|
5153
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
5154
|
-
_tag: "leaf",
|
|
5155
|
-
value: cstValue(ctx, input, pos, result.span.end, value),
|
|
5156
|
-
span: result.span
|
|
5157
|
-
});
|
|
5168
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf5(cstValue(ctx, input, pos, result.span.end, value), result.span));
|
|
5158
5169
|
return { ok: true, value, span: result.span };
|
|
5159
5170
|
}
|
|
5160
5171
|
};
|
|
@@ -5167,6 +5178,7 @@ function sourceLeaf(root, fn) {
|
|
|
5167
5178
|
}
|
|
5168
5179
|
|
|
5169
5180
|
// src/combinators/scanTo.ts
|
|
5181
|
+
import { PlainLeaf as PlainLeaf6, PlainSpan as PlainSpan7 } from "../cst/plain.js";
|
|
5170
5182
|
function resolveScanSkip(explicitSkip, raw, ctx) {
|
|
5171
5183
|
if (raw) return [];
|
|
5172
5184
|
const trivia2 = ctx.trivia;
|
|
@@ -5204,7 +5216,7 @@ function scanTo(sentinel, { skip, raw = false, orEOF = false, recoverAt, stopAt
|
|
|
5204
5216
|
probeCtx._errors = ctx._errors;
|
|
5205
5217
|
const emit = (end) => {
|
|
5206
5218
|
if (end > pos && cstCaptureActive(ctx)) {
|
|
5207
|
-
const leaf2 =
|
|
5219
|
+
const leaf2 = new PlainLeaf6(input.slice(pos, end), new PlainSpan7(pos, end));
|
|
5208
5220
|
pushCstLeaf(ctx, leaf2);
|
|
5209
5221
|
}
|
|
5210
5222
|
};
|
|
@@ -5555,6 +5567,7 @@ function clearOf(ranges, input, from, to) {
|
|
|
5555
5567
|
}
|
|
5556
5568
|
|
|
5557
5569
|
// src/combinators/dispatch.ts
|
|
5570
|
+
import { PlainLeaf as PlainLeaf7 } from "../cst/plain.js";
|
|
5558
5571
|
function parserUsesRouted(parser2, seen = /* @__PURE__ */ new Set()) {
|
|
5559
5572
|
if (seen.has(parser2)) return false;
|
|
5560
5573
|
seen.add(parser2);
|
|
@@ -5623,6 +5636,7 @@ function asciiFoldKey(key) {
|
|
|
5623
5636
|
}
|
|
5624
5637
|
|
|
5625
5638
|
// src/combinators/node.ts
|
|
5639
|
+
import { PlainNode, PlainSpan as PlainSpan8 } from "../cst/plain.js";
|
|
5626
5640
|
function unwrapChild(child) {
|
|
5627
5641
|
return child !== null && typeof child === "object" && child._tag === "leaf" ? child.value : child;
|
|
5628
5642
|
}
|
|
@@ -5636,6 +5650,9 @@ function projectChild(children2, project, type) {
|
|
|
5636
5650
|
return unwrapChild(children2[project]);
|
|
5637
5651
|
}
|
|
5638
5652
|
|
|
5653
|
+
// src/table/assemble.ts
|
|
5654
|
+
import { PlainBuf as PlainBuf2, PlainField, PlainLeaf as PlainLeaf8, PlainNode as PlainNode2, PlainSpan as PlainSpan9 } from "../cst/plain.js";
|
|
5655
|
+
|
|
5639
5656
|
// src/table/ops.ts
|
|
5640
5657
|
var OP_LIT = 1;
|
|
5641
5658
|
var OP_RX = 2;
|
|
@@ -7370,7 +7387,14 @@ var EMITTED_PARAMS = [
|
|
|
7370
7387
|
"skipDeferredTrivia",
|
|
7371
7388
|
// Appended for the pass-through collapse (`run-support.ts`); old factories
|
|
7372
7389
|
// ignore it.
|
|
7373
|
-
"collapseEmpty"
|
|
7390
|
+
"collapseEmpty",
|
|
7391
|
+
// Appended for constructor-built tree objects (`cst/plain.d.ts`): a `new` call has
|
|
7392
|
+
// no allocation site, so V8 cannot pretenure them. Old factories ignore them.
|
|
7393
|
+
"_SP",
|
|
7394
|
+
"_LF",
|
|
7395
|
+
"_ND",
|
|
7396
|
+
"_FC",
|
|
7397
|
+
"_BUF"
|
|
7374
7398
|
];
|
|
7375
7399
|
var RUNTIME_PRELUDE = `
|
|
7376
7400
|
let _pfScan=null
|
|
@@ -7394,9 +7418,9 @@ if(s!==null)return skipTriviaScanned(s,input,cur,ctx)
|
|
|
7394
7418
|
if(needsDeferredTriviaCommit(ctx))return skipDeferredTrivia(input,cur,ctx)
|
|
7395
7419
|
return advanceTrivia(input,cur,ctx)
|
|
7396
7420
|
}
|
|
7397
|
-
function _pushLeaf(ctx,value,s,e){pushCstLeaf(ctx,
|
|
7421
|
+
function _pushLeaf(ctx,value,s,e){pushCstLeaf(ctx,new _LF(value,new _SP(s,e)))}
|
|
7398
7422
|
function _pushLeafBuf(ctx,value,s,e){
|
|
7399
|
-
const l=
|
|
7423
|
+
const l=new _LF(value,new _SP(s,e))
|
|
7400
7424
|
const b=ctx._cstBuf
|
|
7401
7425
|
if(b.ch!==undefined)b.ch.push(l)
|
|
7402
7426
|
else if(b.single!==undefined){b.ch=[b.single,l];b.single=undefined}
|
|
@@ -7454,7 +7478,7 @@ if(ctx._rootTriviaLog!==undefined&&ctx._rootTriviaLog.length!==rt)ctx._rootTrivi
|
|
|
7454
7478
|
`;
|
|
7455
7479
|
var NO_RAW_RUNTIME_PRELUDE = `
|
|
7456
7480
|
function _pushLeafNoRawBuf(ctx,value,s,e){
|
|
7457
|
-
const l=
|
|
7481
|
+
const l=new _LF(value,new _SP(s,e))
|
|
7458
7482
|
const b=ctx._cstBuf
|
|
7459
7483
|
if(b.ch!==undefined)b.ch.push(l)
|
|
7460
7484
|
else if(b.single!==undefined){b.ch=[b.single,l];b.single=undefined}
|
|
@@ -8131,7 +8155,7 @@ try{return ${child}(input,pos,ctx)}finally{ctx.state=saved}
|
|
|
8131
8155
|
return `${head}
|
|
8132
8156
|
const v=${child}(input,pos,ctx)
|
|
8133
8157
|
if(v===FAIL)return FAIL
|
|
8134
|
-
return ${fn}(v,
|
|
8158
|
+
return ${fn}(v,new _SP(pos,EC.e))
|
|
8135
8159
|
}`;
|
|
8136
8160
|
}
|
|
8137
8161
|
case OP_LABEL: {
|
|
@@ -8152,7 +8176,7 @@ return v
|
|
|
8152
8176
|
const v=${child}(input,pos,ctx)
|
|
8153
8177
|
if(v===FAIL)return FAIL
|
|
8154
8178
|
const f=ctx._fields
|
|
8155
|
-
if(f!==undefined)f.push({name
|
|
8179
|
+
if(f!==undefined)f.push(new _FC(${name},v,new _SP(pos,EC.e)))
|
|
8156
8180
|
return v
|
|
8157
8181
|
}`;
|
|
8158
8182
|
}
|
|
@@ -8177,7 +8201,7 @@ return v
|
|
|
8177
8201
|
return `${head}
|
|
8178
8202
|
const v=${child}(input,pos,ctx)
|
|
8179
8203
|
if(v!==FAIL)return v
|
|
8180
|
-
const err={_tag:'parseError',span:${prog.lines === 1 ? "spanLines(ctx,pos,pos)" : "
|
|
8204
|
+
const err={_tag:'parseError',span:${prog.lines === 1 ? "spanLines(ctx,pos,pos)" : "new _SP(pos,pos)"},expected:${xf}}
|
|
8181
8205
|
const es=ctx._errors
|
|
8182
8206
|
if(es!==undefined)es.push(err)
|
|
8183
8207
|
${REC ? "if(ctx._tolerant===true)captureError(ctx,err)\n" : ""}ctx._fc=false
|
|
@@ -8188,7 +8212,7 @@ return err
|
|
|
8188
8212
|
case OP_ROUTED: {
|
|
8189
8213
|
const fb = code[ip + 1];
|
|
8190
8214
|
const fallback = fb >= 0 ? link(fb) : void 0;
|
|
8191
|
-
const push = `pushCstLeaf(ctx,
|
|
8215
|
+
const push = `pushCstLeaf(ctx,new _LF(it.value,it.span))`;
|
|
8192
8216
|
return `${head}
|
|
8193
8217
|
const it=ctx._routed
|
|
8194
8218
|
if(it===undefined||pos!==it.span.start){
|
|
@@ -8269,8 +8293,8 @@ ctx._triviaLog=sOtl
|
|
|
8269
8293
|
}
|
|
8270
8294
|
if(v===FAIL)return FAIL
|
|
8271
8295
|
const e=EC.e
|
|
8272
|
-
const out=${isToken ? "input.slice(pos,e)" : `${fn}(v,
|
|
8273
|
-
if(wasCap)pushCstLeaf(ctx,{
|
|
8296
|
+
const out=${isToken ? "input.slice(pos,e)" : `${fn}(v,new _SP(pos,e))`}
|
|
8297
|
+
if(wasCap)pushCstLeaf(ctx,new _LF(${capturesSource ? "input.slice(pos,e)" : "out"},new _SP(pos,e)))
|
|
8274
8298
|
EC.e=e
|
|
8275
8299
|
return out
|
|
8276
8300
|
}`;
|
|
@@ -8294,7 +8318,7 @@ ${hasSuffix && (lineFlags & 2) !== 0 ? "if(sm)_trackLines(ctx,input,e)" : ""}
|
|
|
8294
8318
|
${hasSuffix ? `if(!sm){ctx._fe=e;ctx._fx=${suffixExpected};if(ctx._probe!==undefined)failAt(ctx,${suffixExpected},e)}` : ""}
|
|
8295
8319
|
const v=${pending ? "tp?_pfTokValue:" : ""}input.slice(pos,e)
|
|
8296
8320
|
${pending ? "if(tp){_pfTokBody=-1;_pfTokValue=undefined}" : ""}
|
|
8297
|
-
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,
|
|
8321
|
+
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
8298
8322
|
EC.e=e
|
|
8299
8323
|
return v
|
|
8300
8324
|
}`;
|
|
@@ -8333,7 +8357,7 @@ ctx._rootTriviaLog=sRtl
|
|
|
8333
8357
|
}
|
|
8334
8358
|
if(e<0)return FAIL
|
|
8335
8359
|
const v=input.slice(pos,e)
|
|
8336
|
-
if(wasCap)pushCstLeaf(ctx,
|
|
8360
|
+
if(wasCap)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
8337
8361
|
EC.e=e
|
|
8338
8362
|
return v
|
|
8339
8363
|
}`;
|
|
@@ -8341,7 +8365,7 @@ return v
|
|
|
8341
8365
|
const e=${run}(input,pos,ctx)
|
|
8342
8366
|
if(e<0)return FAIL
|
|
8343
8367
|
const v=input.slice(pos,e)
|
|
8344
|
-
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,
|
|
8368
|
+
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
8345
8369
|
EC.e=e
|
|
8346
8370
|
return v
|
|
8347
8371
|
}`;
|
|
@@ -8455,7 +8479,7 @@ return v
|
|
|
8455
8479
|
}` : `${parts.join("\n")}
|
|
8456
8480
|
}`;
|
|
8457
8481
|
if (n === 1) {
|
|
8458
|
-
parts.push(fused ? projection === 0 ? "return v0" : `return ${fn}([v0],
|
|
8482
|
+
parts.push(fused ? projection === 0 ? "return v0" : `return ${fn}([v0],new _SP(pos,EC.e))` : wantValues ? "return [v0]" : "return undefined");
|
|
8459
8483
|
return close();
|
|
8460
8484
|
}
|
|
8461
8485
|
parts.push("let cur=EC.e");
|
|
@@ -8481,7 +8505,7 @@ return v
|
|
|
8481
8505
|
names.push(vn);
|
|
8482
8506
|
}
|
|
8483
8507
|
parts.push("EC.e=cur");
|
|
8484
|
-
parts.push(fused ? projection >= 0 ? `return ${names[projection]}` : `return ${fn}([${names.join(",")}],
|
|
8508
|
+
parts.push(fused ? projection >= 0 ? `return ${names[projection]}` : `return ${fn}([${names.join(",")}],new _SP(pos,cur))` : wantValues ? `return [${names.join(",")}]` : "return undefined");
|
|
8485
8509
|
return close();
|
|
8486
8510
|
}
|
|
8487
8511
|
case OP_CHOICE: {
|
|
@@ -8740,7 +8764,7 @@ ${spec.match.map((m, i) => `${i === 0 ? "" : "else "}if(${dispatchClaim(m)})arm=
|
|
|
8740
8764
|
const routedCall = (target) => `{const savedRouted=ctx._routed
|
|
8741
8765
|
${emitRollback(m1, L.buf, L.raw, sinks)}
|
|
8742
8766
|
${emitMark(m2, L.buf, L.raw, sinks, false)}
|
|
8743
|
-
ctx._routed={value:key,span:
|
|
8767
|
+
ctx._routed={value:key,span:new _SP(pos,selEnd)}
|
|
8744
8768
|
try{v=${target}(input,pos,ctx)}finally{ctx._routed=savedRouted}
|
|
8745
8769
|
break}`;
|
|
8746
8770
|
const plainCall = (target) => `v=${target}(input,selEnd,ctx);break`;
|
|
@@ -8935,8 +8959,8 @@ return out
|
|
|
8935
8959
|
const end=${recognize}(input,pos)
|
|
8936
8960
|
if(end<0){ctx._fe=pos;ctx._fx=${xf};return FAIL}
|
|
8937
8961
|
const value=${value2}
|
|
8938
|
-
const leaf=
|
|
8939
|
-
const kids=[leaf],rawKids=[leaf],span=
|
|
8962
|
+
const leaf=new _LF(value,new _SP(pos,end))
|
|
8963
|
+
const kids=[leaf],rawKids=[leaf],span=new _SP(pos,end)
|
|
8940
8964
|
EC.e=end
|
|
8941
8965
|
const nd=${build2}(kids,undefined,span,rawKids,EMPTY_TL,undefined)
|
|
8942
8966
|
${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))"}
|
|
@@ -9035,7 +9059,7 @@ ctx._cstTriviaLog=sTl
|
|
|
9035
9059
|
ctx.captureTrivia=sCap
|
|
9036
9060
|
if(v===FAIL)return FAIL
|
|
9037
9061
|
const end=EC.e
|
|
9038
|
-
${collapseChildren ? `const nd=captured.length===1?captured[0]:${build}(captured,undefined,
|
|
9062
|
+
${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)`}
|
|
9039
9063
|
${publish}
|
|
9040
9064
|
EC.e=end
|
|
9041
9065
|
return nd
|
|
@@ -9058,20 +9082,20 @@ return nd
|
|
|
9058
9082
|
const direct = `${build}(kids,fieldMap,span,rawKids,${captureWide ? "tlog" : "EMPTY_TL"},st)`;
|
|
9059
9083
|
value = hostCst ? `nd=_pfHost!==undefined?${hostCall}:${direct}` : `nd=${direct}`;
|
|
9060
9084
|
} else {
|
|
9061
|
-
value = `nd=_pfHost!==undefined?_pfHost(${ty},hostKids,fieldMap,span,rawKids,tlog,st,${tags}):{
|
|
9085
|
+
value = `nd=_pfHost!==undefined?_pfHost(${ty},hostKids,fieldMap,span,rawKids,tlog,st,${tags}):new _ND(${ty},span,st??null,kids===EMPTY_CH?kids:[...kids])`;
|
|
9062
9086
|
}
|
|
9063
9087
|
const collapsible = keepChildren && (hostCst || build === void 0 && proj < 0);
|
|
9064
|
-
const openCapture = omitsRaw ? `const buf=
|
|
9088
|
+
const openCapture = omitsRaw ? `const buf=new _BUF(undefined,true,0)
|
|
9065
9089
|
ctx._cstBuf=buf
|
|
9066
9090
|
ctx._cstChildren=undefined
|
|
9067
9091
|
ctx._cstLeaves=undefined
|
|
9068
9092
|
ctx._cstRawChildren=undefined
|
|
9069
|
-
ctx._cstTriviaLog=undefined` : keepChildren ? `const buf=
|
|
9093
|
+
ctx._cstTriviaLog=undefined` : keepChildren ? `const buf=new _BUF(undefined,undefined,0)
|
|
9070
9094
|
ctx._cstBuf=buf
|
|
9071
9095
|
ctx._cstChildren=undefined
|
|
9072
9096
|
ctx._cstLeaves=undefined
|
|
9073
9097
|
ctx._cstRawChildren=undefined
|
|
9074
|
-
ctx._cstTriviaLog=undefined` : `const buf=
|
|
9098
|
+
ctx._cstTriviaLog=undefined` : `const buf=new _BUF(true,undefined,0)
|
|
9075
9099
|
ctx._cstBuf=buf
|
|
9076
9100
|
ctx._cstChildren=undefined
|
|
9077
9101
|
ctx._cstLeaves=undefined
|
|
@@ -9109,7 +9133,7 @@ ctx._cstTriviaLog=sTl
|
|
|
9109
9133
|
ctx.captureTrivia=sCap
|
|
9110
9134
|
if(v===FAIL)return FAIL
|
|
9111
9135
|
const end=EC.e
|
|
9112
|
-
const span=${tracked ? "spanLines(ctx,pos,end)" : "
|
|
9136
|
+
const span=${tracked ? "spanLines(ctx,pos,end)" : "new _SP(pos,end)"}
|
|
9113
9137
|
const st=${readsState ? "ctx.state" : "undefined"}
|
|
9114
9138
|
let nd
|
|
9115
9139
|
${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]
|
|
@@ -9547,7 +9571,7 @@ function assemble(t, prog, cfg) {
|
|
|
9547
9571
|
const NULLABLE = /* @__PURE__ */ new Map();
|
|
9548
9572
|
const CLEAN = REC ? () => false : failCleanAnalysis(code);
|
|
9549
9573
|
function pushLeaf(ctx, value, s, e) {
|
|
9550
|
-
const lf =
|
|
9574
|
+
const lf = new PlainLeaf8(value, new PlainSpan9(s, e));
|
|
9551
9575
|
pushCstLeaf(ctx, lf);
|
|
9552
9576
|
}
|
|
9553
9577
|
function plainBuildNode(child, build, trailing) {
|
|
@@ -9580,7 +9604,7 @@ function assemble(t, prog, cfg) {
|
|
|
9580
9604
|
ctx.captureTrivia = sCap;
|
|
9581
9605
|
if (value === FAIL) return FAIL;
|
|
9582
9606
|
const end = EC.e;
|
|
9583
|
-
const span =
|
|
9607
|
+
const span = new PlainSpan9(pos, end);
|
|
9584
9608
|
const node = build(kids, void 0, span, rawKids, EMPTY_TL, void 0);
|
|
9585
9609
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
9586
9610
|
pushCstChild(ctx, node, rawEntry(node, input, pos, end));
|
|
@@ -9625,7 +9649,7 @@ function assemble(t, prog, cfg) {
|
|
|
9625
9649
|
ctx.captureTrivia = sCap;
|
|
9626
9650
|
if (value === FAIL) return FAIL;
|
|
9627
9651
|
const end = EC.e;
|
|
9628
|
-
const node = build(captured, void 0,
|
|
9652
|
+
const node = build(captured, void 0, new PlainSpan9(pos, end), EMPTY_CH, EMPTY_TL, void 0);
|
|
9629
9653
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
9630
9654
|
pushCstChild(ctx, node, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node, input, pos, end) : void 0);
|
|
9631
9655
|
}
|
|
@@ -9662,7 +9686,7 @@ function assemble(t, prog, cfg) {
|
|
|
9662
9686
|
ctx.captureTrivia = sCap;
|
|
9663
9687
|
if (value === FAIL) return FAIL;
|
|
9664
9688
|
const end = EC.e;
|
|
9665
|
-
const node = build(captured, fieldMap,
|
|
9689
|
+
const node = build(captured, fieldMap, new PlainSpan9(pos, end), EMPTY_CH, EMPTY_TL, void 0);
|
|
9666
9690
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
9667
9691
|
pushCstChild(ctx, node, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node, input, pos, end) : void 0);
|
|
9668
9692
|
}
|
|
@@ -9699,7 +9723,7 @@ function assemble(t, prog, cfg) {
|
|
|
9699
9723
|
ctx.captureTrivia = sCap;
|
|
9700
9724
|
if (value === FAIL) return FAIL;
|
|
9701
9725
|
const end = EC.e;
|
|
9702
|
-
const span =
|
|
9726
|
+
const span = new PlainSpan9(pos, end);
|
|
9703
9727
|
const node = kids.length === 1 ? kids[0] : build(kids, void 0, span, rawKids, EMPTY_TL, void 0);
|
|
9704
9728
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
9705
9729
|
pushCstChild(ctx, node, rawEntry(node, input, pos, end));
|
|
@@ -9736,7 +9760,7 @@ function assemble(t, prog, cfg) {
|
|
|
9736
9760
|
ctx.captureTrivia = sCap;
|
|
9737
9761
|
if (value === FAIL) return FAIL;
|
|
9738
9762
|
const end = EC.e;
|
|
9739
|
-
const node = captured.length === 1 ? captured[0] : build(captured, void 0,
|
|
9763
|
+
const node = captured.length === 1 ? captured[0] : build(captured, void 0, new PlainSpan9(pos, end), EMPTY_CH, EMPTY_TL, void 0);
|
|
9740
9764
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
9741
9765
|
pushCstChild(ctx, node, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node, input, pos, end) : void 0);
|
|
9742
9766
|
}
|
|
@@ -10169,7 +10193,7 @@ function assemble(t, prog, cfg) {
|
|
|
10169
10193
|
return (input, pos, selEnd, key, ctx, need, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot) => {
|
|
10170
10194
|
const savedRouted = ctx._routed;
|
|
10171
10195
|
if (need) rollbackTriviaAt(ctx, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot);
|
|
10172
|
-
ctx._routed = { value: key, span:
|
|
10196
|
+
ctx._routed = { value: key, span: new PlainSpan9(pos, selEnd) };
|
|
10173
10197
|
let v;
|
|
10174
10198
|
try {
|
|
10175
10199
|
v = child(input, pos, ctx);
|
|
@@ -10602,7 +10626,7 @@ function assemble(t, prog, cfg) {
|
|
|
10602
10626
|
case OP_EXPECT: {
|
|
10603
10627
|
const child = link(code[ip + 1]);
|
|
10604
10628
|
const xf = fx[code[ip + 2]];
|
|
10605
|
-
const expectSpan = (ctx, pos) => prog.lines === 1 ? spanLines(ctx, pos, pos) :
|
|
10629
|
+
const expectSpan = (ctx, pos) => prog.lines === 1 ? spanLines(ctx, pos, pos) : new PlainSpan9(pos, pos);
|
|
10606
10630
|
if (REC) {
|
|
10607
10631
|
return (input, pos, ctx) => {
|
|
10608
10632
|
const v = child(input, pos, ctx);
|
|
@@ -10634,7 +10658,7 @@ function assemble(t, prog, cfg) {
|
|
|
10634
10658
|
return (input, pos, ctx) => {
|
|
10635
10659
|
const v = child(input, pos, ctx);
|
|
10636
10660
|
if (v === FAIL) return FAIL;
|
|
10637
|
-
ctx._fields?.push(
|
|
10661
|
+
ctx._fields?.push(new PlainField(name, v, new PlainSpan9(pos, EC.e)));
|
|
10638
10662
|
return v;
|
|
10639
10663
|
};
|
|
10640
10664
|
}
|
|
@@ -10658,7 +10682,7 @@ function assemble(t, prog, cfg) {
|
|
|
10658
10682
|
return (input, pos, ctx) => {
|
|
10659
10683
|
const v = child(input, pos, ctx);
|
|
10660
10684
|
if (v === FAIL) return FAIL;
|
|
10661
|
-
return fn(v,
|
|
10685
|
+
return fn(v, new PlainSpan9(pos, EC.e));
|
|
10662
10686
|
};
|
|
10663
10687
|
}
|
|
10664
10688
|
case OP_SCAN: {
|
|
@@ -10762,7 +10786,7 @@ function assemble(t, prog, cfg) {
|
|
|
10762
10786
|
ctx._fx = ROUTED_FX;
|
|
10763
10787
|
return FAIL;
|
|
10764
10788
|
}
|
|
10765
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
10789
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf8(item.value, item.span));
|
|
10766
10790
|
EC.e = item.span.end;
|
|
10767
10791
|
return item.value;
|
|
10768
10792
|
};
|
|
@@ -10948,7 +10972,7 @@ function assemble(t, prog, cfg) {
|
|
|
10948
10972
|
if (v === FAIL) return FAIL;
|
|
10949
10973
|
const end = EC.e;
|
|
10950
10974
|
const value = input.slice(pos, end);
|
|
10951
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
10975
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf8(value, new PlainSpan9(pos, end)));
|
|
10952
10976
|
EC.e = end;
|
|
10953
10977
|
return value;
|
|
10954
10978
|
};
|
|
@@ -10982,7 +11006,7 @@ function assemble(t, prog, cfg) {
|
|
|
10982
11006
|
if (ctx._probe !== void 0) failAt(ctx, suffixExpected, end);
|
|
10983
11007
|
}
|
|
10984
11008
|
const value = input.slice(pos, end);
|
|
10985
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
11009
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf8(value, new PlainSpan9(pos, end)));
|
|
10986
11010
|
EC.e = end;
|
|
10987
11011
|
return value;
|
|
10988
11012
|
};
|
|
@@ -11025,7 +11049,7 @@ function assemble(t, prog, cfg) {
|
|
|
11025
11049
|
}
|
|
11026
11050
|
if (end < 0) return FAIL;
|
|
11027
11051
|
const value = input.slice(pos, end);
|
|
11028
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
11052
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf8(value, new PlainSpan9(pos, end)));
|
|
11029
11053
|
EC.e = end;
|
|
11030
11054
|
return value;
|
|
11031
11055
|
};
|
|
@@ -11034,7 +11058,7 @@ function assemble(t, prog, cfg) {
|
|
|
11034
11058
|
const end = run(input, pos, ctx);
|
|
11035
11059
|
if (end < 0) return FAIL;
|
|
11036
11060
|
const value = input.slice(pos, end);
|
|
11037
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
11061
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf8(value, new PlainSpan9(pos, end)));
|
|
11038
11062
|
EC.e = end;
|
|
11039
11063
|
return value;
|
|
11040
11064
|
};
|
|
@@ -11067,12 +11091,8 @@ function assemble(t, prog, cfg) {
|
|
|
11067
11091
|
}
|
|
11068
11092
|
if (v === FAIL) return FAIL;
|
|
11069
11093
|
const end = EC.e;
|
|
11070
|
-
const out = fn(v,
|
|
11071
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
11072
|
-
_tag: "leaf",
|
|
11073
|
-
value: op === OP_SOURCE_LEAF && hostCst ? input.slice(pos, end) : out,
|
|
11074
|
-
span: { start: pos, end }
|
|
11075
|
-
});
|
|
11094
|
+
const out = fn(v, new PlainSpan9(pos, end));
|
|
11095
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf8(op === OP_SOURCE_LEAF && hostCst ? input.slice(pos, end) : out, new PlainSpan9(pos, end)));
|
|
11076
11096
|
EC.e = end;
|
|
11077
11097
|
return out;
|
|
11078
11098
|
};
|
|
@@ -11207,7 +11227,7 @@ function assemble(t, prog, cfg) {
|
|
|
11207
11227
|
const cur = runSyncTerms(input, pos, ctx, values);
|
|
11208
11228
|
if (cur < 0) return FAIL;
|
|
11209
11229
|
EC.e = cur;
|
|
11210
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
11230
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan9(pos, cur));
|
|
11211
11231
|
};
|
|
11212
11232
|
}
|
|
11213
11233
|
if (wantValues) {
|
|
@@ -11301,7 +11321,7 @@ function assemble(t, prog, cfg) {
|
|
|
11301
11321
|
const cur = runAdjTerms(input, pos, ctx, values);
|
|
11302
11322
|
if (cur < 0) return FAIL;
|
|
11303
11323
|
EC.e = cur;
|
|
11304
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
11324
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan9(pos, cur));
|
|
11305
11325
|
};
|
|
11306
11326
|
}
|
|
11307
11327
|
if (wantValues) {
|
|
@@ -11326,7 +11346,7 @@ function assemble(t, prog, cfg) {
|
|
|
11326
11346
|
return (input, pos, ctx) => {
|
|
11327
11347
|
const v = k0(input, pos, ctx);
|
|
11328
11348
|
if (v === FAIL) return FAIL;
|
|
11329
|
-
return projection === 0 ? v : fn([v],
|
|
11349
|
+
return projection === 0 ? v : fn([v], new PlainSpan9(pos, EC.e));
|
|
11330
11350
|
};
|
|
11331
11351
|
}
|
|
11332
11352
|
if (wantValues) {
|
|
@@ -11351,7 +11371,7 @@ function assemble(t, prog, cfg) {
|
|
|
11351
11371
|
const cur = step(k1, input, EC.e, ctx);
|
|
11352
11372
|
if (cur < 0) return FAIL;
|
|
11353
11373
|
EC.e = cur;
|
|
11354
|
-
return projection === 0 ? v0 : projection === 1 ? TERMV : fn([v0, TERMV],
|
|
11374
|
+
return projection === 0 ? v0 : projection === 1 ? TERMV : fn([v0, TERMV], new PlainSpan9(pos, cur));
|
|
11355
11375
|
};
|
|
11356
11376
|
}
|
|
11357
11377
|
if (wantValues) {
|
|
@@ -11385,7 +11405,7 @@ function assemble(t, prog, cfg) {
|
|
|
11385
11405
|
cur = step(k2, input, cur, ctx);
|
|
11386
11406
|
if (cur < 0) return FAIL;
|
|
11387
11407
|
EC.e = cur;
|
|
11388
|
-
return projection === 0 ? v0 : projection === 1 ? v1 : projection === 2 ? TERMV : fn([v0, v1, TERMV],
|
|
11408
|
+
return projection === 0 ? v0 : projection === 1 ? v1 : projection === 2 ? TERMV : fn([v0, v1, TERMV], new PlainSpan9(pos, cur));
|
|
11389
11409
|
};
|
|
11390
11410
|
}
|
|
11391
11411
|
if (wantValues) {
|
|
@@ -11482,7 +11502,7 @@ function assemble(t, prog, cfg) {
|
|
|
11482
11502
|
const cur = runDirectTerms(input, pos, ctx, values);
|
|
11483
11503
|
if (cur < 0) return FAIL;
|
|
11484
11504
|
EC.e = cur;
|
|
11485
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
11505
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan9(pos, cur));
|
|
11486
11506
|
};
|
|
11487
11507
|
}
|
|
11488
11508
|
if (wantValues) {
|
|
@@ -12380,10 +12400,10 @@ function assemble(t, prog, cfg) {
|
|
|
12380
12400
|
return FAIL;
|
|
12381
12401
|
}
|
|
12382
12402
|
const value = regexValue ? input.slice(pos, end) : spec;
|
|
12383
|
-
const leaf2 =
|
|
12403
|
+
const leaf2 = new PlainLeaf8(value, new PlainSpan9(pos, end));
|
|
12384
12404
|
const kids = [leaf2];
|
|
12385
12405
|
const rawKids = [leaf2];
|
|
12386
|
-
const span =
|
|
12406
|
+
const span = new PlainSpan9(pos, end);
|
|
12387
12407
|
EC.e = end;
|
|
12388
12408
|
const nd = build2(kids, void 0, span, rawKids, EMPTY_TL, void 0);
|
|
12389
12409
|
if (ctx._cstBuf !== void 0 || ctx._cstChildren !== void 0) {
|
|
@@ -12465,7 +12485,7 @@ function assemble(t, prog, cfg) {
|
|
|
12465
12485
|
const sCh = ctx._cstChildren;
|
|
12466
12486
|
const sCap = ctx.captureTrivia;
|
|
12467
12487
|
const sBuf = ctx._cstBuf;
|
|
12468
|
-
const buf = rawOnly ?
|
|
12488
|
+
const buf = rawOnly ? new PlainBuf2(true, void 0, 0) : omitsRaw ? new PlainBuf2(void 0, true, 0) : new PlainBuf2(void 0, void 0, 0);
|
|
12469
12489
|
ctx._cstBuf = buf;
|
|
12470
12490
|
ctx.captureTrivia = captureWide;
|
|
12471
12491
|
const savedFields = ctx._fields;
|
|
@@ -12487,7 +12507,7 @@ function assemble(t, prog, cfg) {
|
|
|
12487
12507
|
ctx.captureTrivia = sCap;
|
|
12488
12508
|
if (v === FAIL) return FAIL;
|
|
12489
12509
|
const end = EC.e;
|
|
12490
|
-
const span = tracked ? spanLines(ctx, pos, end) :
|
|
12510
|
+
const span = tracked ? spanLines(ctx, pos, end) : new PlainSpan9(pos, end);
|
|
12491
12511
|
const st = readsState ? ctx.state : void 0;
|
|
12492
12512
|
let nd;
|
|
12493
12513
|
if (unwrap && kids.length === 1) {
|
|
@@ -12511,7 +12531,7 @@ function assemble(t, prog, cfg) {
|
|
|
12511
12531
|
} else if (host !== void 0) {
|
|
12512
12532
|
nd = host(type, hostKids, fieldMap, span, rawKids, tlog, st, tags);
|
|
12513
12533
|
} else {
|
|
12514
|
-
nd =
|
|
12534
|
+
nd = new PlainNode2(type, span, st ?? null, kids === EMPTY_CH ? kids : [...kids]);
|
|
12515
12535
|
}
|
|
12516
12536
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
12517
12537
|
pushCstChild(ctx, nd, rawEntry(nd, input, pos, end));
|
|
@@ -12537,7 +12557,7 @@ function assemble(t, prog, cfg) {
|
|
|
12537
12557
|
const at = fe === void 0 || fe < 0 ? pos : fe;
|
|
12538
12558
|
return { ok: false, expected: ctx._fx ?? EMPTY_FX2, span: { start: at, end: at } };
|
|
12539
12559
|
}
|
|
12540
|
-
return { ok: true, value: v, span:
|
|
12560
|
+
return { ok: true, value: v, span: new PlainSpan9(pos, EC.e) };
|
|
12541
12561
|
}
|
|
12542
12562
|
};
|
|
12543
12563
|
}
|
|
@@ -12652,7 +12672,12 @@ function assemble(t, prog, cfg) {
|
|
|
12652
12672
|
LEAD,
|
|
12653
12673
|
triviaFieldCapture,
|
|
12654
12674
|
skipDeferredTrivia,
|
|
12655
|
-
collapseEmpty
|
|
12675
|
+
collapseEmpty,
|
|
12676
|
+
PlainSpan9,
|
|
12677
|
+
PlainLeaf8,
|
|
12678
|
+
PlainNode2,
|
|
12679
|
+
PlainField,
|
|
12680
|
+
PlainBuf2
|
|
12656
12681
|
);
|
|
12657
12682
|
emitReached = new Set(pre.reached);
|
|
12658
12683
|
if (emitted.ext !== void 0) HYBRID = emitted;
|
|
@@ -12739,7 +12764,12 @@ function assemble(t, prog, cfg) {
|
|
|
12739
12764
|
LEAD,
|
|
12740
12765
|
triviaFieldCapture,
|
|
12741
12766
|
skipDeferredTrivia,
|
|
12742
|
-
collapseEmpty
|
|
12767
|
+
collapseEmpty,
|
|
12768
|
+
PlainSpan9,
|
|
12769
|
+
PlainLeaf8,
|
|
12770
|
+
PlainNode2,
|
|
12771
|
+
PlainField,
|
|
12772
|
+
PlainBuf2
|
|
12743
12773
|
);
|
|
12744
12774
|
emitReached = em.reached;
|
|
12745
12775
|
} catch (e) {
|
|
@@ -13767,6 +13797,7 @@ import {
|
|
|
13767
13797
|
} from "../compiler/token-capability.js";
|
|
13768
13798
|
|
|
13769
13799
|
// src/combinators/keywords.ts
|
|
13800
|
+
import { PlainLeaf as PlainLeaf9, PlainSpan as PlainSpan10 } from "../cst/plain.js";
|
|
13770
13801
|
function escapeRe(s) {
|
|
13771
13802
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
13772
13803
|
}
|
|
@@ -15531,7 +15562,11 @@ function encodeTableProgram(ruleMap, settings = {}) {
|
|
|
15531
15562
|
return { prog, fnSrcs: enc.fnSrcs };
|
|
15532
15563
|
}
|
|
15533
15564
|
|
|
15565
|
+
// src/version.ts
|
|
15566
|
+
var PARSEMAN_VERSION = "0.59.0";
|
|
15567
|
+
|
|
15534
15568
|
// src/table/emit.ts
|
|
15569
|
+
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`)});`;
|
|
15535
15570
|
function jsString(s) {
|
|
15536
15571
|
return JSON.stringify(s);
|
|
15537
15572
|
}
|
|
@@ -15617,7 +15652,7 @@ function emitAssemblies(prog, cfgs) {
|
|
|
15617
15652
|
throw e;
|
|
15618
15653
|
}
|
|
15619
15654
|
const plan = em.plan;
|
|
15620
|
-
out.push(`{key:${key},factory:function(${EMITTED_PARAMS.join(",")}){${em.source}
|
|
15655
|
+
out.push(`{key:${key},factory:function(${EMITTED_PARAMS.join(",")}){${FACTORY_ARITY_GUARD}${em.source}
|
|
15621
15656
|
},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(",")}]}`);
|
|
15622
15657
|
}
|
|
15623
15658
|
return [`a:[${out.join(",")}],`];
|