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/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
|
}
|
|
@@ -10445,7 +10472,14 @@ var EMITTED_PARAMS = [
|
|
|
10445
10472
|
"skipDeferredTrivia",
|
|
10446
10473
|
// Appended for the pass-through collapse (`run-support.ts`); old factories
|
|
10447
10474
|
// ignore it.
|
|
10448
|
-
"collapseEmpty"
|
|
10475
|
+
"collapseEmpty",
|
|
10476
|
+
// Appended for constructor-built tree objects (`cst/plain.d.ts`): a `new` call has
|
|
10477
|
+
// no allocation site, so V8 cannot pretenure them. Old factories ignore them.
|
|
10478
|
+
"_SP",
|
|
10479
|
+
"_LF",
|
|
10480
|
+
"_ND",
|
|
10481
|
+
"_FC",
|
|
10482
|
+
"_BUF"
|
|
10449
10483
|
];
|
|
10450
10484
|
var RUNTIME_PRELUDE = `
|
|
10451
10485
|
let _pfScan=null
|
|
@@ -10469,9 +10503,9 @@ if(s!==null)return skipTriviaScanned(s,input,cur,ctx)
|
|
|
10469
10503
|
if(needsDeferredTriviaCommit(ctx))return skipDeferredTrivia(input,cur,ctx)
|
|
10470
10504
|
return advanceTrivia(input,cur,ctx)
|
|
10471
10505
|
}
|
|
10472
|
-
function _pushLeaf(ctx,value,s,e){pushCstLeaf(ctx,
|
|
10506
|
+
function _pushLeaf(ctx,value,s,e){pushCstLeaf(ctx,new _LF(value,new _SP(s,e)))}
|
|
10473
10507
|
function _pushLeafBuf(ctx,value,s,e){
|
|
10474
|
-
const l=
|
|
10508
|
+
const l=new _LF(value,new _SP(s,e))
|
|
10475
10509
|
const b=ctx._cstBuf
|
|
10476
10510
|
if(b.ch!==undefined)b.ch.push(l)
|
|
10477
10511
|
else if(b.single!==undefined){b.ch=[b.single,l];b.single=undefined}
|
|
@@ -10529,7 +10563,7 @@ if(ctx._rootTriviaLog!==undefined&&ctx._rootTriviaLog.length!==rt)ctx._rootTrivi
|
|
|
10529
10563
|
`;
|
|
10530
10564
|
var NO_RAW_RUNTIME_PRELUDE = `
|
|
10531
10565
|
function _pushLeafNoRawBuf(ctx,value,s,e){
|
|
10532
|
-
const l=
|
|
10566
|
+
const l=new _LF(value,new _SP(s,e))
|
|
10533
10567
|
const b=ctx._cstBuf
|
|
10534
10568
|
if(b.ch!==undefined)b.ch.push(l)
|
|
10535
10569
|
else if(b.single!==undefined){b.ch=[b.single,l];b.single=undefined}
|
|
@@ -11206,7 +11240,7 @@ try{return ${child}(input,pos,ctx)}finally{ctx.state=saved}
|
|
|
11206
11240
|
return `${head}
|
|
11207
11241
|
const v=${child}(input,pos,ctx)
|
|
11208
11242
|
if(v===FAIL)return FAIL
|
|
11209
|
-
return ${fn}(v,
|
|
11243
|
+
return ${fn}(v,new _SP(pos,EC.e))
|
|
11210
11244
|
}`;
|
|
11211
11245
|
}
|
|
11212
11246
|
case OP_LABEL: {
|
|
@@ -11227,7 +11261,7 @@ return v
|
|
|
11227
11261
|
const v=${child}(input,pos,ctx)
|
|
11228
11262
|
if(v===FAIL)return FAIL
|
|
11229
11263
|
const f=ctx._fields
|
|
11230
|
-
if(f!==undefined)f.push({name
|
|
11264
|
+
if(f!==undefined)f.push(new _FC(${name},v,new _SP(pos,EC.e)))
|
|
11231
11265
|
return v
|
|
11232
11266
|
}`;
|
|
11233
11267
|
}
|
|
@@ -11252,7 +11286,7 @@ return v
|
|
|
11252
11286
|
return `${head}
|
|
11253
11287
|
const v=${child}(input,pos,ctx)
|
|
11254
11288
|
if(v!==FAIL)return v
|
|
11255
|
-
const err={_tag:'parseError',span:${prog.lines === 1 ? "spanLines(ctx,pos,pos)" : "
|
|
11289
|
+
const err={_tag:'parseError',span:${prog.lines === 1 ? "spanLines(ctx,pos,pos)" : "new _SP(pos,pos)"},expected:${xf}}
|
|
11256
11290
|
const es=ctx._errors
|
|
11257
11291
|
if(es!==undefined)es.push(err)
|
|
11258
11292
|
${REC2 ? "if(ctx._tolerant===true)captureError(ctx,err)\n" : ""}ctx._fc=false
|
|
@@ -11263,7 +11297,7 @@ return err
|
|
|
11263
11297
|
case OP_ROUTED: {
|
|
11264
11298
|
const fb = code[ip + 1];
|
|
11265
11299
|
const fallback2 = fb >= 0 ? link(fb) : void 0;
|
|
11266
|
-
const push = `pushCstLeaf(ctx,
|
|
11300
|
+
const push = `pushCstLeaf(ctx,new _LF(it.value,it.span))`;
|
|
11267
11301
|
return `${head}
|
|
11268
11302
|
const it=ctx._routed
|
|
11269
11303
|
if(it===undefined||pos!==it.span.start){
|
|
@@ -11344,8 +11378,8 @@ ctx._triviaLog=sOtl
|
|
|
11344
11378
|
}
|
|
11345
11379
|
if(v===FAIL)return FAIL
|
|
11346
11380
|
const e=EC.e
|
|
11347
|
-
const out=${isToken ? "input.slice(pos,e)" : `${fn}(v,
|
|
11348
|
-
if(wasCap)pushCstLeaf(ctx,{
|
|
11381
|
+
const out=${isToken ? "input.slice(pos,e)" : `${fn}(v,new _SP(pos,e))`}
|
|
11382
|
+
if(wasCap)pushCstLeaf(ctx,new _LF(${capturesSource ? "input.slice(pos,e)" : "out"},new _SP(pos,e)))
|
|
11349
11383
|
EC.e=e
|
|
11350
11384
|
return out
|
|
11351
11385
|
}`;
|
|
@@ -11369,7 +11403,7 @@ ${hasSuffix && (lineFlags & 2) !== 0 ? "if(sm)_trackLines(ctx,input,e)" : ""}
|
|
|
11369
11403
|
${hasSuffix ? `if(!sm){ctx._fe=e;ctx._fx=${suffixExpected};if(ctx._probe!==undefined)failAt(ctx,${suffixExpected},e)}` : ""}
|
|
11370
11404
|
const v=${pending ? "tp?_pfTokValue:" : ""}input.slice(pos,e)
|
|
11371
11405
|
${pending ? "if(tp){_pfTokBody=-1;_pfTokValue=undefined}" : ""}
|
|
11372
|
-
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,
|
|
11406
|
+
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
11373
11407
|
EC.e=e
|
|
11374
11408
|
return v
|
|
11375
11409
|
}`;
|
|
@@ -11408,7 +11442,7 @@ ctx._rootTriviaLog=sRtl
|
|
|
11408
11442
|
}
|
|
11409
11443
|
if(e<0)return FAIL
|
|
11410
11444
|
const v=input.slice(pos,e)
|
|
11411
|
-
if(wasCap)pushCstLeaf(ctx,
|
|
11445
|
+
if(wasCap)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
11412
11446
|
EC.e=e
|
|
11413
11447
|
return v
|
|
11414
11448
|
}`;
|
|
@@ -11416,7 +11450,7 @@ return v
|
|
|
11416
11450
|
const e=${run2}(input,pos,ctx)
|
|
11417
11451
|
if(e<0)return FAIL
|
|
11418
11452
|
const v=input.slice(pos,e)
|
|
11419
|
-
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,
|
|
11453
|
+
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
11420
11454
|
EC.e=e
|
|
11421
11455
|
return v
|
|
11422
11456
|
}`;
|
|
@@ -11530,7 +11564,7 @@ return v
|
|
|
11530
11564
|
}` : `${parts.join("\n")}
|
|
11531
11565
|
}`;
|
|
11532
11566
|
if (n === 1) {
|
|
11533
|
-
parts.push(fused ? projection === 0 ? "return v0" : `return ${fn}([v0],
|
|
11567
|
+
parts.push(fused ? projection === 0 ? "return v0" : `return ${fn}([v0],new _SP(pos,EC.e))` : wantValues ? "return [v0]" : "return undefined");
|
|
11534
11568
|
return close();
|
|
11535
11569
|
}
|
|
11536
11570
|
parts.push("let cur=EC.e");
|
|
@@ -11556,7 +11590,7 @@ return v
|
|
|
11556
11590
|
names.push(vn);
|
|
11557
11591
|
}
|
|
11558
11592
|
parts.push("EC.e=cur");
|
|
11559
|
-
parts.push(fused ? projection >= 0 ? `return ${names[projection]}` : `return ${fn}([${names.join(",")}],
|
|
11593
|
+
parts.push(fused ? projection >= 0 ? `return ${names[projection]}` : `return ${fn}([${names.join(",")}],new _SP(pos,cur))` : wantValues ? `return [${names.join(",")}]` : "return undefined");
|
|
11560
11594
|
return close();
|
|
11561
11595
|
}
|
|
11562
11596
|
case OP_CHOICE: {
|
|
@@ -11815,7 +11849,7 @@ ${spec.match.map((m, i) => `${i === 0 ? "" : "else "}if(${dispatchClaim(m)})arm=
|
|
|
11815
11849
|
const routedCall = (target) => `{const savedRouted=ctx._routed
|
|
11816
11850
|
${emitRollback(m1, L.buf, L.raw, sinks)}
|
|
11817
11851
|
${emitMark(m2, L.buf, L.raw, sinks, false)}
|
|
11818
|
-
ctx._routed={value:key,span:
|
|
11852
|
+
ctx._routed={value:key,span:new _SP(pos,selEnd)}
|
|
11819
11853
|
try{v=${target}(input,pos,ctx)}finally{ctx._routed=savedRouted}
|
|
11820
11854
|
break}`;
|
|
11821
11855
|
const plainCall = (target) => `v=${target}(input,selEnd,ctx);break`;
|
|
@@ -12010,8 +12044,8 @@ return out
|
|
|
12010
12044
|
const end=${recognize}(input,pos)
|
|
12011
12045
|
if(end<0){ctx._fe=pos;ctx._fx=${xf};return FAIL}
|
|
12012
12046
|
const value=${value2}
|
|
12013
|
-
const leaf=
|
|
12014
|
-
const kids=[leaf],rawKids=[leaf],span=
|
|
12047
|
+
const leaf=new _LF(value,new _SP(pos,end))
|
|
12048
|
+
const kids=[leaf],rawKids=[leaf],span=new _SP(pos,end)
|
|
12015
12049
|
EC.e=end
|
|
12016
12050
|
const nd=${build2}(kids,undefined,span,rawKids,EMPTY_TL,undefined)
|
|
12017
12051
|
${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 +12144,7 @@ ctx._cstTriviaLog=sTl
|
|
|
12110
12144
|
ctx.captureTrivia=sCap
|
|
12111
12145
|
if(v===FAIL)return FAIL
|
|
12112
12146
|
const end=EC.e
|
|
12113
|
-
${collapseChildren ? `const nd=captured.length===1?captured[0]:${build}(captured,undefined,
|
|
12147
|
+
${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
12148
|
${publish}
|
|
12115
12149
|
EC.e=end
|
|
12116
12150
|
return nd
|
|
@@ -12133,20 +12167,20 @@ return nd
|
|
|
12133
12167
|
const direct = `${build}(kids,fieldMap,span,rawKids,${captureWide ? "tlog" : "EMPTY_TL"},st)`;
|
|
12134
12168
|
value = hostCst ? `nd=_pfHost!==undefined?${hostCall}:${direct}` : `nd=${direct}`;
|
|
12135
12169
|
} else {
|
|
12136
|
-
value = `nd=_pfHost!==undefined?_pfHost(${ty},hostKids,fieldMap,span,rawKids,tlog,st,${tags}):{
|
|
12170
|
+
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
12171
|
}
|
|
12138
12172
|
const collapsible = keepChildren && (hostCst || build === void 0 && proj < 0);
|
|
12139
|
-
const openCapture = omitsRaw ? `const buf=
|
|
12173
|
+
const openCapture = omitsRaw ? `const buf=new _BUF(undefined,true,0)
|
|
12140
12174
|
ctx._cstBuf=buf
|
|
12141
12175
|
ctx._cstChildren=undefined
|
|
12142
12176
|
ctx._cstLeaves=undefined
|
|
12143
12177
|
ctx._cstRawChildren=undefined
|
|
12144
|
-
ctx._cstTriviaLog=undefined` : keepChildren ? `const buf=
|
|
12178
|
+
ctx._cstTriviaLog=undefined` : keepChildren ? `const buf=new _BUF(undefined,undefined,0)
|
|
12145
12179
|
ctx._cstBuf=buf
|
|
12146
12180
|
ctx._cstChildren=undefined
|
|
12147
12181
|
ctx._cstLeaves=undefined
|
|
12148
12182
|
ctx._cstRawChildren=undefined
|
|
12149
|
-
ctx._cstTriviaLog=undefined` : `const buf=
|
|
12183
|
+
ctx._cstTriviaLog=undefined` : `const buf=new _BUF(true,undefined,0)
|
|
12150
12184
|
ctx._cstBuf=buf
|
|
12151
12185
|
ctx._cstChildren=undefined
|
|
12152
12186
|
ctx._cstLeaves=undefined
|
|
@@ -12184,7 +12218,7 @@ ctx._cstTriviaLog=sTl
|
|
|
12184
12218
|
ctx.captureTrivia=sCap
|
|
12185
12219
|
if(v===FAIL)return FAIL
|
|
12186
12220
|
const end=EC.e
|
|
12187
|
-
const span=${tracked ? "spanLines(ctx,pos,end)" : "
|
|
12221
|
+
const span=${tracked ? "spanLines(ctx,pos,end)" : "new _SP(pos,end)"}
|
|
12188
12222
|
const st=${readsState ? "ctx.state" : "undefined"}
|
|
12189
12223
|
let nd
|
|
12190
12224
|
${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 +12505,7 @@ function rebuildLineScan(s, subtree) {
|
|
|
12471
12505
|
}
|
|
12472
12506
|
|
|
12473
12507
|
// src/combinators/scanTo.ts
|
|
12508
|
+
import { PlainLeaf as PlainLeaf8, PlainSpan as PlainSpan9 } from "../cst/plain.js";
|
|
12474
12509
|
function resolveScanSkip(explicitSkip, raw, ctx) {
|
|
12475
12510
|
if (raw) return [];
|
|
12476
12511
|
const trivia2 = ctx.trivia;
|
|
@@ -12508,7 +12543,7 @@ function scanTo(sentinel, { skip, raw = false, orEOF = false, recoverAt, stopAt
|
|
|
12508
12543
|
probeCtx._errors = ctx._errors;
|
|
12509
12544
|
const emit = (end) => {
|
|
12510
12545
|
if (end > pos && cstCaptureActive(ctx)) {
|
|
12511
|
-
const leaf2 =
|
|
12546
|
+
const leaf2 = new PlainLeaf8(input.slice(pos, end), new PlainSpan9(pos, end));
|
|
12512
12547
|
pushCstLeaf(ctx, leaf2);
|
|
12513
12548
|
}
|
|
12514
12549
|
};
|
|
@@ -12787,6 +12822,9 @@ function clearOf(ranges, input, from, to) {
|
|
|
12787
12822
|
return true;
|
|
12788
12823
|
}
|
|
12789
12824
|
|
|
12825
|
+
// src/table/assemble.ts
|
|
12826
|
+
import { PlainBuf as PlainBuf2, PlainField, PlainLeaf as PlainLeaf9, PlainNode as PlainNode2, PlainSpan as PlainSpan10 } from "../cst/plain.js";
|
|
12827
|
+
|
|
12790
12828
|
// src/table/fail-clean.ts
|
|
12791
12829
|
function passChild(code, ip) {
|
|
12792
12830
|
switch (code[ip]) {
|
|
@@ -13114,7 +13152,7 @@ function assemble(t, prog, cfg) {
|
|
|
13114
13152
|
const NULLABLE = /* @__PURE__ */ new Map();
|
|
13115
13153
|
const CLEAN = REC2 ? () => false : failCleanAnalysis(code);
|
|
13116
13154
|
function pushLeaf(ctx, value, s, e) {
|
|
13117
|
-
const lf =
|
|
13155
|
+
const lf = new PlainLeaf9(value, new PlainSpan10(s, e));
|
|
13118
13156
|
pushCstLeaf(ctx, lf);
|
|
13119
13157
|
}
|
|
13120
13158
|
function plainBuildNode(child, build, trailing) {
|
|
@@ -13147,7 +13185,7 @@ function assemble(t, prog, cfg) {
|
|
|
13147
13185
|
ctx.captureTrivia = sCap;
|
|
13148
13186
|
if (value === FAIL) return FAIL;
|
|
13149
13187
|
const end = EC.e;
|
|
13150
|
-
const span =
|
|
13188
|
+
const span = new PlainSpan10(pos, end);
|
|
13151
13189
|
const node2 = build(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
|
|
13152
13190
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13153
13191
|
pushCstChild(ctx, node2, rawEntry(node2, input, pos, end));
|
|
@@ -13192,7 +13230,7 @@ function assemble(t, prog, cfg) {
|
|
|
13192
13230
|
ctx.captureTrivia = sCap;
|
|
13193
13231
|
if (value === FAIL) return FAIL;
|
|
13194
13232
|
const end = EC.e;
|
|
13195
|
-
const node2 = build(captured, void 0,
|
|
13233
|
+
const node2 = build(captured, void 0, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
|
|
13196
13234
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13197
13235
|
pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
|
|
13198
13236
|
}
|
|
@@ -13229,7 +13267,7 @@ function assemble(t, prog, cfg) {
|
|
|
13229
13267
|
ctx.captureTrivia = sCap;
|
|
13230
13268
|
if (value === FAIL) return FAIL;
|
|
13231
13269
|
const end = EC.e;
|
|
13232
|
-
const node2 = build(captured, fieldMap,
|
|
13270
|
+
const node2 = build(captured, fieldMap, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
|
|
13233
13271
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13234
13272
|
pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
|
|
13235
13273
|
}
|
|
@@ -13266,7 +13304,7 @@ function assemble(t, prog, cfg) {
|
|
|
13266
13304
|
ctx.captureTrivia = sCap;
|
|
13267
13305
|
if (value === FAIL) return FAIL;
|
|
13268
13306
|
const end = EC.e;
|
|
13269
|
-
const span =
|
|
13307
|
+
const span = new PlainSpan10(pos, end);
|
|
13270
13308
|
const node2 = kids.length === 1 ? kids[0] : build(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
|
|
13271
13309
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13272
13310
|
pushCstChild(ctx, node2, rawEntry(node2, input, pos, end));
|
|
@@ -13303,7 +13341,7 @@ function assemble(t, prog, cfg) {
|
|
|
13303
13341
|
ctx.captureTrivia = sCap;
|
|
13304
13342
|
if (value === FAIL) return FAIL;
|
|
13305
13343
|
const end = EC.e;
|
|
13306
|
-
const node2 = captured.length === 1 ? captured[0] : build(captured, void 0,
|
|
13344
|
+
const node2 = captured.length === 1 ? captured[0] : build(captured, void 0, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
|
|
13307
13345
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13308
13346
|
pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
|
|
13309
13347
|
}
|
|
@@ -13736,7 +13774,7 @@ function assemble(t, prog, cfg) {
|
|
|
13736
13774
|
return (input, pos, selEnd, key, ctx, need, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot) => {
|
|
13737
13775
|
const savedRouted = ctx._routed;
|
|
13738
13776
|
if (need) rollbackTriviaAt(ctx, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot);
|
|
13739
|
-
ctx._routed = { value: key, span:
|
|
13777
|
+
ctx._routed = { value: key, span: new PlainSpan10(pos, selEnd) };
|
|
13740
13778
|
let v;
|
|
13741
13779
|
try {
|
|
13742
13780
|
v = child(input, pos, ctx);
|
|
@@ -14169,7 +14207,7 @@ function assemble(t, prog, cfg) {
|
|
|
14169
14207
|
case OP_EXPECT: {
|
|
14170
14208
|
const child = link(code[ip + 1]);
|
|
14171
14209
|
const xf = fx[code[ip + 2]];
|
|
14172
|
-
const expectSpan = (ctx, pos) => prog.lines === 1 ? spanLines(ctx, pos, pos) :
|
|
14210
|
+
const expectSpan = (ctx, pos) => prog.lines === 1 ? spanLines(ctx, pos, pos) : new PlainSpan10(pos, pos);
|
|
14173
14211
|
if (REC2) {
|
|
14174
14212
|
return (input, pos, ctx) => {
|
|
14175
14213
|
const v = child(input, pos, ctx);
|
|
@@ -14201,7 +14239,7 @@ function assemble(t, prog, cfg) {
|
|
|
14201
14239
|
return (input, pos, ctx) => {
|
|
14202
14240
|
const v = child(input, pos, ctx);
|
|
14203
14241
|
if (v === FAIL) return FAIL;
|
|
14204
|
-
ctx._fields?.push(
|
|
14242
|
+
ctx._fields?.push(new PlainField(name, v, new PlainSpan10(pos, EC.e)));
|
|
14205
14243
|
return v;
|
|
14206
14244
|
};
|
|
14207
14245
|
}
|
|
@@ -14225,7 +14263,7 @@ function assemble(t, prog, cfg) {
|
|
|
14225
14263
|
return (input, pos, ctx) => {
|
|
14226
14264
|
const v = child(input, pos, ctx);
|
|
14227
14265
|
if (v === FAIL) return FAIL;
|
|
14228
|
-
return fn(v,
|
|
14266
|
+
return fn(v, new PlainSpan10(pos, EC.e));
|
|
14229
14267
|
};
|
|
14230
14268
|
}
|
|
14231
14269
|
case OP_SCAN: {
|
|
@@ -14329,7 +14367,7 @@ function assemble(t, prog, cfg) {
|
|
|
14329
14367
|
ctx._fx = ROUTED_FX;
|
|
14330
14368
|
return FAIL;
|
|
14331
14369
|
}
|
|
14332
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
14370
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(item.value, item.span));
|
|
14333
14371
|
EC.e = item.span.end;
|
|
14334
14372
|
return item.value;
|
|
14335
14373
|
};
|
|
@@ -14515,7 +14553,7 @@ function assemble(t, prog, cfg) {
|
|
|
14515
14553
|
if (v === FAIL) return FAIL;
|
|
14516
14554
|
const end = EC.e;
|
|
14517
14555
|
const value = input.slice(pos, end);
|
|
14518
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
14556
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
|
|
14519
14557
|
EC.e = end;
|
|
14520
14558
|
return value;
|
|
14521
14559
|
};
|
|
@@ -14549,7 +14587,7 @@ function assemble(t, prog, cfg) {
|
|
|
14549
14587
|
if (ctx._probe !== void 0) failAt(ctx, suffixExpected, end);
|
|
14550
14588
|
}
|
|
14551
14589
|
const value = input.slice(pos, end);
|
|
14552
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
14590
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
|
|
14553
14591
|
EC.e = end;
|
|
14554
14592
|
return value;
|
|
14555
14593
|
};
|
|
@@ -14592,7 +14630,7 @@ function assemble(t, prog, cfg) {
|
|
|
14592
14630
|
}
|
|
14593
14631
|
if (end < 0) return FAIL;
|
|
14594
14632
|
const value = input.slice(pos, end);
|
|
14595
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
14633
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
|
|
14596
14634
|
EC.e = end;
|
|
14597
14635
|
return value;
|
|
14598
14636
|
};
|
|
@@ -14601,7 +14639,7 @@ function assemble(t, prog, cfg) {
|
|
|
14601
14639
|
const end = run2(input, pos, ctx);
|
|
14602
14640
|
if (end < 0) return FAIL;
|
|
14603
14641
|
const value = input.slice(pos, end);
|
|
14604
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
14642
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
|
|
14605
14643
|
EC.e = end;
|
|
14606
14644
|
return value;
|
|
14607
14645
|
};
|
|
@@ -14634,12 +14672,8 @@ function assemble(t, prog, cfg) {
|
|
|
14634
14672
|
}
|
|
14635
14673
|
if (v === FAIL) return FAIL;
|
|
14636
14674
|
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
|
-
});
|
|
14675
|
+
const out = fn(v, new PlainSpan10(pos, end));
|
|
14676
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(op === OP_SOURCE_LEAF && hostCst ? input.slice(pos, end) : out, new PlainSpan10(pos, end)));
|
|
14643
14677
|
EC.e = end;
|
|
14644
14678
|
return out;
|
|
14645
14679
|
};
|
|
@@ -14774,7 +14808,7 @@ function assemble(t, prog, cfg) {
|
|
|
14774
14808
|
const cur = runSyncTerms(input, pos, ctx, values);
|
|
14775
14809
|
if (cur < 0) return FAIL;
|
|
14776
14810
|
EC.e = cur;
|
|
14777
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
14811
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
|
|
14778
14812
|
};
|
|
14779
14813
|
}
|
|
14780
14814
|
if (wantValues) {
|
|
@@ -14868,7 +14902,7 @@ function assemble(t, prog, cfg) {
|
|
|
14868
14902
|
const cur = runAdjTerms(input, pos, ctx, values);
|
|
14869
14903
|
if (cur < 0) return FAIL;
|
|
14870
14904
|
EC.e = cur;
|
|
14871
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
14905
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
|
|
14872
14906
|
};
|
|
14873
14907
|
}
|
|
14874
14908
|
if (wantValues) {
|
|
@@ -14893,7 +14927,7 @@ function assemble(t, prog, cfg) {
|
|
|
14893
14927
|
return (input, pos, ctx) => {
|
|
14894
14928
|
const v = k0(input, pos, ctx);
|
|
14895
14929
|
if (v === FAIL) return FAIL;
|
|
14896
|
-
return projection === 0 ? v : fn([v],
|
|
14930
|
+
return projection === 0 ? v : fn([v], new PlainSpan10(pos, EC.e));
|
|
14897
14931
|
};
|
|
14898
14932
|
}
|
|
14899
14933
|
if (wantValues) {
|
|
@@ -14918,7 +14952,7 @@ function assemble(t, prog, cfg) {
|
|
|
14918
14952
|
const cur = step(k1, input, EC.e, ctx);
|
|
14919
14953
|
if (cur < 0) return FAIL;
|
|
14920
14954
|
EC.e = cur;
|
|
14921
|
-
return projection === 0 ? v0 : projection === 1 ? TERMV : fn([v0, TERMV],
|
|
14955
|
+
return projection === 0 ? v0 : projection === 1 ? TERMV : fn([v0, TERMV], new PlainSpan10(pos, cur));
|
|
14922
14956
|
};
|
|
14923
14957
|
}
|
|
14924
14958
|
if (wantValues) {
|
|
@@ -14952,7 +14986,7 @@ function assemble(t, prog, cfg) {
|
|
|
14952
14986
|
cur = step(k2, input, cur, ctx);
|
|
14953
14987
|
if (cur < 0) return FAIL;
|
|
14954
14988
|
EC.e = cur;
|
|
14955
|
-
return projection === 0 ? v0 : projection === 1 ? v1 : projection === 2 ? TERMV : fn([v0, v1, TERMV],
|
|
14989
|
+
return projection === 0 ? v0 : projection === 1 ? v1 : projection === 2 ? TERMV : fn([v0, v1, TERMV], new PlainSpan10(pos, cur));
|
|
14956
14990
|
};
|
|
14957
14991
|
}
|
|
14958
14992
|
if (wantValues) {
|
|
@@ -15049,7 +15083,7 @@ function assemble(t, prog, cfg) {
|
|
|
15049
15083
|
const cur = runDirectTerms(input, pos, ctx, values);
|
|
15050
15084
|
if (cur < 0) return FAIL;
|
|
15051
15085
|
EC.e = cur;
|
|
15052
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
15086
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
|
|
15053
15087
|
};
|
|
15054
15088
|
}
|
|
15055
15089
|
if (wantValues) {
|
|
@@ -15947,10 +15981,10 @@ function assemble(t, prog, cfg) {
|
|
|
15947
15981
|
return FAIL;
|
|
15948
15982
|
}
|
|
15949
15983
|
const value = regexValue ? input.slice(pos, end) : spec;
|
|
15950
|
-
const leaf2 =
|
|
15984
|
+
const leaf2 = new PlainLeaf9(value, new PlainSpan10(pos, end));
|
|
15951
15985
|
const kids = [leaf2];
|
|
15952
15986
|
const rawKids = [leaf2];
|
|
15953
|
-
const span =
|
|
15987
|
+
const span = new PlainSpan10(pos, end);
|
|
15954
15988
|
EC.e = end;
|
|
15955
15989
|
const nd = build2(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
|
|
15956
15990
|
if (ctx._cstBuf !== void 0 || ctx._cstChildren !== void 0) {
|
|
@@ -16032,7 +16066,7 @@ function assemble(t, prog, cfg) {
|
|
|
16032
16066
|
const sCh = ctx._cstChildren;
|
|
16033
16067
|
const sCap = ctx.captureTrivia;
|
|
16034
16068
|
const sBuf = ctx._cstBuf;
|
|
16035
|
-
const buf = rawOnly ?
|
|
16069
|
+
const buf = rawOnly ? new PlainBuf2(true, void 0, 0) : omitsRaw ? new PlainBuf2(void 0, true, 0) : new PlainBuf2(void 0, void 0, 0);
|
|
16036
16070
|
ctx._cstBuf = buf;
|
|
16037
16071
|
ctx.captureTrivia = captureWide;
|
|
16038
16072
|
const savedFields = ctx._fields;
|
|
@@ -16054,7 +16088,7 @@ function assemble(t, prog, cfg) {
|
|
|
16054
16088
|
ctx.captureTrivia = sCap;
|
|
16055
16089
|
if (v === FAIL) return FAIL;
|
|
16056
16090
|
const end = EC.e;
|
|
16057
|
-
const span = tracked ? spanLines(ctx, pos, end) :
|
|
16091
|
+
const span = tracked ? spanLines(ctx, pos, end) : new PlainSpan10(pos, end);
|
|
16058
16092
|
const st = readsState ? ctx.state : void 0;
|
|
16059
16093
|
let nd;
|
|
16060
16094
|
if (unwrap && kids.length === 1) {
|
|
@@ -16078,7 +16112,7 @@ function assemble(t, prog, cfg) {
|
|
|
16078
16112
|
} else if (host !== void 0) {
|
|
16079
16113
|
nd = host(type, hostKids, fieldMap, span, rawKids, tlog, st, tags);
|
|
16080
16114
|
} else {
|
|
16081
|
-
nd =
|
|
16115
|
+
nd = new PlainNode2(type, span, st ?? null, kids === EMPTY_CH ? kids : [...kids]);
|
|
16082
16116
|
}
|
|
16083
16117
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
16084
16118
|
pushCstChild(ctx, nd, rawEntry(nd, input, pos, end));
|
|
@@ -16104,7 +16138,7 @@ function assemble(t, prog, cfg) {
|
|
|
16104
16138
|
const at = fe === void 0 || fe < 0 ? pos : fe;
|
|
16105
16139
|
return { ok: false, expected: ctx._fx ?? EMPTY_FX2, span: { start: at, end: at } };
|
|
16106
16140
|
}
|
|
16107
|
-
return { ok: true, value: v, span:
|
|
16141
|
+
return { ok: true, value: v, span: new PlainSpan10(pos, EC.e) };
|
|
16108
16142
|
}
|
|
16109
16143
|
};
|
|
16110
16144
|
}
|
|
@@ -16219,7 +16253,12 @@ function assemble(t, prog, cfg) {
|
|
|
16219
16253
|
LEAD,
|
|
16220
16254
|
triviaFieldCapture,
|
|
16221
16255
|
skipDeferredTrivia,
|
|
16222
|
-
collapseEmpty
|
|
16256
|
+
collapseEmpty,
|
|
16257
|
+
PlainSpan10,
|
|
16258
|
+
PlainLeaf9,
|
|
16259
|
+
PlainNode2,
|
|
16260
|
+
PlainField,
|
|
16261
|
+
PlainBuf2
|
|
16223
16262
|
);
|
|
16224
16263
|
emitReached = new Set(pre.reached);
|
|
16225
16264
|
if (emitted.ext !== void 0) HYBRID = emitted;
|
|
@@ -16306,7 +16345,12 @@ function assemble(t, prog, cfg) {
|
|
|
16306
16345
|
LEAD,
|
|
16307
16346
|
triviaFieldCapture,
|
|
16308
16347
|
skipDeferredTrivia,
|
|
16309
|
-
collapseEmpty
|
|
16348
|
+
collapseEmpty,
|
|
16349
|
+
PlainSpan10,
|
|
16350
|
+
PlainLeaf9,
|
|
16351
|
+
PlainNode2,
|
|
16352
|
+
PlainField,
|
|
16353
|
+
PlainBuf2
|
|
16310
16354
|
);
|
|
16311
16355
|
emitReached = em.reached;
|
|
16312
16356
|
} catch (e) {
|
|
@@ -16575,7 +16619,11 @@ function tableRules(source, metadataOrEntry = {}) {
|
|
|
16575
16619
|
return map[entry];
|
|
16576
16620
|
}
|
|
16577
16621
|
|
|
16622
|
+
// src/version.ts
|
|
16623
|
+
var PARSEMAN_VERSION = "0.59.0";
|
|
16624
|
+
|
|
16578
16625
|
// src/table/emit.ts
|
|
16626
|
+
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
16627
|
function jsString(s) {
|
|
16580
16628
|
return JSON.stringify(s);
|
|
16581
16629
|
}
|
|
@@ -16661,7 +16709,7 @@ function emitAssemblies(prog, cfgs) {
|
|
|
16661
16709
|
throw e;
|
|
16662
16710
|
}
|
|
16663
16711
|
const plan = em.plan;
|
|
16664
|
-
out.push(`{key:${key},factory:function(${EMITTED_PARAMS.join(",")}){${em.source}
|
|
16712
|
+
out.push(`{key:${key},factory:function(${EMITTED_PARAMS.join(",")}){${FACTORY_ARITY_GUARD}${em.source}
|
|
16665
16713
|
},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
16714
|
}
|
|
16667
16715
|
return [`a:[${out.join(",")}],`];
|
|
@@ -19021,9 +19069,6 @@ function fieldOptionsSrc(def) {
|
|
|
19021
19069
|
return `, { ${[def.leadingTrivia === true ? "leadingTrivia: true" : "", def.trailingTrivia === true ? "trailingTrivia: true" : ""].filter(Boolean).join(", ")} }`;
|
|
19022
19070
|
}
|
|
19023
19071
|
|
|
19024
|
-
// src/version.ts
|
|
19025
|
-
var PARSEMAN_VERSION = "0.58.3";
|
|
19026
|
-
|
|
19027
19072
|
// src/compiler/compile-linkable-table.ts
|
|
19028
19073
|
function isLocal(rule) {
|
|
19029
19074
|
const d = rule._def;
|
|
@@ -19090,6 +19135,7 @@ function compileLinkableTable(ruleMapArg, ns, opts = {}) {
|
|
|
19090
19135
|
}
|
|
19091
19136
|
|
|
19092
19137
|
// src/compiler/linker.ts
|
|
19138
|
+
import { PlainNode as PlainNode3, PlainTaggedNode } from "../cst/plain.js";
|
|
19093
19139
|
function normalizeCstCollapse(collapse) {
|
|
19094
19140
|
if (collapse === true) return () => true;
|
|
19095
19141
|
if (Array.isArray(collapse)) {
|
|
@@ -19099,7 +19145,7 @@ function normalizeCstCollapse(collapse) {
|
|
|
19099
19145
|
return typeof collapse === "function" ? collapse : void 0;
|
|
19100
19146
|
}
|
|
19101
19147
|
function buildCstNode(type, children3, _fields, span, _rawChildren, _triviaLog, state, tags) {
|
|
19102
|
-
return tags !== void 0 && tags.length > 0 ?
|
|
19148
|
+
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
19149
|
}
|
|
19104
19150
|
function cstBuildHost(typeOrOptions, children3, _fields, span, rawChildren, triviaLog, state, _tags) {
|
|
19105
19151
|
if (typeof typeOrOptions === "string") {
|
|
@@ -21554,8 +21600,8 @@ function supercompileRuleMapReplacement(prog, replacement, select) {
|
|
|
21554
21600
|
if (typeof body.start !== "number" || typeof body.end !== "number") return replacement;
|
|
21555
21601
|
const start = body.start - prefix.length + 1;
|
|
21556
21602
|
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);
|
|
21603
|
+
if (replacement.slice(start, end) !== FACTORY_ARITY_GUARD + canonical2.source + "\n") return replacement;
|
|
21604
|
+
const transformed = replacement.slice(0, start) + FACTORY_ARITY_GUARD + candidate.source + "\n" + replacement.slice(end);
|
|
21559
21605
|
const checked = parseSync4("parseman-entry-supercompile-replacement-result.js", prefix + transformed);
|
|
21560
21606
|
return checked.errors.length === 0 ? transformed : replacement;
|
|
21561
21607
|
}
|