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
package/dist/plugin/index.js
CHANGED
|
@@ -569,6 +569,7 @@ function markUnusedValues(root) {
|
|
|
569
569
|
}
|
|
570
570
|
|
|
571
571
|
// src/line-index.ts
|
|
572
|
+
import { PlainLineSpan, PlainSpan } from "../cst/plain.js";
|
|
572
573
|
function createLineIndex() {
|
|
573
574
|
return { lineStarts: [0] };
|
|
574
575
|
}
|
|
@@ -621,6 +622,27 @@ function annotateSpan(span, index) {
|
|
|
621
622
|
endColumn: e.col
|
|
622
623
|
};
|
|
623
624
|
}
|
|
625
|
+
var SPAN_KEYS = ["start", "end", "startLine", "startColumn", "endLine", "endColumn"];
|
|
626
|
+
function copySpan(span) {
|
|
627
|
+
let n = 0;
|
|
628
|
+
for (const key in span) {
|
|
629
|
+
if (key !== SPAN_KEYS[n]) return { ...span };
|
|
630
|
+
n++;
|
|
631
|
+
}
|
|
632
|
+
if (n === 2) return new PlainSpan(span.start, span.end);
|
|
633
|
+
if (n === 6 && span.startLine !== void 0 && span.startColumn !== void 0 && span.endLine !== void 0 && span.endColumn !== void 0) {
|
|
634
|
+
return new PlainLineSpan(span.start, span.end, span.startLine, span.startColumn, span.endLine, span.endColumn);
|
|
635
|
+
}
|
|
636
|
+
return { ...span };
|
|
637
|
+
}
|
|
638
|
+
function lineSpanFromContext(span, ctx) {
|
|
639
|
+
if (!ctx.trackLines) return span;
|
|
640
|
+
const index = ctx._lineIndex ?? (ctx._lineStarts ? { lineStarts: ctx._lineStarts } : void 0);
|
|
641
|
+
if (!index) return span;
|
|
642
|
+
const s = offsetToLineCol(index, span.start);
|
|
643
|
+
const e = offsetToLineCol(index, span.end);
|
|
644
|
+
return new PlainLineSpan(span.start, span.end, s.line, s.col, e.line, e.col);
|
|
645
|
+
}
|
|
624
646
|
function annotateSpanFromLineContext(span, ctx) {
|
|
625
647
|
if (!ctx.trackLines) return span;
|
|
626
648
|
const index = ctx._lineIndex ?? (ctx._lineStarts ? { lineStarts: ctx._lineStarts } : void 0);
|
|
@@ -628,6 +650,7 @@ function annotateSpanFromLineContext(span, ctx) {
|
|
|
628
650
|
}
|
|
629
651
|
|
|
630
652
|
// src/cst/capture-buffer.ts
|
|
653
|
+
import { PlainBuf, PlainLeaf } from "../cst/plain.js";
|
|
631
654
|
var EMPTY = [];
|
|
632
655
|
var EMPTY_TL = [];
|
|
633
656
|
function cstCaptureActive(ctx) {
|
|
@@ -642,7 +665,7 @@ function beginCstNodeCapture(ctx) {
|
|
|
642
665
|
cap: ctx.captureTrivia,
|
|
643
666
|
buf: ctx._cstBuf
|
|
644
667
|
};
|
|
645
|
-
ctx._cstBuf =
|
|
668
|
+
ctx._cstBuf = new PlainBuf(void 0, void 0, 0);
|
|
646
669
|
ctx._cstChildren = void 0;
|
|
647
670
|
ctx._cstLeaves = void 0;
|
|
648
671
|
ctx._cstRawChildren = void 0;
|
|
@@ -667,12 +690,15 @@ function endCstNodeCapture(ctx, saved) {
|
|
|
667
690
|
ctx.captureTrivia = saved.cap;
|
|
668
691
|
return materialized;
|
|
669
692
|
}
|
|
693
|
+
function isLeaf(v) {
|
|
694
|
+
return typeof v === "object" && v !== null && v._tag === "leaf";
|
|
695
|
+
}
|
|
670
696
|
function pushCstLeaf(ctx, leaf2) {
|
|
671
697
|
if (!ctx.trackLines) {
|
|
672
698
|
pushCstChild(ctx, leaf2, leaf2);
|
|
673
699
|
return;
|
|
674
700
|
}
|
|
675
|
-
const annotated = leaf2 && typeof leaf2 === "object" && leaf2.span ? { ...leaf2, span: annotateSpanFromLineContext(leaf2.span, ctx) } : leaf2;
|
|
701
|
+
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;
|
|
676
702
|
pushCstChild(ctx, annotated, annotated);
|
|
677
703
|
}
|
|
678
704
|
function pushCstChild(ctx, built, rawEntry2) {
|
|
@@ -2024,6 +2050,7 @@ function assertionFailureExpected(positive, childTag) {
|
|
|
2024
2050
|
}
|
|
2025
2051
|
|
|
2026
2052
|
// src/combinators/literal.ts
|
|
2053
|
+
import { PlainLeaf as PlainLeaf2, PlainSpan as PlainSpan2 } from "../cst/plain.js";
|
|
2027
2054
|
function asciiFoldEq(a, b) {
|
|
2028
2055
|
if (a.length !== b.length) return false;
|
|
2029
2056
|
for (let i = 0; i < a.length; i++) {
|
|
@@ -2081,9 +2108,9 @@ function literal(value, opts = {}) {
|
|
|
2081
2108
|
const code = value.charCodeAt(0);
|
|
2082
2109
|
return function parse3(input, pos, ctx) {
|
|
2083
2110
|
if (input.charCodeAt(pos) === code) {
|
|
2084
|
-
const span =
|
|
2111
|
+
const span = new PlainSpan2(pos, pos + 1);
|
|
2085
2112
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, span.end);
|
|
2086
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
2113
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf2(value, span));
|
|
2087
2114
|
return { ok: true, value, span };
|
|
2088
2115
|
}
|
|
2089
2116
|
return failAt(ctx, expected, pos);
|
|
@@ -2095,9 +2122,9 @@ function literal(value, opts = {}) {
|
|
|
2095
2122
|
}
|
|
2096
2123
|
const matchedValue = caseInsensitive ? input.slice(pos, end) : value;
|
|
2097
2124
|
if (caseInsensitive ? asciiFoldEq(matchedValue, value) : input.startsWith(value, pos)) {
|
|
2098
|
-
const span =
|
|
2125
|
+
const span = new PlainSpan2(pos, end);
|
|
2099
2126
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, end);
|
|
2100
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
2127
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf2(matchedValue, span));
|
|
2101
2128
|
return { ok: true, value: matchedValue, span };
|
|
2102
2129
|
}
|
|
2103
2130
|
return failAt(ctx, expected, pos);
|
|
@@ -2432,6 +2459,7 @@ function firstSetFromRegex(source, flags = "") {
|
|
|
2432
2459
|
}
|
|
2433
2460
|
|
|
2434
2461
|
// src/combinators/regex.ts
|
|
2462
|
+
import { PlainLeaf as PlainLeaf3, PlainSpan as PlainSpan3 } from "../cst/plain.js";
|
|
2435
2463
|
var SCAN_BAIL_AT = 64;
|
|
2436
2464
|
function inRanges2(cp, ranges) {
|
|
2437
2465
|
for (let i = 0; i < ranges.length; i++) {
|
|
@@ -2544,9 +2572,9 @@ function regex(pattern, flags = "") {
|
|
|
2544
2572
|
if (scanEnd !== void 0) {
|
|
2545
2573
|
if (scanEnd === null) return failAt(ctx, directTerminalFailureExpected(def), pos);
|
|
2546
2574
|
const value = input.slice(pos, scanEnd);
|
|
2547
|
-
const span2 =
|
|
2575
|
+
const span2 = new PlainSpan3(pos, scanEnd);
|
|
2548
2576
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, scanEnd);
|
|
2549
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
2577
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf3(value, span2));
|
|
2550
2578
|
return { ok: true, value, span: span2 };
|
|
2551
2579
|
}
|
|
2552
2580
|
anchored.lastIndex = pos;
|
|
@@ -2554,9 +2582,9 @@ function regex(pattern, flags = "") {
|
|
|
2554
2582
|
if (m === null) {
|
|
2555
2583
|
return failAt(ctx, directTerminalFailureExpected(def), pos);
|
|
2556
2584
|
}
|
|
2557
|
-
const span =
|
|
2585
|
+
const span = new PlainSpan3(pos, pos + m[0].length);
|
|
2558
2586
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, span.end);
|
|
2559
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
2587
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf3(m[0], span));
|
|
2560
2588
|
return { ok: true, value: m[0], span };
|
|
2561
2589
|
}
|
|
2562
2590
|
};
|
|
@@ -2598,6 +2626,7 @@ function caseFoldVariants(cp) {
|
|
|
2598
2626
|
}
|
|
2599
2627
|
|
|
2600
2628
|
// src/combinators/keywords.ts
|
|
2629
|
+
import { PlainLeaf as PlainLeaf4, PlainSpan as PlainSpan4 } from "../cst/plain.js";
|
|
2601
2630
|
function word(str, boundaryOrOpts, opts) {
|
|
2602
2631
|
const boundary = typeof boundaryOrOpts === "string" ? boundaryOrOpts : "_0-9A-Za-z";
|
|
2603
2632
|
const rest = typeof boundaryOrOpts === "object" && boundaryOrOpts !== null ? boundaryOrOpts : opts;
|
|
@@ -2651,8 +2680,8 @@ function keywords(words, opts = {}) {
|
|
|
2651
2680
|
const m = re.exec(input);
|
|
2652
2681
|
if (m === null) return failAt(ctx, directTerminalFailureExpected(def), pos);
|
|
2653
2682
|
const value = m[0];
|
|
2654
|
-
const span =
|
|
2655
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
2683
|
+
const span = new PlainSpan4(pos, pos + value.length);
|
|
2684
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf4(value, span));
|
|
2656
2685
|
return { ok: true, value, span };
|
|
2657
2686
|
}
|
|
2658
2687
|
};
|
|
@@ -3277,6 +3306,7 @@ function altStarSource(source) {
|
|
|
3277
3306
|
}
|
|
3278
3307
|
|
|
3279
3308
|
// src/recovery/scan.ts
|
|
3309
|
+
import { PlainSpan as PlainSpan5 } from "../cst/plain.js";
|
|
3280
3310
|
function probeAt(sentinel, input, pos, ctx) {
|
|
3281
3311
|
const s = {
|
|
3282
3312
|
_probe: ctx._probe,
|
|
@@ -3353,7 +3383,7 @@ function firstSetSentinel(fs3) {
|
|
|
3353
3383
|
function recoverScan(input, from, ctx, sync, expected) {
|
|
3354
3384
|
let scanPos = from;
|
|
3355
3385
|
while (scanPos < input.length && !probeAt(sync, input, scanPos, ctx)) scanPos++;
|
|
3356
|
-
const span =
|
|
3386
|
+
const span = new PlainSpan5(from, scanPos);
|
|
3357
3387
|
if (ctx.trackLines) recordLineRangeFromContext(ctx, input, from, scanPos);
|
|
3358
3388
|
const error = { _tag: "parseError", span: ctx.trackLines ? annotateSpanFromLineContext(span, ctx) : span, expected };
|
|
3359
3389
|
ctx._errors?.push(error);
|
|
@@ -3433,17 +3463,18 @@ function notAdjacent(options) {
|
|
|
3433
3463
|
}
|
|
3434
3464
|
|
|
3435
3465
|
// src/combinators/field-trivia.ts
|
|
3466
|
+
import { PlainSpan as PlainSpan6, PlainTriviaField } from "../cst/plain.js";
|
|
3436
3467
|
var LEAD = { at: -1 };
|
|
3437
3468
|
var FIELD_LEADING_TRIVIA = 1;
|
|
3438
3469
|
var FIELD_TRAILING_TRIVIA = 2;
|
|
3439
3470
|
function triviaFieldCapture(name, value, input, start, end, leadFrom, trailEnd) {
|
|
3440
|
-
return
|
|
3471
|
+
return new PlainTriviaField(
|
|
3441
3472
|
name,
|
|
3442
3473
|
value,
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3474
|
+
new PlainSpan6(start, end),
|
|
3475
|
+
leadFrom >= 0 && leadFrom < start ? input.slice(leadFrom, start) : "",
|
|
3476
|
+
trailEnd > end ? input.slice(end, trailEnd) : ""
|
|
3477
|
+
);
|
|
3447
3478
|
}
|
|
3448
3479
|
function leadsTrivia(p) {
|
|
3449
3480
|
return p._def.tag === "field" && p._def.leadingTrivia === true;
|
|
@@ -4022,6 +4053,7 @@ function buildAsciiDispatch(parsers) {
|
|
|
4022
4053
|
}
|
|
4023
4054
|
|
|
4024
4055
|
// src/combinators/dispatch.ts
|
|
4056
|
+
import { PlainLeaf as PlainLeaf5 } from "../cst/plain.js";
|
|
4025
4057
|
function parserUsesRouted(parser2, seen = /* @__PURE__ */ new Set()) {
|
|
4026
4058
|
if (seen.has(parser2)) return false;
|
|
4027
4059
|
seen.add(parser2);
|
|
@@ -4158,7 +4190,7 @@ function routed(fallback2) {
|
|
|
4158
4190
|
return { ok: false, expected: ["routed()"], span: { start: pos, end: pos } };
|
|
4159
4191
|
}
|
|
4160
4192
|
if (cstCaptureActive(ctx)) {
|
|
4161
|
-
pushCstLeaf(ctx,
|
|
4193
|
+
pushCstLeaf(ctx, new PlainLeaf5(item.value, item.span));
|
|
4162
4194
|
}
|
|
4163
4195
|
return { ok: true, value: item.value, span: item.span };
|
|
4164
4196
|
}
|
|
@@ -5108,6 +5140,7 @@ function buildFieldMap(captures) {
|
|
|
5108
5140
|
}
|
|
5109
5141
|
|
|
5110
5142
|
// src/combinators/node.ts
|
|
5143
|
+
import { PlainNode, PlainSpan as PlainSpan7 } from "../cst/plain.js";
|
|
5111
5144
|
function unwrapChild(child) {
|
|
5112
5145
|
return child !== null && typeof child === "object" && child._tag === "leaf" ? child.value : child;
|
|
5113
5146
|
}
|
|
@@ -5213,7 +5246,7 @@ function node(typeOrCombinator, combinatorOrBuild, buildOrOpts, maybeOpts) {
|
|
|
5213
5246
|
const nodeType = def.type ?? missingInferredType();
|
|
5214
5247
|
const cstOutput = cstOutputHost(ctx.build);
|
|
5215
5248
|
const span = ctx.trackLines ? annotateSpanFromLineContext(r.span, ctx) : r.span;
|
|
5216
|
-
const built = unwrap && children3.length === 1 ? unwrapChild(children3[0]) : collapse && children3.length === 1 ? children3[0] : (cstOutput || !build && project === void 0) && ctx.build?._parsemanCstCollapse && children3.length === 1 && rawChildren.length === 1 && ctx.build._parsemanCstCollapse(nodeType, children3[0], children3, rawChildren) ? children3[0] : project !== void 0 ? cstOutput && ctx.build ? ctx.build(nodeType, children3, fields, span, rawChildren, triviaLog, ctx.state, tags) : projectChild(children3, project, nodeType) : build ? cstOutput && ctx.build ? ctx.build(nodeType, children3, fields, span, rawChildren, triviaLog, ctx.state, tags) : build(children3, fields, span, rawChildren, triviaLog, st) : ctx.build ? ctx.build(nodeType, children3, fields, span, rawChildren, triviaLog, st, tags) :
|
|
5249
|
+
const built = unwrap && children3.length === 1 ? unwrapChild(children3[0]) : collapse && children3.length === 1 ? children3[0] : (cstOutput || !build && project === void 0) && ctx.build?._parsemanCstCollapse && children3.length === 1 && rawChildren.length === 1 && ctx.build._parsemanCstCollapse(nodeType, children3[0], children3, rawChildren) ? children3[0] : project !== void 0 ? cstOutput && ctx.build ? ctx.build(nodeType, children3, fields, span, rawChildren, triviaLog, ctx.state, tags) : projectChild(children3, project, nodeType) : build ? cstOutput && ctx.build ? ctx.build(nodeType, children3, fields, span, rawChildren, triviaLog, ctx.state, tags) : build(children3, fields, span, rawChildren, triviaLog, st) : ctx.build ? ctx.build(nodeType, children3, fields, span, rawChildren, triviaLog, st, tags) : new PlainNode(nodeType, ctx.trackLines ? copySpan(span) : new PlainSpan7(r.span.start, r.span.end), st ?? null, [...children3]);
|
|
5217
5250
|
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 };
|
|
5218
5251
|
if (saved.buf !== void 0 || saved.ch !== void 0) {
|
|
5219
5252
|
pushCstChild(ctx, built, rawEntry2);
|
|
@@ -5369,6 +5402,7 @@ function field(name, combinator, opts) {
|
|
|
5369
5402
|
}
|
|
5370
5403
|
|
|
5371
5404
|
// src/combinators/token.ts
|
|
5405
|
+
import { PlainLeaf as PlainLeaf6 } from "../cst/plain.js";
|
|
5372
5406
|
function semanticLeafValue(_ctx, _input, _start, _end, value) {
|
|
5373
5407
|
return value;
|
|
5374
5408
|
}
|
|
@@ -5422,7 +5456,7 @@ function token(root) {
|
|
|
5422
5456
|
if (!result.ok) return result;
|
|
5423
5457
|
const span = result.span;
|
|
5424
5458
|
const value = input.slice(pos, span.end);
|
|
5425
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
5459
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf6(value, span));
|
|
5426
5460
|
return { ok: true, value, span };
|
|
5427
5461
|
}
|
|
5428
5462
|
};
|
|
@@ -5470,11 +5504,7 @@ function makeLeaf(root, fn, sourceCstValue) {
|
|
|
5470
5504
|
}
|
|
5471
5505
|
if (!result.ok) return result;
|
|
5472
5506
|
const value = fn(result.value, result.span);
|
|
5473
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
5474
|
-
_tag: "leaf",
|
|
5475
|
-
value: cstValue(ctx, input, pos, result.span.end, value),
|
|
5476
|
-
span: result.span
|
|
5477
|
-
});
|
|
5507
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf6(cstValue(ctx, input, pos, result.span.end, value), result.span));
|
|
5478
5508
|
return { ok: true, value, span: result.span };
|
|
5479
5509
|
}
|
|
5480
5510
|
};
|
|
@@ -5507,6 +5537,7 @@ function buildLexBodyRecognizer(spec, constants) {
|
|
|
5507
5537
|
}
|
|
5508
5538
|
|
|
5509
5539
|
// src/table/run-support.ts
|
|
5540
|
+
import { PlainLeaf as PlainLeaf7, PlainLineSpan as PlainLineSpan2, PlainSpan as PlainSpan8 } from "../cst/plain.js";
|
|
5510
5541
|
function lineCol(ctx, offset) {
|
|
5511
5542
|
const starts = ctx._lineStarts ?? [0];
|
|
5512
5543
|
let lo = 0, hi = starts.length - 1;
|
|
@@ -5519,18 +5550,14 @@ function lineCol(ctx, offset) {
|
|
|
5519
5550
|
}
|
|
5520
5551
|
function spanLines(ctx, start, end) {
|
|
5521
5552
|
const s = lineCol(ctx, start), e = lineCol(ctx, end);
|
|
5522
|
-
return
|
|
5553
|
+
return new PlainLineSpan2(start, end, s[0], s[1], e[0], e[1]);
|
|
5523
5554
|
}
|
|
5524
5555
|
function rawEntry(v, input, s, e) {
|
|
5525
5556
|
if (typeof v === "object" && v !== null) {
|
|
5526
5557
|
const tg = v._tag;
|
|
5527
5558
|
if (tg === "node" || tg === "leaf" || tg === "parseError") return v;
|
|
5528
5559
|
}
|
|
5529
|
-
return
|
|
5530
|
-
_tag: "leaf",
|
|
5531
|
-
value: typeof v === "string" ? v : typeof v === "object" && v !== null ? input.slice(s, e) : "",
|
|
5532
|
-
span: { start: s, end: e }
|
|
5533
|
-
};
|
|
5560
|
+
return new PlainLeaf7(typeof v === "string" ? v : typeof v === "object" && v !== null ? input.slice(s, e) : "", new PlainSpan8(s, e));
|
|
5534
5561
|
}
|
|
5535
5562
|
function lead(input, pos) {
|
|
5536
5563
|
if (pos >= input.length) return -1;
|
|
@@ -5544,7 +5571,7 @@ function collapseEmpty(ctx, build, input, pos, end, readsRaw) {
|
|
|
5544
5571
|
const collected = ctx._cstBuf !== void 0 || ctx._cstChildren !== void 0;
|
|
5545
5572
|
if (collected) popCstChild(ctx);
|
|
5546
5573
|
const raw = readsRaw ? [rawEntry(void 0, input, pos, end)] : EMPTY_KIDS;
|
|
5547
|
-
const nd = build(EMPTY_KIDS, void 0,
|
|
5574
|
+
const nd = build(EMPTY_KIDS, void 0, new PlainSpan8(pos, end), raw, EMPTY_TRIVIA, void 0);
|
|
5548
5575
|
if (collected) pushCstChild(ctx, nd, ctx._cstBuf?.noRaw === true ? void 0 : rawEntry(nd, input, pos, end));
|
|
5549
5576
|
return nd;
|
|
5550
5577
|
}
|
|
@@ -7768,18 +7795,10 @@ var Encoder = class {
|
|
|
7768
7795
|
/** TOKEN bodies are an all-program decision. A complete occurrence inside an
|
|
7769
7796
|
* otherwise incomplete final graph stays on CHARACTER with every sibling. */
|
|
7770
7797
|
selectLexicalBodies;
|
|
7771
|
-
/**
|
|
7772
|
-
* Decides the extra operands laid down below. ALWAYS TRUE — see
|
|
7773
|
-
* `TableSettings.recovery`. Kept as a field rather than folded away because it
|
|
7774
|
-
* is what every emit site reads, and the emit sites are where the shape of the
|
|
7775
|
-
* row is stated.
|
|
7776
|
-
*/
|
|
7777
|
-
rec;
|
|
7778
7798
|
constructor(settings, selectLexicalBodies) {
|
|
7779
7799
|
this.settings = settings;
|
|
7780
7800
|
this.track = settings.trackLines === true;
|
|
7781
7801
|
this.selectLexicalBodies = selectLexicalBodies;
|
|
7782
|
-
this.rec = true;
|
|
7783
7802
|
this.plan = settings.coverage;
|
|
7784
7803
|
this.cov = settings.coverage === void 0 ? void 0 : settings.coverage.definitions.map((d) => [d.id, covKindCode(d.kind)]);
|
|
7785
7804
|
this.covIndex = new Map((this.cov ?? []).map((d, i) => [d[0], i]));
|
|
@@ -8281,12 +8300,10 @@ var Encoder = class {
|
|
|
8281
8300
|
}
|
|
8282
8301
|
case "sequence": {
|
|
8283
8302
|
const kids = d.parsers.map((c) => this.node(c).ip);
|
|
8284
|
-
const head = this.emitHead(d.valueUnused ? OP_SEQV : OP_SEQ, 1 +
|
|
8303
|
+
const head = this.emitHead(d.valueUnused ? OP_SEQV : OP_SEQ, 1 + 2 * kids.length);
|
|
8285
8304
|
this.code[head + 1] = kids.length;
|
|
8286
8305
|
for (let i = 0; i < kids.length; i++) this.code[head + 2 + i] = kids[i];
|
|
8287
|
-
|
|
8288
|
-
for (let i = 0; i < kids.length; i++) this.code[head + 2 + kids.length + i] = this.followClass(d.parsers, i);
|
|
8289
|
-
}
|
|
8306
|
+
for (let i = 0; i < kids.length; i++) this.code[head + 2 + kids.length + i] = this.followClass(d.parsers, i);
|
|
8290
8307
|
return head;
|
|
8291
8308
|
}
|
|
8292
8309
|
case "choice": {
|
|
@@ -8388,25 +8405,22 @@ var Encoder = class {
|
|
|
8388
8405
|
const itemClass = matchesEmpty(d.parser, /* @__PURE__ */ new Set(), rr) ? -1 : this.charClass(firstSetOf(d.parser, /* @__PURE__ */ new Set(), rr, this.activeTrivia));
|
|
8389
8406
|
const op = d.valueUnused ? OP_REPV : OP_REP;
|
|
8390
8407
|
const min = d.tag === "many" ? 0 : d.min;
|
|
8391
|
-
return this.
|
|
8408
|
+
return this.emit(op, child, min, d.max ?? -1, -1, 0, this.expected(deriveExpected(d.parser)), itemClass);
|
|
8392
8409
|
}
|
|
8393
8410
|
case "sepBy": {
|
|
8394
8411
|
const child = this.node(d.parser).ip;
|
|
8395
8412
|
const sep2 = this.node(d.separator).ip;
|
|
8396
8413
|
const flags = (d.trailing === "allow" ? 1 : 0) | (d.keepSeparators === true ? 2 : 0) | (d.min >= 2 ? 4 : 0);
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
);
|
|
8408
|
-
}
|
|
8409
|
-
return d.min >= 2 ? this.emit(OP_REP, child, d.min, d.max ?? -1, sep2, flags, this.expected(deriveExpected(d.parser))) : this.emit(OP_REP, child, d.min, d.max ?? -1, sep2, flags);
|
|
8414
|
+
return this.emit(
|
|
8415
|
+
OP_REP,
|
|
8416
|
+
child,
|
|
8417
|
+
d.min,
|
|
8418
|
+
d.max ?? -1,
|
|
8419
|
+
sep2,
|
|
8420
|
+
flags,
|
|
8421
|
+
this.expected(deriveExpected(d.parser)),
|
|
8422
|
+
this.charClass(firstSetOf(d.separator, /* @__PURE__ */ new Set(), this.refResolver(), this.activeTrivia))
|
|
8423
|
+
);
|
|
8410
8424
|
}
|
|
8411
8425
|
case "optional": {
|
|
8412
8426
|
const head = this.emit(OP_OPT, this.lookaheadGate(d.parser, this.node(d.parser).ip));
|
|
@@ -8417,14 +8431,12 @@ var Encoder = class {
|
|
|
8417
8431
|
const inner = d.parser._def;
|
|
8418
8432
|
if (inner.tag === "sequence" && !this.memo.has(d.parser) && !this.pending.has(d.parser)) {
|
|
8419
8433
|
const kids = inner.parsers.map((c) => this.node(c).ip);
|
|
8420
|
-
const head = this.emitHead(OP_SEQX, 2 +
|
|
8434
|
+
const head = this.emitHead(OP_SEQX, 2 + 2 * kids.length);
|
|
8421
8435
|
const projection = directArrayProjection(d.fn, d.fnSrc, kids.length);
|
|
8422
8436
|
this.code[head + 1] = projection === null ? this.fn(d.fn, d.fnSrc ?? null) : ~projection;
|
|
8423
8437
|
this.code[head + 2] = kids.length;
|
|
8424
8438
|
for (let i = 0; i < kids.length; i++) this.code[head + 3 + i] = kids[i];
|
|
8425
|
-
|
|
8426
|
-
for (let i = 0; i < kids.length; i++) this.code[head + 3 + kids.length + i] = this.followClass(inner.parsers, i);
|
|
8427
|
-
}
|
|
8439
|
+
for (let i = 0; i < kids.length; i++) this.code[head + 3 + kids.length + i] = this.followClass(inner.parsers, i);
|
|
8428
8440
|
return head;
|
|
8429
8441
|
}
|
|
8430
8442
|
const child = this.node(d.parser).ip;
|
|
@@ -8747,7 +8759,7 @@ var Encoder = class {
|
|
|
8747
8759
|
...this.settings.hostMode === void 0 ? {} : { hostMode: this.settings.hostMode },
|
|
8748
8760
|
...this.runtimeOnly.size === 0 ? {} : { runtimeOnly: [...this.runtimeOnly].sort() },
|
|
8749
8761
|
...this.triviaSpecs.length === 0 ? {} : { triviaSpecs: this.triviaSpecs },
|
|
8750
|
-
|
|
8762
|
+
rec: 1,
|
|
8751
8763
|
...this.cov === void 0 ? {} : { cov: this.cov },
|
|
8752
8764
|
lines: this.track ? 1 : 0
|
|
8753
8765
|
}, void 0, {
|
|
@@ -9511,7 +9523,6 @@ function caseFoldLiteralOrAlt(source) {
|
|
|
9511
9523
|
}
|
|
9512
9524
|
return { kind: "alt", arms: litArms, disjoint: false, firsts: litArms.map(() => null) };
|
|
9513
9525
|
}
|
|
9514
|
-
var scanToIndexOfEnabled = () => process.env.PARSEMAN_SCANTO === "indexof";
|
|
9515
9526
|
var classCond = (cVar, ranges) => ranges.map(([lo, hi]) => lo === hi ? `${cVar} === ${lo}` : `(${cVar} >= ${lo} && ${cVar} <= ${hi})`).join(" || ");
|
|
9516
9527
|
var litCond = (base, cps, firstVar) => cps.map(
|
|
9517
9528
|
(cp, k) => k === 0 && firstVar ? `${firstVar} === ${cp}` : `input.charCodeAt(${base}${k ? ` + ${k}` : ""}) === ${cp}`
|
|
@@ -9741,13 +9752,7 @@ function emitShapeMatch(shape, start, mint, ind, firstChar) {
|
|
|
9741
9752
|
const j2 = mint("_j");
|
|
9742
9753
|
const openLen2 = shape.open.length;
|
|
9743
9754
|
const openChk2 = openLen2 === 1 ? `${codeAt(start, firstChar)} === ${shape.open[0]}` : litCond(start, shape.open, firstChar);
|
|
9744
|
-
const
|
|
9745
|
-
const scanLine = stopCp !== null && stopCp <= 65535 && scanToIndexOfEnabled() ? (
|
|
9746
|
-
// No temp is minted: a temp would renumber every later variable in the
|
|
9747
|
-
// function and show up as an artifact-size delta that is counter
|
|
9748
|
-
// renumbering rather than this change (the §9.1.4 / §9.2 effect).
|
|
9749
|
-
`${ind} ${j2} = input.indexOf(${JSON.stringify(String.fromCharCode(stopCp))}, ${j2}); if (${j2} < 0) ${j2} = input.length`
|
|
9750
|
-
) : `${ind} while (${j2} < input.length && !(${classCond(`input.charCodeAt(${j2})`, shape.stop)})) ${j2}++`;
|
|
9755
|
+
const scanLine = `${ind} while (${j2} < input.length && !(${classCond(`input.charCodeAt(${j2})`, shape.stop)})) ${j2}++`;
|
|
9751
9756
|
return {
|
|
9752
9757
|
setup: [
|
|
9753
9758
|
`${ind}let ${j2} = ${start}`,
|
|
@@ -9805,11 +9810,7 @@ function emitShapeMatch(shape, start, mint, ind, firstChar) {
|
|
|
9805
9810
|
const closeLen = shape.close.length;
|
|
9806
9811
|
const openChk = openLen === 1 ? `${codeAt(start, firstChar)} === ${shape.open[0]}` : litCond(start, shape.open, firstChar);
|
|
9807
9812
|
const closeChk = litCond(j, shape.close);
|
|
9808
|
-
const
|
|
9809
|
-
const scanLines = scanToIndexOfEnabled() ? [
|
|
9810
|
-
`${ind} ${j} = input.indexOf(${JSON.stringify(closeStr)}, ${j}); if (${j} < 0) ${j} = input.length`,
|
|
9811
|
-
`${ind} if (${j} + ${closeLen} <= input.length) ${endV} = ${j} + ${closeLen}`
|
|
9812
|
-
] : [
|
|
9813
|
+
const scanLines = [
|
|
9813
9814
|
`${ind} while (${j} + ${closeLen - 1} < input.length && !(${closeChk})) ${j}++`,
|
|
9814
9815
|
`${ind} if (${j} + ${closeLen} <= input.length && (${closeChk})) ${endV} = ${j} + ${closeLen}`
|
|
9815
9816
|
];
|
|
@@ -10445,7 +10446,14 @@ var EMITTED_PARAMS = [
|
|
|
10445
10446
|
"skipDeferredTrivia",
|
|
10446
10447
|
// Appended for the pass-through collapse (`run-support.ts`); old factories
|
|
10447
10448
|
// ignore it.
|
|
10448
|
-
"collapseEmpty"
|
|
10449
|
+
"collapseEmpty",
|
|
10450
|
+
// Appended for constructor-built tree objects (`cst/plain.d.ts`): a `new` call has
|
|
10451
|
+
// no allocation site, so V8 cannot pretenure them. Old factories ignore them.
|
|
10452
|
+
"_SP",
|
|
10453
|
+
"_LF",
|
|
10454
|
+
"_ND",
|
|
10455
|
+
"_FC",
|
|
10456
|
+
"_BUF"
|
|
10449
10457
|
];
|
|
10450
10458
|
var RUNTIME_PRELUDE = `
|
|
10451
10459
|
let _pfScan=null
|
|
@@ -10469,9 +10477,9 @@ if(s!==null)return skipTriviaScanned(s,input,cur,ctx)
|
|
|
10469
10477
|
if(needsDeferredTriviaCommit(ctx))return skipDeferredTrivia(input,cur,ctx)
|
|
10470
10478
|
return advanceTrivia(input,cur,ctx)
|
|
10471
10479
|
}
|
|
10472
|
-
function _pushLeaf(ctx,value,s,e){pushCstLeaf(ctx,
|
|
10480
|
+
function _pushLeaf(ctx,value,s,e){pushCstLeaf(ctx,new _LF(value,new _SP(s,e)))}
|
|
10473
10481
|
function _pushLeafBuf(ctx,value,s,e){
|
|
10474
|
-
const l=
|
|
10482
|
+
const l=new _LF(value,new _SP(s,e))
|
|
10475
10483
|
const b=ctx._cstBuf
|
|
10476
10484
|
if(b.ch!==undefined)b.ch.push(l)
|
|
10477
10485
|
else if(b.single!==undefined){b.ch=[b.single,l];b.single=undefined}
|
|
@@ -10529,7 +10537,7 @@ if(ctx._rootTriviaLog!==undefined&&ctx._rootTriviaLog.length!==rt)ctx._rootTrivi
|
|
|
10529
10537
|
`;
|
|
10530
10538
|
var NO_RAW_RUNTIME_PRELUDE = `
|
|
10531
10539
|
function _pushLeafNoRawBuf(ctx,value,s,e){
|
|
10532
|
-
const l=
|
|
10540
|
+
const l=new _LF(value,new _SP(s,e))
|
|
10533
10541
|
const b=ctx._cstBuf
|
|
10534
10542
|
if(b.ch!==undefined)b.ch.push(l)
|
|
10535
10543
|
else if(b.single!==undefined){b.ch=[b.single,l];b.single=undefined}
|
|
@@ -11206,7 +11214,7 @@ try{return ${child}(input,pos,ctx)}finally{ctx.state=saved}
|
|
|
11206
11214
|
return `${head}
|
|
11207
11215
|
const v=${child}(input,pos,ctx)
|
|
11208
11216
|
if(v===FAIL)return FAIL
|
|
11209
|
-
return ${fn}(v,
|
|
11217
|
+
return ${fn}(v,new _SP(pos,EC.e))
|
|
11210
11218
|
}`;
|
|
11211
11219
|
}
|
|
11212
11220
|
case OP_LABEL: {
|
|
@@ -11227,7 +11235,7 @@ return v
|
|
|
11227
11235
|
const v=${child}(input,pos,ctx)
|
|
11228
11236
|
if(v===FAIL)return FAIL
|
|
11229
11237
|
const f=ctx._fields
|
|
11230
|
-
if(f!==undefined)f.push({name
|
|
11238
|
+
if(f!==undefined)f.push(new _FC(${name},v,new _SP(pos,EC.e)))
|
|
11231
11239
|
return v
|
|
11232
11240
|
}`;
|
|
11233
11241
|
}
|
|
@@ -11252,7 +11260,7 @@ return v
|
|
|
11252
11260
|
return `${head}
|
|
11253
11261
|
const v=${child}(input,pos,ctx)
|
|
11254
11262
|
if(v!==FAIL)return v
|
|
11255
|
-
const err={_tag:'parseError',span:${prog.lines === 1 ? "spanLines(ctx,pos,pos)" : "
|
|
11263
|
+
const err={_tag:'parseError',span:${prog.lines === 1 ? "spanLines(ctx,pos,pos)" : "new _SP(pos,pos)"},expected:${xf}}
|
|
11256
11264
|
const es=ctx._errors
|
|
11257
11265
|
if(es!==undefined)es.push(err)
|
|
11258
11266
|
${REC2 ? "if(ctx._tolerant===true)captureError(ctx,err)\n" : ""}ctx._fc=false
|
|
@@ -11263,7 +11271,7 @@ return err
|
|
|
11263
11271
|
case OP_ROUTED: {
|
|
11264
11272
|
const fb = code[ip + 1];
|
|
11265
11273
|
const fallback2 = fb >= 0 ? link(fb) : void 0;
|
|
11266
|
-
const push = `pushCstLeaf(ctx,
|
|
11274
|
+
const push = `pushCstLeaf(ctx,new _LF(it.value,it.span))`;
|
|
11267
11275
|
return `${head}
|
|
11268
11276
|
const it=ctx._routed
|
|
11269
11277
|
if(it===undefined||pos!==it.span.start){
|
|
@@ -11344,8 +11352,8 @@ ctx._triviaLog=sOtl
|
|
|
11344
11352
|
}
|
|
11345
11353
|
if(v===FAIL)return FAIL
|
|
11346
11354
|
const e=EC.e
|
|
11347
|
-
const out=${isToken ? "input.slice(pos,e)" : `${fn}(v,
|
|
11348
|
-
if(wasCap)pushCstLeaf(ctx,{
|
|
11355
|
+
const out=${isToken ? "input.slice(pos,e)" : `${fn}(v,new _SP(pos,e))`}
|
|
11356
|
+
if(wasCap)pushCstLeaf(ctx,new _LF(${capturesSource ? "input.slice(pos,e)" : "out"},new _SP(pos,e)))
|
|
11349
11357
|
EC.e=e
|
|
11350
11358
|
return out
|
|
11351
11359
|
}`;
|
|
@@ -11369,7 +11377,7 @@ ${hasSuffix && (lineFlags & 2) !== 0 ? "if(sm)_trackLines(ctx,input,e)" : ""}
|
|
|
11369
11377
|
${hasSuffix ? `if(!sm){ctx._fe=e;ctx._fx=${suffixExpected};if(ctx._probe!==undefined)failAt(ctx,${suffixExpected},e)}` : ""}
|
|
11370
11378
|
const v=${pending ? "tp?_pfTokValue:" : ""}input.slice(pos,e)
|
|
11371
11379
|
${pending ? "if(tp){_pfTokBody=-1;_pfTokValue=undefined}" : ""}
|
|
11372
|
-
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,
|
|
11380
|
+
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
11373
11381
|
EC.e=e
|
|
11374
11382
|
return v
|
|
11375
11383
|
}`;
|
|
@@ -11408,7 +11416,7 @@ ctx._rootTriviaLog=sRtl
|
|
|
11408
11416
|
}
|
|
11409
11417
|
if(e<0)return FAIL
|
|
11410
11418
|
const v=input.slice(pos,e)
|
|
11411
|
-
if(wasCap)pushCstLeaf(ctx,
|
|
11419
|
+
if(wasCap)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
11412
11420
|
EC.e=e
|
|
11413
11421
|
return v
|
|
11414
11422
|
}`;
|
|
@@ -11416,7 +11424,7 @@ return v
|
|
|
11416
11424
|
const e=${run2}(input,pos,ctx)
|
|
11417
11425
|
if(e<0)return FAIL
|
|
11418
11426
|
const v=input.slice(pos,e)
|
|
11419
|
-
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,
|
|
11427
|
+
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
11420
11428
|
EC.e=e
|
|
11421
11429
|
return v
|
|
11422
11430
|
}`;
|
|
@@ -11530,7 +11538,7 @@ return v
|
|
|
11530
11538
|
}` : `${parts.join("\n")}
|
|
11531
11539
|
}`;
|
|
11532
11540
|
if (n === 1) {
|
|
11533
|
-
parts.push(fused ? projection === 0 ? "return v0" : `return ${fn}([v0],
|
|
11541
|
+
parts.push(fused ? projection === 0 ? "return v0" : `return ${fn}([v0],new _SP(pos,EC.e))` : wantValues ? "return [v0]" : "return undefined");
|
|
11534
11542
|
return close();
|
|
11535
11543
|
}
|
|
11536
11544
|
parts.push("let cur=EC.e");
|
|
@@ -11556,7 +11564,7 @@ return v
|
|
|
11556
11564
|
names.push(vn);
|
|
11557
11565
|
}
|
|
11558
11566
|
parts.push("EC.e=cur");
|
|
11559
|
-
parts.push(fused ? projection >= 0 ? `return ${names[projection]}` : `return ${fn}([${names.join(",")}],
|
|
11567
|
+
parts.push(fused ? projection >= 0 ? `return ${names[projection]}` : `return ${fn}([${names.join(",")}],new _SP(pos,cur))` : wantValues ? `return [${names.join(",")}]` : "return undefined");
|
|
11560
11568
|
return close();
|
|
11561
11569
|
}
|
|
11562
11570
|
case OP_CHOICE: {
|
|
@@ -11815,7 +11823,7 @@ ${spec.match.map((m, i) => `${i === 0 ? "" : "else "}if(${dispatchClaim(m)})arm=
|
|
|
11815
11823
|
const routedCall = (target) => `{const savedRouted=ctx._routed
|
|
11816
11824
|
${emitRollback(m1, L.buf, L.raw, sinks)}
|
|
11817
11825
|
${emitMark(m2, L.buf, L.raw, sinks, false)}
|
|
11818
|
-
ctx._routed={value:key,span:
|
|
11826
|
+
ctx._routed={value:key,span:new _SP(pos,selEnd)}
|
|
11819
11827
|
try{v=${target}(input,pos,ctx)}finally{ctx._routed=savedRouted}
|
|
11820
11828
|
break}`;
|
|
11821
11829
|
const plainCall = (target) => `v=${target}(input,selEnd,ctx);break`;
|
|
@@ -12010,8 +12018,8 @@ return out
|
|
|
12010
12018
|
const end=${recognize}(input,pos)
|
|
12011
12019
|
if(end<0){ctx._fe=pos;ctx._fx=${xf};return FAIL}
|
|
12012
12020
|
const value=${value2}
|
|
12013
|
-
const leaf=
|
|
12014
|
-
const kids=[leaf],rawKids=[leaf],span=
|
|
12021
|
+
const leaf=new _LF(value,new _SP(pos,end))
|
|
12022
|
+
const kids=[leaf],rawKids=[leaf],span=new _SP(pos,end)
|
|
12015
12023
|
EC.e=end
|
|
12016
12024
|
const nd=${build2}(kids,undefined,span,rawKids,EMPTY_TL,undefined)
|
|
12017
12025
|
${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))"}
|
|
@@ -12110,7 +12118,7 @@ ctx._cstTriviaLog=sTl
|
|
|
12110
12118
|
ctx.captureTrivia=sCap
|
|
12111
12119
|
if(v===FAIL)return FAIL
|
|
12112
12120
|
const end=EC.e
|
|
12113
|
-
${collapseChildren ? `const nd=captured.length===1?captured[0]:${build}(captured,undefined,
|
|
12121
|
+
${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)`}
|
|
12114
12122
|
${publish}
|
|
12115
12123
|
EC.e=end
|
|
12116
12124
|
return nd
|
|
@@ -12133,20 +12141,20 @@ return nd
|
|
|
12133
12141
|
const direct = `${build}(kids,fieldMap,span,rawKids,${captureWide ? "tlog" : "EMPTY_TL"},st)`;
|
|
12134
12142
|
value = hostCst ? `nd=_pfHost!==undefined?${hostCall}:${direct}` : `nd=${direct}`;
|
|
12135
12143
|
} else {
|
|
12136
|
-
value = `nd=_pfHost!==undefined?_pfHost(${ty},hostKids,fieldMap,span,rawKids,tlog,st,${tags}):{
|
|
12144
|
+
value = `nd=_pfHost!==undefined?_pfHost(${ty},hostKids,fieldMap,span,rawKids,tlog,st,${tags}):new _ND(${ty},span,st??null,kids===EMPTY_CH?kids:[...kids])`;
|
|
12137
12145
|
}
|
|
12138
12146
|
const collapsible = keepChildren && (hostCst || build === void 0 && proj < 0);
|
|
12139
|
-
const openCapture = omitsRaw ? `const buf=
|
|
12147
|
+
const openCapture = omitsRaw ? `const buf=new _BUF(undefined,true,0)
|
|
12140
12148
|
ctx._cstBuf=buf
|
|
12141
12149
|
ctx._cstChildren=undefined
|
|
12142
12150
|
ctx._cstLeaves=undefined
|
|
12143
12151
|
ctx._cstRawChildren=undefined
|
|
12144
|
-
ctx._cstTriviaLog=undefined` : keepChildren ? `const buf=
|
|
12152
|
+
ctx._cstTriviaLog=undefined` : keepChildren ? `const buf=new _BUF(undefined,undefined,0)
|
|
12145
12153
|
ctx._cstBuf=buf
|
|
12146
12154
|
ctx._cstChildren=undefined
|
|
12147
12155
|
ctx._cstLeaves=undefined
|
|
12148
12156
|
ctx._cstRawChildren=undefined
|
|
12149
|
-
ctx._cstTriviaLog=undefined` : `const buf=
|
|
12157
|
+
ctx._cstTriviaLog=undefined` : `const buf=new _BUF(true,undefined,0)
|
|
12150
12158
|
ctx._cstBuf=buf
|
|
12151
12159
|
ctx._cstChildren=undefined
|
|
12152
12160
|
ctx._cstLeaves=undefined
|
|
@@ -12184,7 +12192,7 @@ ctx._cstTriviaLog=sTl
|
|
|
12184
12192
|
ctx.captureTrivia=sCap
|
|
12185
12193
|
if(v===FAIL)return FAIL
|
|
12186
12194
|
const end=EC.e
|
|
12187
|
-
const span=${tracked ? "spanLines(ctx,pos,end)" : "
|
|
12195
|
+
const span=${tracked ? "spanLines(ctx,pos,end)" : "new _SP(pos,end)"}
|
|
12188
12196
|
const st=${readsState ? "ctx.state" : "undefined"}
|
|
12189
12197
|
let nd
|
|
12190
12198
|
${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]
|
|
@@ -12471,6 +12479,7 @@ function rebuildLineScan(s, subtree) {
|
|
|
12471
12479
|
}
|
|
12472
12480
|
|
|
12473
12481
|
// src/combinators/scanTo.ts
|
|
12482
|
+
import { PlainLeaf as PlainLeaf8, PlainSpan as PlainSpan9 } from "../cst/plain.js";
|
|
12474
12483
|
function resolveScanSkip(explicitSkip, raw, ctx) {
|
|
12475
12484
|
if (raw) return [];
|
|
12476
12485
|
const trivia2 = ctx.trivia;
|
|
@@ -12508,7 +12517,7 @@ function scanTo(sentinel, { skip, raw = false, orEOF = false, recoverAt, stopAt
|
|
|
12508
12517
|
probeCtx._errors = ctx._errors;
|
|
12509
12518
|
const emit = (end) => {
|
|
12510
12519
|
if (end > pos && cstCaptureActive(ctx)) {
|
|
12511
|
-
const leaf2 =
|
|
12520
|
+
const leaf2 = new PlainLeaf8(input.slice(pos, end), new PlainSpan9(pos, end));
|
|
12512
12521
|
pushCstLeaf(ctx, leaf2);
|
|
12513
12522
|
}
|
|
12514
12523
|
};
|
|
@@ -12787,6 +12796,9 @@ function clearOf(ranges, input, from, to) {
|
|
|
12787
12796
|
return true;
|
|
12788
12797
|
}
|
|
12789
12798
|
|
|
12799
|
+
// src/table/assemble.ts
|
|
12800
|
+
import { PlainBuf as PlainBuf2, PlainField, PlainLeaf as PlainLeaf9, PlainNode as PlainNode2, PlainSpan as PlainSpan10 } from "../cst/plain.js";
|
|
12801
|
+
|
|
12790
12802
|
// src/table/fail-clean.ts
|
|
12791
12803
|
function passChild(code, ip) {
|
|
12792
12804
|
switch (code[ip]) {
|
|
@@ -13114,7 +13126,7 @@ function assemble(t, prog, cfg) {
|
|
|
13114
13126
|
const NULLABLE = /* @__PURE__ */ new Map();
|
|
13115
13127
|
const CLEAN = REC2 ? () => false : failCleanAnalysis(code);
|
|
13116
13128
|
function pushLeaf(ctx, value, s, e) {
|
|
13117
|
-
const lf =
|
|
13129
|
+
const lf = new PlainLeaf9(value, new PlainSpan10(s, e));
|
|
13118
13130
|
pushCstLeaf(ctx, lf);
|
|
13119
13131
|
}
|
|
13120
13132
|
function plainBuildNode(child, build, trailing) {
|
|
@@ -13147,7 +13159,7 @@ function assemble(t, prog, cfg) {
|
|
|
13147
13159
|
ctx.captureTrivia = sCap;
|
|
13148
13160
|
if (value === FAIL) return FAIL;
|
|
13149
13161
|
const end = EC.e;
|
|
13150
|
-
const span =
|
|
13162
|
+
const span = new PlainSpan10(pos, end);
|
|
13151
13163
|
const node2 = build(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
|
|
13152
13164
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13153
13165
|
pushCstChild(ctx, node2, rawEntry(node2, input, pos, end));
|
|
@@ -13192,7 +13204,7 @@ function assemble(t, prog, cfg) {
|
|
|
13192
13204
|
ctx.captureTrivia = sCap;
|
|
13193
13205
|
if (value === FAIL) return FAIL;
|
|
13194
13206
|
const end = EC.e;
|
|
13195
|
-
const node2 = build(captured, void 0,
|
|
13207
|
+
const node2 = build(captured, void 0, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
|
|
13196
13208
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13197
13209
|
pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
|
|
13198
13210
|
}
|
|
@@ -13229,7 +13241,7 @@ function assemble(t, prog, cfg) {
|
|
|
13229
13241
|
ctx.captureTrivia = sCap;
|
|
13230
13242
|
if (value === FAIL) return FAIL;
|
|
13231
13243
|
const end = EC.e;
|
|
13232
|
-
const node2 = build(captured, fieldMap,
|
|
13244
|
+
const node2 = build(captured, fieldMap, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
|
|
13233
13245
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13234
13246
|
pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
|
|
13235
13247
|
}
|
|
@@ -13266,7 +13278,7 @@ function assemble(t, prog, cfg) {
|
|
|
13266
13278
|
ctx.captureTrivia = sCap;
|
|
13267
13279
|
if (value === FAIL) return FAIL;
|
|
13268
13280
|
const end = EC.e;
|
|
13269
|
-
const span =
|
|
13281
|
+
const span = new PlainSpan10(pos, end);
|
|
13270
13282
|
const node2 = kids.length === 1 ? kids[0] : build(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
|
|
13271
13283
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13272
13284
|
pushCstChild(ctx, node2, rawEntry(node2, input, pos, end));
|
|
@@ -13303,7 +13315,7 @@ function assemble(t, prog, cfg) {
|
|
|
13303
13315
|
ctx.captureTrivia = sCap;
|
|
13304
13316
|
if (value === FAIL) return FAIL;
|
|
13305
13317
|
const end = EC.e;
|
|
13306
|
-
const node2 = captured.length === 1 ? captured[0] : build(captured, void 0,
|
|
13318
|
+
const node2 = captured.length === 1 ? captured[0] : build(captured, void 0, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
|
|
13307
13319
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13308
13320
|
pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
|
|
13309
13321
|
}
|
|
@@ -13736,7 +13748,7 @@ function assemble(t, prog, cfg) {
|
|
|
13736
13748
|
return (input, pos, selEnd, key, ctx, need, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot) => {
|
|
13737
13749
|
const savedRouted = ctx._routed;
|
|
13738
13750
|
if (need) rollbackTriviaAt(ctx, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot);
|
|
13739
|
-
ctx._routed = { value: key, span:
|
|
13751
|
+
ctx._routed = { value: key, span: new PlainSpan10(pos, selEnd) };
|
|
13740
13752
|
let v;
|
|
13741
13753
|
try {
|
|
13742
13754
|
v = child(input, pos, ctx);
|
|
@@ -14169,7 +14181,7 @@ function assemble(t, prog, cfg) {
|
|
|
14169
14181
|
case OP_EXPECT: {
|
|
14170
14182
|
const child = link(code[ip + 1]);
|
|
14171
14183
|
const xf = fx[code[ip + 2]];
|
|
14172
|
-
const expectSpan = (ctx, pos) => prog.lines === 1 ? spanLines(ctx, pos, pos) :
|
|
14184
|
+
const expectSpan = (ctx, pos) => prog.lines === 1 ? spanLines(ctx, pos, pos) : new PlainSpan10(pos, pos);
|
|
14173
14185
|
if (REC2) {
|
|
14174
14186
|
return (input, pos, ctx) => {
|
|
14175
14187
|
const v = child(input, pos, ctx);
|
|
@@ -14201,7 +14213,7 @@ function assemble(t, prog, cfg) {
|
|
|
14201
14213
|
return (input, pos, ctx) => {
|
|
14202
14214
|
const v = child(input, pos, ctx);
|
|
14203
14215
|
if (v === FAIL) return FAIL;
|
|
14204
|
-
ctx._fields?.push(
|
|
14216
|
+
ctx._fields?.push(new PlainField(name, v, new PlainSpan10(pos, EC.e)));
|
|
14205
14217
|
return v;
|
|
14206
14218
|
};
|
|
14207
14219
|
}
|
|
@@ -14225,7 +14237,7 @@ function assemble(t, prog, cfg) {
|
|
|
14225
14237
|
return (input, pos, ctx) => {
|
|
14226
14238
|
const v = child(input, pos, ctx);
|
|
14227
14239
|
if (v === FAIL) return FAIL;
|
|
14228
|
-
return fn(v,
|
|
14240
|
+
return fn(v, new PlainSpan10(pos, EC.e));
|
|
14229
14241
|
};
|
|
14230
14242
|
}
|
|
14231
14243
|
case OP_SCAN: {
|
|
@@ -14329,7 +14341,7 @@ function assemble(t, prog, cfg) {
|
|
|
14329
14341
|
ctx._fx = ROUTED_FX;
|
|
14330
14342
|
return FAIL;
|
|
14331
14343
|
}
|
|
14332
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
14344
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(item.value, item.span));
|
|
14333
14345
|
EC.e = item.span.end;
|
|
14334
14346
|
return item.value;
|
|
14335
14347
|
};
|
|
@@ -14515,7 +14527,7 @@ function assemble(t, prog, cfg) {
|
|
|
14515
14527
|
if (v === FAIL) return FAIL;
|
|
14516
14528
|
const end = EC.e;
|
|
14517
14529
|
const value = input.slice(pos, end);
|
|
14518
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
14530
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
|
|
14519
14531
|
EC.e = end;
|
|
14520
14532
|
return value;
|
|
14521
14533
|
};
|
|
@@ -14549,7 +14561,7 @@ function assemble(t, prog, cfg) {
|
|
|
14549
14561
|
if (ctx._probe !== void 0) failAt(ctx, suffixExpected, end);
|
|
14550
14562
|
}
|
|
14551
14563
|
const value = input.slice(pos, end);
|
|
14552
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
14564
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
|
|
14553
14565
|
EC.e = end;
|
|
14554
14566
|
return value;
|
|
14555
14567
|
};
|
|
@@ -14592,7 +14604,7 @@ function assemble(t, prog, cfg) {
|
|
|
14592
14604
|
}
|
|
14593
14605
|
if (end < 0) return FAIL;
|
|
14594
14606
|
const value = input.slice(pos, end);
|
|
14595
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
14607
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
|
|
14596
14608
|
EC.e = end;
|
|
14597
14609
|
return value;
|
|
14598
14610
|
};
|
|
@@ -14601,7 +14613,7 @@ function assemble(t, prog, cfg) {
|
|
|
14601
14613
|
const end = run2(input, pos, ctx);
|
|
14602
14614
|
if (end < 0) return FAIL;
|
|
14603
14615
|
const value = input.slice(pos, end);
|
|
14604
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
14616
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
|
|
14605
14617
|
EC.e = end;
|
|
14606
14618
|
return value;
|
|
14607
14619
|
};
|
|
@@ -14634,12 +14646,8 @@ function assemble(t, prog, cfg) {
|
|
|
14634
14646
|
}
|
|
14635
14647
|
if (v === FAIL) return FAIL;
|
|
14636
14648
|
const end = EC.e;
|
|
14637
|
-
const out = fn(v,
|
|
14638
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
14639
|
-
_tag: "leaf",
|
|
14640
|
-
value: op === OP_SOURCE_LEAF && hostCst ? input.slice(pos, end) : out,
|
|
14641
|
-
span: { start: pos, end }
|
|
14642
|
-
});
|
|
14649
|
+
const out = fn(v, new PlainSpan10(pos, end));
|
|
14650
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(op === OP_SOURCE_LEAF && hostCst ? input.slice(pos, end) : out, new PlainSpan10(pos, end)));
|
|
14643
14651
|
EC.e = end;
|
|
14644
14652
|
return out;
|
|
14645
14653
|
};
|
|
@@ -14774,7 +14782,7 @@ function assemble(t, prog, cfg) {
|
|
|
14774
14782
|
const cur = runSyncTerms(input, pos, ctx, values);
|
|
14775
14783
|
if (cur < 0) return FAIL;
|
|
14776
14784
|
EC.e = cur;
|
|
14777
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
14785
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
|
|
14778
14786
|
};
|
|
14779
14787
|
}
|
|
14780
14788
|
if (wantValues) {
|
|
@@ -14868,7 +14876,7 @@ function assemble(t, prog, cfg) {
|
|
|
14868
14876
|
const cur = runAdjTerms(input, pos, ctx, values);
|
|
14869
14877
|
if (cur < 0) return FAIL;
|
|
14870
14878
|
EC.e = cur;
|
|
14871
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
14879
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
|
|
14872
14880
|
};
|
|
14873
14881
|
}
|
|
14874
14882
|
if (wantValues) {
|
|
@@ -14893,7 +14901,7 @@ function assemble(t, prog, cfg) {
|
|
|
14893
14901
|
return (input, pos, ctx) => {
|
|
14894
14902
|
const v = k0(input, pos, ctx);
|
|
14895
14903
|
if (v === FAIL) return FAIL;
|
|
14896
|
-
return projection === 0 ? v : fn([v],
|
|
14904
|
+
return projection === 0 ? v : fn([v], new PlainSpan10(pos, EC.e));
|
|
14897
14905
|
};
|
|
14898
14906
|
}
|
|
14899
14907
|
if (wantValues) {
|
|
@@ -14918,7 +14926,7 @@ function assemble(t, prog, cfg) {
|
|
|
14918
14926
|
const cur = step(k1, input, EC.e, ctx);
|
|
14919
14927
|
if (cur < 0) return FAIL;
|
|
14920
14928
|
EC.e = cur;
|
|
14921
|
-
return projection === 0 ? v0 : projection === 1 ? TERMV : fn([v0, TERMV],
|
|
14929
|
+
return projection === 0 ? v0 : projection === 1 ? TERMV : fn([v0, TERMV], new PlainSpan10(pos, cur));
|
|
14922
14930
|
};
|
|
14923
14931
|
}
|
|
14924
14932
|
if (wantValues) {
|
|
@@ -14952,7 +14960,7 @@ function assemble(t, prog, cfg) {
|
|
|
14952
14960
|
cur = step(k2, input, cur, ctx);
|
|
14953
14961
|
if (cur < 0) return FAIL;
|
|
14954
14962
|
EC.e = cur;
|
|
14955
|
-
return projection === 0 ? v0 : projection === 1 ? v1 : projection === 2 ? TERMV : fn([v0, v1, TERMV],
|
|
14963
|
+
return projection === 0 ? v0 : projection === 1 ? v1 : projection === 2 ? TERMV : fn([v0, v1, TERMV], new PlainSpan10(pos, cur));
|
|
14956
14964
|
};
|
|
14957
14965
|
}
|
|
14958
14966
|
if (wantValues) {
|
|
@@ -15049,7 +15057,7 @@ function assemble(t, prog, cfg) {
|
|
|
15049
15057
|
const cur = runDirectTerms(input, pos, ctx, values);
|
|
15050
15058
|
if (cur < 0) return FAIL;
|
|
15051
15059
|
EC.e = cur;
|
|
15052
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
15060
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
|
|
15053
15061
|
};
|
|
15054
15062
|
}
|
|
15055
15063
|
if (wantValues) {
|
|
@@ -15947,10 +15955,10 @@ function assemble(t, prog, cfg) {
|
|
|
15947
15955
|
return FAIL;
|
|
15948
15956
|
}
|
|
15949
15957
|
const value = regexValue ? input.slice(pos, end) : spec;
|
|
15950
|
-
const leaf2 =
|
|
15958
|
+
const leaf2 = new PlainLeaf9(value, new PlainSpan10(pos, end));
|
|
15951
15959
|
const kids = [leaf2];
|
|
15952
15960
|
const rawKids = [leaf2];
|
|
15953
|
-
const span =
|
|
15961
|
+
const span = new PlainSpan10(pos, end);
|
|
15954
15962
|
EC.e = end;
|
|
15955
15963
|
const nd = build2(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
|
|
15956
15964
|
if (ctx._cstBuf !== void 0 || ctx._cstChildren !== void 0) {
|
|
@@ -16032,7 +16040,7 @@ function assemble(t, prog, cfg) {
|
|
|
16032
16040
|
const sCh = ctx._cstChildren;
|
|
16033
16041
|
const sCap = ctx.captureTrivia;
|
|
16034
16042
|
const sBuf = ctx._cstBuf;
|
|
16035
|
-
const buf = rawOnly ?
|
|
16043
|
+
const buf = rawOnly ? new PlainBuf2(true, void 0, 0) : omitsRaw ? new PlainBuf2(void 0, true, 0) : new PlainBuf2(void 0, void 0, 0);
|
|
16036
16044
|
ctx._cstBuf = buf;
|
|
16037
16045
|
ctx.captureTrivia = captureWide;
|
|
16038
16046
|
const savedFields = ctx._fields;
|
|
@@ -16054,7 +16062,7 @@ function assemble(t, prog, cfg) {
|
|
|
16054
16062
|
ctx.captureTrivia = sCap;
|
|
16055
16063
|
if (v === FAIL) return FAIL;
|
|
16056
16064
|
const end = EC.e;
|
|
16057
|
-
const span = tracked ? spanLines(ctx, pos, end) :
|
|
16065
|
+
const span = tracked ? spanLines(ctx, pos, end) : new PlainSpan10(pos, end);
|
|
16058
16066
|
const st = readsState ? ctx.state : void 0;
|
|
16059
16067
|
let nd;
|
|
16060
16068
|
if (unwrap && kids.length === 1) {
|
|
@@ -16078,7 +16086,7 @@ function assemble(t, prog, cfg) {
|
|
|
16078
16086
|
} else if (host !== void 0) {
|
|
16079
16087
|
nd = host(type, hostKids, fieldMap, span, rawKids, tlog, st, tags);
|
|
16080
16088
|
} else {
|
|
16081
|
-
nd =
|
|
16089
|
+
nd = new PlainNode2(type, span, st ?? null, kids === EMPTY_CH ? kids : [...kids]);
|
|
16082
16090
|
}
|
|
16083
16091
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
16084
16092
|
pushCstChild(ctx, nd, rawEntry(nd, input, pos, end));
|
|
@@ -16104,7 +16112,7 @@ function assemble(t, prog, cfg) {
|
|
|
16104
16112
|
const at = fe === void 0 || fe < 0 ? pos : fe;
|
|
16105
16113
|
return { ok: false, expected: ctx._fx ?? EMPTY_FX2, span: { start: at, end: at } };
|
|
16106
16114
|
}
|
|
16107
|
-
return { ok: true, value: v, span:
|
|
16115
|
+
return { ok: true, value: v, span: new PlainSpan10(pos, EC.e) };
|
|
16108
16116
|
}
|
|
16109
16117
|
};
|
|
16110
16118
|
}
|
|
@@ -16219,7 +16227,12 @@ function assemble(t, prog, cfg) {
|
|
|
16219
16227
|
LEAD,
|
|
16220
16228
|
triviaFieldCapture,
|
|
16221
16229
|
skipDeferredTrivia,
|
|
16222
|
-
collapseEmpty
|
|
16230
|
+
collapseEmpty,
|
|
16231
|
+
PlainSpan10,
|
|
16232
|
+
PlainLeaf9,
|
|
16233
|
+
PlainNode2,
|
|
16234
|
+
PlainField,
|
|
16235
|
+
PlainBuf2
|
|
16223
16236
|
);
|
|
16224
16237
|
emitReached = new Set(pre.reached);
|
|
16225
16238
|
if (emitted.ext !== void 0) HYBRID = emitted;
|
|
@@ -16306,7 +16319,12 @@ function assemble(t, prog, cfg) {
|
|
|
16306
16319
|
LEAD,
|
|
16307
16320
|
triviaFieldCapture,
|
|
16308
16321
|
skipDeferredTrivia,
|
|
16309
|
-
collapseEmpty
|
|
16322
|
+
collapseEmpty,
|
|
16323
|
+
PlainSpan10,
|
|
16324
|
+
PlainLeaf9,
|
|
16325
|
+
PlainNode2,
|
|
16326
|
+
PlainField,
|
|
16327
|
+
PlainBuf2
|
|
16310
16328
|
);
|
|
16311
16329
|
emitReached = em.reached;
|
|
16312
16330
|
} catch (e) {
|
|
@@ -16575,7 +16593,11 @@ function tableRules(source, metadataOrEntry = {}) {
|
|
|
16575
16593
|
return map[entry];
|
|
16576
16594
|
}
|
|
16577
16595
|
|
|
16596
|
+
// src/version.ts
|
|
16597
|
+
var PARSEMAN_VERSION = "0.59.1";
|
|
16598
|
+
|
|
16578
16599
|
// src/table/emit.ts
|
|
16600
|
+
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`)});`;
|
|
16579
16601
|
function jsString(s) {
|
|
16580
16602
|
return JSON.stringify(s);
|
|
16581
16603
|
}
|
|
@@ -16661,7 +16683,7 @@ function emitAssemblies(prog, cfgs) {
|
|
|
16661
16683
|
throw e;
|
|
16662
16684
|
}
|
|
16663
16685
|
const plan = em.plan;
|
|
16664
|
-
out.push(`{key:${key},factory:function(${EMITTED_PARAMS.join(",")}){${em.source}
|
|
16686
|
+
out.push(`{key:${key},factory:function(${EMITTED_PARAMS.join(",")}){${FACTORY_ARITY_GUARD}${em.source}
|
|
16665
16687
|
},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(",")}]}`);
|
|
16666
16688
|
}
|
|
16667
16689
|
return [`a:[${out.join(",")}],`];
|
|
@@ -18673,7 +18695,7 @@ function serializeRuleMap(ruleMap, scanSkip) {
|
|
|
18673
18695
|
return new Serializer(ruleMap, scanSkip ?? []).run();
|
|
18674
18696
|
} catch (e) {
|
|
18675
18697
|
if (e instanceof Unserializable) {
|
|
18676
|
-
if (process.env
|
|
18698
|
+
if (typeof process !== "undefined" && process.env?.PARSEMAN_IR_DEBUG) console.error(`[ir] fallback: ${e.message}`);
|
|
18677
18699
|
return null;
|
|
18678
18700
|
}
|
|
18679
18701
|
throw e;
|
|
@@ -19021,9 +19043,6 @@ function fieldOptionsSrc(def) {
|
|
|
19021
19043
|
return `, { ${[def.leadingTrivia === true ? "leadingTrivia: true" : "", def.trailingTrivia === true ? "trailingTrivia: true" : ""].filter(Boolean).join(", ")} }`;
|
|
19022
19044
|
}
|
|
19023
19045
|
|
|
19024
|
-
// src/version.ts
|
|
19025
|
-
var PARSEMAN_VERSION = "0.58.3";
|
|
19026
|
-
|
|
19027
19046
|
// src/compiler/compile-linkable-table.ts
|
|
19028
19047
|
function isLocal(rule) {
|
|
19029
19048
|
const d = rule._def;
|
|
@@ -19090,6 +19109,7 @@ function compileLinkableTable(ruleMapArg, ns, opts = {}) {
|
|
|
19090
19109
|
}
|
|
19091
19110
|
|
|
19092
19111
|
// src/compiler/linker.ts
|
|
19112
|
+
import { PlainNode as PlainNode3, PlainTaggedNode } from "../cst/plain.js";
|
|
19093
19113
|
function normalizeCstCollapse(collapse) {
|
|
19094
19114
|
if (collapse === true) return () => true;
|
|
19095
19115
|
if (Array.isArray(collapse)) {
|
|
@@ -19099,7 +19119,7 @@ function normalizeCstCollapse(collapse) {
|
|
|
19099
19119
|
return typeof collapse === "function" ? collapse : void 0;
|
|
19100
19120
|
}
|
|
19101
19121
|
function buildCstNode(type, children3, _fields, span, _rawChildren, _triviaLog, state, tags) {
|
|
19102
|
-
return tags !== void 0 && tags.length > 0 ?
|
|
19122
|
+
return tags !== void 0 && tags.length > 0 ? new PlainTaggedNode(type, tags, copySpan(span), state ?? null, [...children3]) : new PlainNode3(type, copySpan(span), state ?? null, [...children3]);
|
|
19103
19123
|
}
|
|
19104
19124
|
function cstBuildHost(typeOrOptions, children3, _fields, span, rawChildren, triviaLog, state, _tags) {
|
|
19105
19125
|
if (typeof typeOrOptions === "string") {
|
|
@@ -21554,8 +21574,8 @@ function supercompileRuleMapReplacement(prog, replacement, select) {
|
|
|
21554
21574
|
if (typeof body.start !== "number" || typeof body.end !== "number") return replacement;
|
|
21555
21575
|
const start = body.start - prefix.length + 1;
|
|
21556
21576
|
const end = body.end - prefix.length - 1;
|
|
21557
|
-
if (replacement.slice(start, end) !== canonical2.source + "\n") return replacement;
|
|
21558
|
-
const transformed = replacement.slice(0, start) + candidate.source + "\n" + replacement.slice(end);
|
|
21577
|
+
if (replacement.slice(start, end) !== FACTORY_ARITY_GUARD + canonical2.source + "\n") return replacement;
|
|
21578
|
+
const transformed = replacement.slice(0, start) + FACTORY_ARITY_GUARD + candidate.source + "\n" + replacement.slice(end);
|
|
21559
21579
|
const checked = parseSync4("parseman-entry-supercompile-replacement-result.js", prefix + transformed);
|
|
21560
21580
|
return checked.errors.length === 0 ? transformed : replacement;
|
|
21561
21581
|
}
|