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/cli/index.js
CHANGED
|
@@ -725,6 +725,7 @@ function analyzeChoice(p, d, rule2, resolve2) {
|
|
|
725
725
|
}
|
|
726
726
|
|
|
727
727
|
// src/line-index.ts
|
|
728
|
+
import { PlainLineSpan, PlainSpan } from "../cst/plain.js";
|
|
728
729
|
function createLineIndex() {
|
|
729
730
|
return { lineStarts: [0] };
|
|
730
731
|
}
|
|
@@ -777,6 +778,27 @@ function annotateSpan(span, index) {
|
|
|
777
778
|
endColumn: e.col
|
|
778
779
|
};
|
|
779
780
|
}
|
|
781
|
+
var SPAN_KEYS = ["start", "end", "startLine", "startColumn", "endLine", "endColumn"];
|
|
782
|
+
function copySpan(span) {
|
|
783
|
+
let n = 0;
|
|
784
|
+
for (const key in span) {
|
|
785
|
+
if (key !== SPAN_KEYS[n]) return { ...span };
|
|
786
|
+
n++;
|
|
787
|
+
}
|
|
788
|
+
if (n === 2) return new PlainSpan(span.start, span.end);
|
|
789
|
+
if (n === 6 && span.startLine !== void 0 && span.startColumn !== void 0 && span.endLine !== void 0 && span.endColumn !== void 0) {
|
|
790
|
+
return new PlainLineSpan(span.start, span.end, span.startLine, span.startColumn, span.endLine, span.endColumn);
|
|
791
|
+
}
|
|
792
|
+
return { ...span };
|
|
793
|
+
}
|
|
794
|
+
function lineSpanFromContext(span, ctx) {
|
|
795
|
+
if (!ctx.trackLines) return span;
|
|
796
|
+
const index = ctx._lineIndex ?? (ctx._lineStarts ? { lineStarts: ctx._lineStarts } : void 0);
|
|
797
|
+
if (!index) return span;
|
|
798
|
+
const s = offsetToLineCol(index, span.start);
|
|
799
|
+
const e = offsetToLineCol(index, span.end);
|
|
800
|
+
return new PlainLineSpan(span.start, span.end, s.line, s.col, e.line, e.col);
|
|
801
|
+
}
|
|
780
802
|
function annotateSpanFromLineContext(span, ctx) {
|
|
781
803
|
if (!ctx.trackLines) return span;
|
|
782
804
|
const index = ctx._lineIndex ?? (ctx._lineStarts ? { lineStarts: ctx._lineStarts } : void 0);
|
|
@@ -784,6 +806,7 @@ function annotateSpanFromLineContext(span, ctx) {
|
|
|
784
806
|
}
|
|
785
807
|
|
|
786
808
|
// src/cst/capture-buffer.ts
|
|
809
|
+
import { PlainBuf, PlainLeaf } from "../cst/plain.js";
|
|
787
810
|
var EMPTY = [];
|
|
788
811
|
var EMPTY_TL = [];
|
|
789
812
|
function cstCaptureActive(ctx) {
|
|
@@ -798,7 +821,7 @@ function beginCstNodeCapture(ctx) {
|
|
|
798
821
|
cap: ctx.captureTrivia,
|
|
799
822
|
buf: ctx._cstBuf
|
|
800
823
|
};
|
|
801
|
-
ctx._cstBuf =
|
|
824
|
+
ctx._cstBuf = new PlainBuf(void 0, void 0, 0);
|
|
802
825
|
ctx._cstChildren = void 0;
|
|
803
826
|
ctx._cstLeaves = void 0;
|
|
804
827
|
ctx._cstRawChildren = void 0;
|
|
@@ -823,12 +846,15 @@ function endCstNodeCapture(ctx, saved) {
|
|
|
823
846
|
ctx.captureTrivia = saved.cap;
|
|
824
847
|
return materialized;
|
|
825
848
|
}
|
|
849
|
+
function isLeaf(v) {
|
|
850
|
+
return typeof v === "object" && v !== null && v._tag === "leaf";
|
|
851
|
+
}
|
|
826
852
|
function pushCstLeaf(ctx, leaf2) {
|
|
827
853
|
if (!ctx.trackLines) {
|
|
828
854
|
pushCstChild(ctx, leaf2, leaf2);
|
|
829
855
|
return;
|
|
830
856
|
}
|
|
831
|
-
const annotated = leaf2 && typeof leaf2 === "object" && leaf2.span ? { ...leaf2, span: annotateSpanFromLineContext(leaf2.span, ctx) } : leaf2;
|
|
857
|
+
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;
|
|
832
858
|
pushCstChild(ctx, annotated, annotated);
|
|
833
859
|
}
|
|
834
860
|
function pushCstChild(ctx, built, rawEntry2) {
|
|
@@ -2410,6 +2436,7 @@ function altStarSource(source) {
|
|
|
2410
2436
|
}
|
|
2411
2437
|
|
|
2412
2438
|
// src/combinators/dispatch.ts
|
|
2439
|
+
import { PlainLeaf as PlainLeaf2 } from "../cst/plain.js";
|
|
2413
2440
|
function parserUsesRouted(parser2, seen = /* @__PURE__ */ new Set()) {
|
|
2414
2441
|
if (seen.has(parser2)) return false;
|
|
2415
2442
|
seen.add(parser2);
|
|
@@ -2478,6 +2505,7 @@ function asciiFoldKey(key) {
|
|
|
2478
2505
|
}
|
|
2479
2506
|
|
|
2480
2507
|
// src/recovery/scan.ts
|
|
2508
|
+
import { PlainSpan as PlainSpan2 } from "../cst/plain.js";
|
|
2481
2509
|
function probeAt(sentinel, input, pos, ctx) {
|
|
2482
2510
|
const s = {
|
|
2483
2511
|
_probe: ctx._probe,
|
|
@@ -2554,7 +2582,7 @@ function firstSetSentinel(fs) {
|
|
|
2554
2582
|
function recoverScan(input, from, ctx, sync, expected) {
|
|
2555
2583
|
let scanPos = from;
|
|
2556
2584
|
while (scanPos < input.length && !probeAt(sync, input, scanPos, ctx)) scanPos++;
|
|
2557
|
-
const span =
|
|
2585
|
+
const span = new PlainSpan2(from, scanPos);
|
|
2558
2586
|
if (ctx.trackLines) recordLineRangeFromContext(ctx, input, from, scanPos);
|
|
2559
2587
|
const error = { _tag: "parseError", span: ctx.trackLines ? annotateSpanFromLineContext(span, ctx) : span, expected };
|
|
2560
2588
|
ctx._errors?.push(error);
|
|
@@ -2744,6 +2772,7 @@ function failAt(ctx, expected, pos) {
|
|
|
2744
2772
|
}
|
|
2745
2773
|
|
|
2746
2774
|
// src/combinators/keywords.ts
|
|
2775
|
+
import { PlainLeaf as PlainLeaf3, PlainSpan as PlainSpan3 } from "../cst/plain.js";
|
|
2747
2776
|
function escapeRe(s) {
|
|
2748
2777
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2749
2778
|
}
|
|
@@ -2792,8 +2821,8 @@ function keywords(words, opts = {}) {
|
|
|
2792
2821
|
const m = re.exec(input);
|
|
2793
2822
|
if (m === null) return failAt(ctx, directTerminalFailureExpected(def), pos);
|
|
2794
2823
|
const value = m[0];
|
|
2795
|
-
const span =
|
|
2796
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
2824
|
+
const span = new PlainSpan3(pos, pos + value.length);
|
|
2825
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf3(value, span));
|
|
2797
2826
|
return { ok: true, value, span };
|
|
2798
2827
|
}
|
|
2799
2828
|
};
|
|
@@ -4429,17 +4458,18 @@ function buildAsciiDispatch(parsers) {
|
|
|
4429
4458
|
}
|
|
4430
4459
|
|
|
4431
4460
|
// src/combinators/field-trivia.ts
|
|
4461
|
+
import { PlainSpan as PlainSpan4, PlainTriviaField } from "../cst/plain.js";
|
|
4432
4462
|
var LEAD = { at: -1 };
|
|
4433
4463
|
var FIELD_LEADING_TRIVIA = 1;
|
|
4434
4464
|
var FIELD_TRAILING_TRIVIA = 2;
|
|
4435
4465
|
function triviaFieldCapture(name, value, input, start, end, leadFrom, trailEnd) {
|
|
4436
|
-
return
|
|
4466
|
+
return new PlainTriviaField(
|
|
4437
4467
|
name,
|
|
4438
4468
|
value,
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4469
|
+
new PlainSpan4(start, end),
|
|
4470
|
+
leadFrom >= 0 && leadFrom < start ? input.slice(leadFrom, start) : "",
|
|
4471
|
+
trailEnd > end ? input.slice(end, trailEnd) : ""
|
|
4472
|
+
);
|
|
4443
4473
|
}
|
|
4444
4474
|
function leadsTrivia(p) {
|
|
4445
4475
|
return p._def.tag === "field" && p._def.leadingTrivia === true;
|
|
@@ -4955,6 +4985,7 @@ function field(name, combinator, opts) {
|
|
|
4955
4985
|
}
|
|
4956
4986
|
|
|
4957
4987
|
// src/combinators/regex.ts
|
|
4988
|
+
import { PlainLeaf as PlainLeaf4, PlainSpan as PlainSpan5 } from "../cst/plain.js";
|
|
4958
4989
|
var SCAN_BAIL_AT = 64;
|
|
4959
4990
|
function inRanges3(cp, ranges) {
|
|
4960
4991
|
for (let i = 0; i < ranges.length; i++) {
|
|
@@ -5067,9 +5098,9 @@ function regex(pattern, flags = "") {
|
|
|
5067
5098
|
if (scanEnd !== void 0) {
|
|
5068
5099
|
if (scanEnd === null) return failAt(ctx, directTerminalFailureExpected(def), pos);
|
|
5069
5100
|
const value = input.slice(pos, scanEnd);
|
|
5070
|
-
const span2 =
|
|
5101
|
+
const span2 = new PlainSpan5(pos, scanEnd);
|
|
5071
5102
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, scanEnd);
|
|
5072
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
5103
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf4(value, span2));
|
|
5073
5104
|
return { ok: true, value, span: span2 };
|
|
5074
5105
|
}
|
|
5075
5106
|
anchored.lastIndex = pos;
|
|
@@ -5077,9 +5108,9 @@ function regex(pattern, flags = "") {
|
|
|
5077
5108
|
if (m === null) {
|
|
5078
5109
|
return failAt(ctx, directTerminalFailureExpected(def), pos);
|
|
5079
5110
|
}
|
|
5080
|
-
const span =
|
|
5111
|
+
const span = new PlainSpan5(pos, pos + m[0].length);
|
|
5081
5112
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, span.end);
|
|
5082
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
5113
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf4(m[0], span));
|
|
5083
5114
|
return { ok: true, value: m[0], span };
|
|
5084
5115
|
}
|
|
5085
5116
|
};
|
|
@@ -5106,6 +5137,7 @@ function buildLexBodyRecognizer(spec, constants) {
|
|
|
5106
5137
|
}
|
|
5107
5138
|
|
|
5108
5139
|
// src/table/run-support.ts
|
|
5140
|
+
import { PlainLeaf as PlainLeaf5, PlainLineSpan as PlainLineSpan2, PlainSpan as PlainSpan6 } from "../cst/plain.js";
|
|
5109
5141
|
function lineCol(ctx, offset) {
|
|
5110
5142
|
const starts = ctx._lineStarts ?? [0];
|
|
5111
5143
|
let lo = 0, hi = starts.length - 1;
|
|
@@ -5118,18 +5150,14 @@ function lineCol(ctx, offset) {
|
|
|
5118
5150
|
}
|
|
5119
5151
|
function spanLines(ctx, start, end) {
|
|
5120
5152
|
const s = lineCol(ctx, start), e = lineCol(ctx, end);
|
|
5121
|
-
return
|
|
5153
|
+
return new PlainLineSpan2(start, end, s[0], s[1], e[0], e[1]);
|
|
5122
5154
|
}
|
|
5123
5155
|
function rawEntry(v, input, s, e) {
|
|
5124
5156
|
if (typeof v === "object" && v !== null) {
|
|
5125
5157
|
const tg = v._tag;
|
|
5126
5158
|
if (tg === "node" || tg === "leaf" || tg === "parseError") return v;
|
|
5127
5159
|
}
|
|
5128
|
-
return
|
|
5129
|
-
_tag: "leaf",
|
|
5130
|
-
value: typeof v === "string" ? v : typeof v === "object" && v !== null ? input.slice(s, e) : "",
|
|
5131
|
-
span: { start: s, end: e }
|
|
5132
|
-
};
|
|
5160
|
+
return new PlainLeaf5(typeof v === "string" ? v : typeof v === "object" && v !== null ? input.slice(s, e) : "", new PlainSpan6(s, e));
|
|
5133
5161
|
}
|
|
5134
5162
|
function lead(input, pos) {
|
|
5135
5163
|
if (pos >= input.length) return -1;
|
|
@@ -5143,7 +5171,7 @@ function collapseEmpty(ctx, build, input, pos, end, readsRaw) {
|
|
|
5143
5171
|
const collected = ctx._cstBuf !== void 0 || ctx._cstChildren !== void 0;
|
|
5144
5172
|
if (collected) popCstChild(ctx);
|
|
5145
5173
|
const raw = readsRaw ? [rawEntry(void 0, input, pos, end)] : EMPTY_KIDS;
|
|
5146
|
-
const nd = build(EMPTY_KIDS, void 0,
|
|
5174
|
+
const nd = build(EMPTY_KIDS, void 0, new PlainSpan6(pos, end), raw, EMPTY_TRIVIA, void 0);
|
|
5147
5175
|
if (collected) pushCstChild(ctx, nd, ctx._cstBuf?.noRaw === true ? void 0 : rawEntry(nd, input, pos, end));
|
|
5148
5176
|
return nd;
|
|
5149
5177
|
}
|
|
@@ -6365,6 +6393,7 @@ function buildReadsState(def) {
|
|
|
6365
6393
|
}
|
|
6366
6394
|
|
|
6367
6395
|
// src/combinators/token.ts
|
|
6396
|
+
import { PlainLeaf as PlainLeaf6 } from "../cst/plain.js";
|
|
6368
6397
|
function semanticLeafValue(_ctx, _input, _start, _end, value) {
|
|
6369
6398
|
return value;
|
|
6370
6399
|
}
|
|
@@ -6418,7 +6447,7 @@ function token(root) {
|
|
|
6418
6447
|
if (!result.ok) return result;
|
|
6419
6448
|
const span = result.span;
|
|
6420
6449
|
const value = input.slice(pos, span.end);
|
|
6421
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
6450
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf6(value, span));
|
|
6422
6451
|
return { ok: true, value, span };
|
|
6423
6452
|
}
|
|
6424
6453
|
};
|
|
@@ -6466,11 +6495,7 @@ function makeLeaf(root, fn, sourceCstValue) {
|
|
|
6466
6495
|
}
|
|
6467
6496
|
if (!result.ok) return result;
|
|
6468
6497
|
const value = fn(result.value, result.span);
|
|
6469
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
6470
|
-
_tag: "leaf",
|
|
6471
|
-
value: cstValue(ctx, input, pos, result.span.end, value),
|
|
6472
|
-
span: result.span
|
|
6473
|
-
});
|
|
6498
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf6(cstValue(ctx, input, pos, result.span.end, value), result.span));
|
|
6474
6499
|
return { ok: true, value, span: result.span };
|
|
6475
6500
|
}
|
|
6476
6501
|
};
|
|
@@ -7059,6 +7084,7 @@ var OP_NAMES = {
|
|
|
7059
7084
|
};
|
|
7060
7085
|
|
|
7061
7086
|
// src/combinators/node.ts
|
|
7087
|
+
import { PlainNode, PlainSpan as PlainSpan7 } from "../cst/plain.js";
|
|
7062
7088
|
function unwrapChild(child) {
|
|
7063
7089
|
return child !== null && typeof child === "object" && child._tag === "leaf" ? child.value : child;
|
|
7064
7090
|
}
|
|
@@ -7164,7 +7190,7 @@ function node(typeOrCombinator, combinatorOrBuild, buildOrOpts, maybeOpts) {
|
|
|
7164
7190
|
const nodeType = def.type ?? missingInferredType();
|
|
7165
7191
|
const cstOutput = cstOutputHost(ctx.build);
|
|
7166
7192
|
const span = ctx.trackLines ? annotateSpanFromLineContext(r.span, ctx) : r.span;
|
|
7167
|
-
const built = unwrap && children2.length === 1 ? unwrapChild(children2[0]) : collapse && children2.length === 1 ? children2[0] : (cstOutput || !build && project === void 0) && ctx.build?._parsemanCstCollapse && children2.length === 1 && rawChildren.length === 1 && ctx.build._parsemanCstCollapse(nodeType, children2[0], children2, rawChildren) ? children2[0] : project !== void 0 ? cstOutput && ctx.build ? ctx.build(nodeType, children2, fields, span, rawChildren, triviaLog, ctx.state, tags) : projectChild(children2, project, nodeType) : build ? cstOutput && ctx.build ? ctx.build(nodeType, children2, fields, span, rawChildren, triviaLog, ctx.state, tags) : build(children2, fields, span, rawChildren, triviaLog, st) : ctx.build ? ctx.build(nodeType, children2, fields, span, rawChildren, triviaLog, st, tags) :
|
|
7193
|
+
const built = unwrap && children2.length === 1 ? unwrapChild(children2[0]) : collapse && children2.length === 1 ? children2[0] : (cstOutput || !build && project === void 0) && ctx.build?._parsemanCstCollapse && children2.length === 1 && rawChildren.length === 1 && ctx.build._parsemanCstCollapse(nodeType, children2[0], children2, rawChildren) ? children2[0] : project !== void 0 ? cstOutput && ctx.build ? ctx.build(nodeType, children2, fields, span, rawChildren, triviaLog, ctx.state, tags) : projectChild(children2, project, nodeType) : build ? cstOutput && ctx.build ? ctx.build(nodeType, children2, fields, span, rawChildren, triviaLog, ctx.state, tags) : build(children2, fields, span, rawChildren, triviaLog, st) : ctx.build ? ctx.build(nodeType, children2, fields, span, rawChildren, triviaLog, st, tags) : new PlainNode(nodeType, ctx.trackLines ? copySpan(span) : new PlainSpan7(r.span.start, r.span.end), st ?? null, [...children2]);
|
|
7168
7194
|
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 };
|
|
7169
7195
|
if (saved.buf !== void 0 || saved.ch !== void 0) {
|
|
7170
7196
|
pushCstChild(ctx, built, rawEntry2);
|
|
@@ -7571,18 +7597,10 @@ var Encoder = class {
|
|
|
7571
7597
|
/** TOKEN bodies are an all-program decision. A complete occurrence inside an
|
|
7572
7598
|
* otherwise incomplete final graph stays on CHARACTER with every sibling. */
|
|
7573
7599
|
selectLexicalBodies;
|
|
7574
|
-
/**
|
|
7575
|
-
* Decides the extra operands laid down below. ALWAYS TRUE — see
|
|
7576
|
-
* `TableSettings.recovery`. Kept as a field rather than folded away because it
|
|
7577
|
-
* is what every emit site reads, and the emit sites are where the shape of the
|
|
7578
|
-
* row is stated.
|
|
7579
|
-
*/
|
|
7580
|
-
rec;
|
|
7581
7600
|
constructor(settings, selectLexicalBodies) {
|
|
7582
7601
|
this.settings = settings;
|
|
7583
7602
|
this.track = settings.trackLines === true;
|
|
7584
7603
|
this.selectLexicalBodies = selectLexicalBodies;
|
|
7585
|
-
this.rec = true;
|
|
7586
7604
|
this.plan = settings.coverage;
|
|
7587
7605
|
this.cov = settings.coverage === void 0 ? void 0 : settings.coverage.definitions.map((d) => [d.id, covKindCode(d.kind)]);
|
|
7588
7606
|
this.covIndex = new Map((this.cov ?? []).map((d, i) => [d[0], i]));
|
|
@@ -8084,12 +8102,10 @@ var Encoder = class {
|
|
|
8084
8102
|
}
|
|
8085
8103
|
case "sequence": {
|
|
8086
8104
|
const kids = d.parsers.map((c) => this.node(c).ip);
|
|
8087
|
-
const head = this.emitHead(d.valueUnused ? OP_SEQV : OP_SEQ, 1 +
|
|
8105
|
+
const head = this.emitHead(d.valueUnused ? OP_SEQV : OP_SEQ, 1 + 2 * kids.length);
|
|
8088
8106
|
this.code[head + 1] = kids.length;
|
|
8089
8107
|
for (let i = 0; i < kids.length; i++) this.code[head + 2 + i] = kids[i];
|
|
8090
|
-
|
|
8091
|
-
for (let i = 0; i < kids.length; i++) this.code[head + 2 + kids.length + i] = this.followClass(d.parsers, i);
|
|
8092
|
-
}
|
|
8108
|
+
for (let i = 0; i < kids.length; i++) this.code[head + 2 + kids.length + i] = this.followClass(d.parsers, i);
|
|
8093
8109
|
return head;
|
|
8094
8110
|
}
|
|
8095
8111
|
case "choice": {
|
|
@@ -8191,25 +8207,22 @@ var Encoder = class {
|
|
|
8191
8207
|
const itemClass = matchesEmpty(d.parser, /* @__PURE__ */ new Set(), rr) ? -1 : this.charClass(firstSetOf(d.parser, /* @__PURE__ */ new Set(), rr, this.activeTrivia));
|
|
8192
8208
|
const op = d.valueUnused ? OP_REPV : OP_REP;
|
|
8193
8209
|
const min = d.tag === "many" ? 0 : d.min;
|
|
8194
|
-
return this.
|
|
8210
|
+
return this.emit(op, child, min, d.max ?? -1, -1, 0, this.expected(deriveExpected(d.parser)), itemClass);
|
|
8195
8211
|
}
|
|
8196
8212
|
case "sepBy": {
|
|
8197
8213
|
const child = this.node(d.parser).ip;
|
|
8198
8214
|
const sep = this.node(d.separator).ip;
|
|
8199
8215
|
const flags = (d.trailing === "allow" ? 1 : 0) | (d.keepSeparators === true ? 2 : 0) | (d.min >= 2 ? 4 : 0);
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
);
|
|
8211
|
-
}
|
|
8212
|
-
return d.min >= 2 ? this.emit(OP_REP, child, d.min, d.max ?? -1, sep, flags, this.expected(deriveExpected(d.parser))) : this.emit(OP_REP, child, d.min, d.max ?? -1, sep, flags);
|
|
8216
|
+
return this.emit(
|
|
8217
|
+
OP_REP,
|
|
8218
|
+
child,
|
|
8219
|
+
d.min,
|
|
8220
|
+
d.max ?? -1,
|
|
8221
|
+
sep,
|
|
8222
|
+
flags,
|
|
8223
|
+
this.expected(deriveExpected(d.parser)),
|
|
8224
|
+
this.charClass(firstSetOf(d.separator, /* @__PURE__ */ new Set(), this.refResolver(), this.activeTrivia))
|
|
8225
|
+
);
|
|
8213
8226
|
}
|
|
8214
8227
|
case "optional": {
|
|
8215
8228
|
const head = this.emit(OP_OPT, this.lookaheadGate(d.parser, this.node(d.parser).ip));
|
|
@@ -8220,14 +8233,12 @@ var Encoder = class {
|
|
|
8220
8233
|
const inner = d.parser._def;
|
|
8221
8234
|
if (inner.tag === "sequence" && !this.memo.has(d.parser) && !this.pending.has(d.parser)) {
|
|
8222
8235
|
const kids = inner.parsers.map((c) => this.node(c).ip);
|
|
8223
|
-
const head = this.emitHead(OP_SEQX, 2 +
|
|
8236
|
+
const head = this.emitHead(OP_SEQX, 2 + 2 * kids.length);
|
|
8224
8237
|
const projection = directArrayProjection(d.fn, d.fnSrc, kids.length);
|
|
8225
8238
|
this.code[head + 1] = projection === null ? this.fn(d.fn, d.fnSrc ?? null) : ~projection;
|
|
8226
8239
|
this.code[head + 2] = kids.length;
|
|
8227
8240
|
for (let i = 0; i < kids.length; i++) this.code[head + 3 + i] = kids[i];
|
|
8228
|
-
|
|
8229
|
-
for (let i = 0; i < kids.length; i++) this.code[head + 3 + kids.length + i] = this.followClass(inner.parsers, i);
|
|
8230
|
-
}
|
|
8241
|
+
for (let i = 0; i < kids.length; i++) this.code[head + 3 + kids.length + i] = this.followClass(inner.parsers, i);
|
|
8231
8242
|
return head;
|
|
8232
8243
|
}
|
|
8233
8244
|
const child = this.node(d.parser).ip;
|
|
@@ -8550,7 +8561,7 @@ var Encoder = class {
|
|
|
8550
8561
|
...this.settings.hostMode === void 0 ? {} : { hostMode: this.settings.hostMode },
|
|
8551
8562
|
...this.runtimeOnly.size === 0 ? {} : { runtimeOnly: [...this.runtimeOnly].sort() },
|
|
8552
8563
|
...this.triviaSpecs.length === 0 ? {} : { triviaSpecs: this.triviaSpecs },
|
|
8553
|
-
|
|
8564
|
+
rec: 1,
|
|
8554
8565
|
...this.cov === void 0 ? {} : { cov: this.cov },
|
|
8555
8566
|
lines: this.track ? 1 : 0
|
|
8556
8567
|
}, void 0, {
|
|
@@ -9314,7 +9325,6 @@ function caseFoldLiteralOrAlt(source) {
|
|
|
9314
9325
|
}
|
|
9315
9326
|
return { kind: "alt", arms: litArms, disjoint: false, firsts: litArms.map(() => null) };
|
|
9316
9327
|
}
|
|
9317
|
-
var scanToIndexOfEnabled = () => process.env.PARSEMAN_SCANTO === "indexof";
|
|
9318
9328
|
var classCond = (cVar, ranges) => ranges.map(([lo, hi]) => lo === hi ? `${cVar} === ${lo}` : `(${cVar} >= ${lo} && ${cVar} <= ${hi})`).join(" || ");
|
|
9319
9329
|
var litCond = (base, cps, firstVar) => cps.map(
|
|
9320
9330
|
(cp, k) => k === 0 && firstVar ? `${firstVar} === ${cp}` : `input.charCodeAt(${base}${k ? ` + ${k}` : ""}) === ${cp}`
|
|
@@ -9544,13 +9554,7 @@ function emitShapeMatch(shape, start, mint, ind, firstChar) {
|
|
|
9544
9554
|
const j2 = mint("_j");
|
|
9545
9555
|
const openLen2 = shape.open.length;
|
|
9546
9556
|
const openChk2 = openLen2 === 1 ? `${codeAt(start, firstChar)} === ${shape.open[0]}` : litCond(start, shape.open, firstChar);
|
|
9547
|
-
const
|
|
9548
|
-
const scanLine = stopCp !== null && stopCp <= 65535 && scanToIndexOfEnabled() ? (
|
|
9549
|
-
// No temp is minted: a temp would renumber every later variable in the
|
|
9550
|
-
// function and show up as an artifact-size delta that is counter
|
|
9551
|
-
// renumbering rather than this change (the §9.1.4 / §9.2 effect).
|
|
9552
|
-
`${ind} ${j2} = input.indexOf(${JSON.stringify(String.fromCharCode(stopCp))}, ${j2}); if (${j2} < 0) ${j2} = input.length`
|
|
9553
|
-
) : `${ind} while (${j2} < input.length && !(${classCond(`input.charCodeAt(${j2})`, shape.stop)})) ${j2}++`;
|
|
9557
|
+
const scanLine = `${ind} while (${j2} < input.length && !(${classCond(`input.charCodeAt(${j2})`, shape.stop)})) ${j2}++`;
|
|
9554
9558
|
return {
|
|
9555
9559
|
setup: [
|
|
9556
9560
|
`${ind}let ${j2} = ${start}`,
|
|
@@ -9608,11 +9612,7 @@ function emitShapeMatch(shape, start, mint, ind, firstChar) {
|
|
|
9608
9612
|
const closeLen = shape.close.length;
|
|
9609
9613
|
const openChk = openLen === 1 ? `${codeAt(start, firstChar)} === ${shape.open[0]}` : litCond(start, shape.open, firstChar);
|
|
9610
9614
|
const closeChk = litCond(j, shape.close);
|
|
9611
|
-
const
|
|
9612
|
-
const scanLines = scanToIndexOfEnabled() ? [
|
|
9613
|
-
`${ind} ${j} = input.indexOf(${JSON.stringify(closeStr)}, ${j}); if (${j} < 0) ${j} = input.length`,
|
|
9614
|
-
`${ind} if (${j} + ${closeLen} <= input.length) ${endV} = ${j} + ${closeLen}`
|
|
9615
|
-
] : [
|
|
9615
|
+
const scanLines = [
|
|
9616
9616
|
`${ind} while (${j} + ${closeLen - 1} < input.length && !(${closeChk})) ${j}++`,
|
|
9617
9617
|
`${ind} if (${j} + ${closeLen} <= input.length && (${closeChk})) ${endV} = ${j} + ${closeLen}`
|
|
9618
9618
|
];
|
|
@@ -10248,7 +10248,14 @@ var EMITTED_PARAMS = [
|
|
|
10248
10248
|
"skipDeferredTrivia",
|
|
10249
10249
|
// Appended for the pass-through collapse (`run-support.ts`); old factories
|
|
10250
10250
|
// ignore it.
|
|
10251
|
-
"collapseEmpty"
|
|
10251
|
+
"collapseEmpty",
|
|
10252
|
+
// Appended for constructor-built tree objects (`cst/plain.d.ts`): a `new` call has
|
|
10253
|
+
// no allocation site, so V8 cannot pretenure them. Old factories ignore them.
|
|
10254
|
+
"_SP",
|
|
10255
|
+
"_LF",
|
|
10256
|
+
"_ND",
|
|
10257
|
+
"_FC",
|
|
10258
|
+
"_BUF"
|
|
10252
10259
|
];
|
|
10253
10260
|
var RUNTIME_PRELUDE = `
|
|
10254
10261
|
let _pfScan=null
|
|
@@ -10272,9 +10279,9 @@ if(s!==null)return skipTriviaScanned(s,input,cur,ctx)
|
|
|
10272
10279
|
if(needsDeferredTriviaCommit(ctx))return skipDeferredTrivia(input,cur,ctx)
|
|
10273
10280
|
return advanceTrivia(input,cur,ctx)
|
|
10274
10281
|
}
|
|
10275
|
-
function _pushLeaf(ctx,value,s,e){pushCstLeaf(ctx,
|
|
10282
|
+
function _pushLeaf(ctx,value,s,e){pushCstLeaf(ctx,new _LF(value,new _SP(s,e)))}
|
|
10276
10283
|
function _pushLeafBuf(ctx,value,s,e){
|
|
10277
|
-
const l=
|
|
10284
|
+
const l=new _LF(value,new _SP(s,e))
|
|
10278
10285
|
const b=ctx._cstBuf
|
|
10279
10286
|
if(b.ch!==undefined)b.ch.push(l)
|
|
10280
10287
|
else if(b.single!==undefined){b.ch=[b.single,l];b.single=undefined}
|
|
@@ -10332,7 +10339,7 @@ if(ctx._rootTriviaLog!==undefined&&ctx._rootTriviaLog.length!==rt)ctx._rootTrivi
|
|
|
10332
10339
|
`;
|
|
10333
10340
|
var NO_RAW_RUNTIME_PRELUDE = `
|
|
10334
10341
|
function _pushLeafNoRawBuf(ctx,value,s,e){
|
|
10335
|
-
const l=
|
|
10342
|
+
const l=new _LF(value,new _SP(s,e))
|
|
10336
10343
|
const b=ctx._cstBuf
|
|
10337
10344
|
if(b.ch!==undefined)b.ch.push(l)
|
|
10338
10345
|
else if(b.single!==undefined){b.ch=[b.single,l];b.single=undefined}
|
|
@@ -11009,7 +11016,7 @@ try{return ${child}(input,pos,ctx)}finally{ctx.state=saved}
|
|
|
11009
11016
|
return `${head}
|
|
11010
11017
|
const v=${child}(input,pos,ctx)
|
|
11011
11018
|
if(v===FAIL)return FAIL
|
|
11012
|
-
return ${fn}(v,
|
|
11019
|
+
return ${fn}(v,new _SP(pos,EC.e))
|
|
11013
11020
|
}`;
|
|
11014
11021
|
}
|
|
11015
11022
|
case OP_LABEL: {
|
|
@@ -11030,7 +11037,7 @@ return v
|
|
|
11030
11037
|
const v=${child}(input,pos,ctx)
|
|
11031
11038
|
if(v===FAIL)return FAIL
|
|
11032
11039
|
const f=ctx._fields
|
|
11033
|
-
if(f!==undefined)f.push({name
|
|
11040
|
+
if(f!==undefined)f.push(new _FC(${name},v,new _SP(pos,EC.e)))
|
|
11034
11041
|
return v
|
|
11035
11042
|
}`;
|
|
11036
11043
|
}
|
|
@@ -11055,7 +11062,7 @@ return v
|
|
|
11055
11062
|
return `${head}
|
|
11056
11063
|
const v=${child}(input,pos,ctx)
|
|
11057
11064
|
if(v!==FAIL)return v
|
|
11058
|
-
const err={_tag:'parseError',span:${prog.lines === 1 ? "spanLines(ctx,pos,pos)" : "
|
|
11065
|
+
const err={_tag:'parseError',span:${prog.lines === 1 ? "spanLines(ctx,pos,pos)" : "new _SP(pos,pos)"},expected:${xf}}
|
|
11059
11066
|
const es=ctx._errors
|
|
11060
11067
|
if(es!==undefined)es.push(err)
|
|
11061
11068
|
${REC ? "if(ctx._tolerant===true)captureError(ctx,err)\n" : ""}ctx._fc=false
|
|
@@ -11066,7 +11073,7 @@ return err
|
|
|
11066
11073
|
case OP_ROUTED: {
|
|
11067
11074
|
const fb = code[ip + 1];
|
|
11068
11075
|
const fallback = fb >= 0 ? link(fb) : void 0;
|
|
11069
|
-
const push = `pushCstLeaf(ctx,
|
|
11076
|
+
const push = `pushCstLeaf(ctx,new _LF(it.value,it.span))`;
|
|
11070
11077
|
return `${head}
|
|
11071
11078
|
const it=ctx._routed
|
|
11072
11079
|
if(it===undefined||pos!==it.span.start){
|
|
@@ -11147,8 +11154,8 @@ ctx._triviaLog=sOtl
|
|
|
11147
11154
|
}
|
|
11148
11155
|
if(v===FAIL)return FAIL
|
|
11149
11156
|
const e=EC.e
|
|
11150
|
-
const out=${isToken ? "input.slice(pos,e)" : `${fn}(v,
|
|
11151
|
-
if(wasCap)pushCstLeaf(ctx,{
|
|
11157
|
+
const out=${isToken ? "input.slice(pos,e)" : `${fn}(v,new _SP(pos,e))`}
|
|
11158
|
+
if(wasCap)pushCstLeaf(ctx,new _LF(${capturesSource ? "input.slice(pos,e)" : "out"},new _SP(pos,e)))
|
|
11152
11159
|
EC.e=e
|
|
11153
11160
|
return out
|
|
11154
11161
|
}`;
|
|
@@ -11172,7 +11179,7 @@ ${hasSuffix && (lineFlags & 2) !== 0 ? "if(sm)_trackLines(ctx,input,e)" : ""}
|
|
|
11172
11179
|
${hasSuffix ? `if(!sm){ctx._fe=e;ctx._fx=${suffixExpected};if(ctx._probe!==undefined)failAt(ctx,${suffixExpected},e)}` : ""}
|
|
11173
11180
|
const v=${pending ? "tp?_pfTokValue:" : ""}input.slice(pos,e)
|
|
11174
11181
|
${pending ? "if(tp){_pfTokBody=-1;_pfTokValue=undefined}" : ""}
|
|
11175
|
-
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,
|
|
11182
|
+
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
11176
11183
|
EC.e=e
|
|
11177
11184
|
return v
|
|
11178
11185
|
}`;
|
|
@@ -11211,7 +11218,7 @@ ctx._rootTriviaLog=sRtl
|
|
|
11211
11218
|
}
|
|
11212
11219
|
if(e<0)return FAIL
|
|
11213
11220
|
const v=input.slice(pos,e)
|
|
11214
|
-
if(wasCap)pushCstLeaf(ctx,
|
|
11221
|
+
if(wasCap)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
11215
11222
|
EC.e=e
|
|
11216
11223
|
return v
|
|
11217
11224
|
}`;
|
|
@@ -11219,7 +11226,7 @@ return v
|
|
|
11219
11226
|
const e=${run}(input,pos,ctx)
|
|
11220
11227
|
if(e<0)return FAIL
|
|
11221
11228
|
const v=input.slice(pos,e)
|
|
11222
|
-
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,
|
|
11229
|
+
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
11223
11230
|
EC.e=e
|
|
11224
11231
|
return v
|
|
11225
11232
|
}`;
|
|
@@ -11333,7 +11340,7 @@ return v
|
|
|
11333
11340
|
}` : `${parts.join("\n")}
|
|
11334
11341
|
}`;
|
|
11335
11342
|
if (n === 1) {
|
|
11336
|
-
parts.push(fused ? projection === 0 ? "return v0" : `return ${fn}([v0],
|
|
11343
|
+
parts.push(fused ? projection === 0 ? "return v0" : `return ${fn}([v0],new _SP(pos,EC.e))` : wantValues ? "return [v0]" : "return undefined");
|
|
11337
11344
|
return close();
|
|
11338
11345
|
}
|
|
11339
11346
|
parts.push("let cur=EC.e");
|
|
@@ -11359,7 +11366,7 @@ return v
|
|
|
11359
11366
|
names.push(vn);
|
|
11360
11367
|
}
|
|
11361
11368
|
parts.push("EC.e=cur");
|
|
11362
|
-
parts.push(fused ? projection >= 0 ? `return ${names[projection]}` : `return ${fn}([${names.join(",")}],
|
|
11369
|
+
parts.push(fused ? projection >= 0 ? `return ${names[projection]}` : `return ${fn}([${names.join(",")}],new _SP(pos,cur))` : wantValues ? `return [${names.join(",")}]` : "return undefined");
|
|
11363
11370
|
return close();
|
|
11364
11371
|
}
|
|
11365
11372
|
case OP_CHOICE: {
|
|
@@ -11618,7 +11625,7 @@ ${spec.match.map((m, i) => `${i === 0 ? "" : "else "}if(${dispatchClaim(m)})arm=
|
|
|
11618
11625
|
const routedCall = (target) => `{const savedRouted=ctx._routed
|
|
11619
11626
|
${emitRollback(m1, L.buf, L.raw, sinks)}
|
|
11620
11627
|
${emitMark(m2, L.buf, L.raw, sinks, false)}
|
|
11621
|
-
ctx._routed={value:key,span:
|
|
11628
|
+
ctx._routed={value:key,span:new _SP(pos,selEnd)}
|
|
11622
11629
|
try{v=${target}(input,pos,ctx)}finally{ctx._routed=savedRouted}
|
|
11623
11630
|
break}`;
|
|
11624
11631
|
const plainCall = (target) => `v=${target}(input,selEnd,ctx);break`;
|
|
@@ -11813,8 +11820,8 @@ return out
|
|
|
11813
11820
|
const end=${recognize}(input,pos)
|
|
11814
11821
|
if(end<0){ctx._fe=pos;ctx._fx=${xf};return FAIL}
|
|
11815
11822
|
const value=${value2}
|
|
11816
|
-
const leaf=
|
|
11817
|
-
const kids=[leaf],rawKids=[leaf],span=
|
|
11823
|
+
const leaf=new _LF(value,new _SP(pos,end))
|
|
11824
|
+
const kids=[leaf],rawKids=[leaf],span=new _SP(pos,end)
|
|
11818
11825
|
EC.e=end
|
|
11819
11826
|
const nd=${build2}(kids,undefined,span,rawKids,EMPTY_TL,undefined)
|
|
11820
11827
|
${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))"}
|
|
@@ -11913,7 +11920,7 @@ ctx._cstTriviaLog=sTl
|
|
|
11913
11920
|
ctx.captureTrivia=sCap
|
|
11914
11921
|
if(v===FAIL)return FAIL
|
|
11915
11922
|
const end=EC.e
|
|
11916
|
-
${collapseChildren ? `const nd=captured.length===1?captured[0]:${build}(captured,undefined,
|
|
11923
|
+
${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)`}
|
|
11917
11924
|
${publish}
|
|
11918
11925
|
EC.e=end
|
|
11919
11926
|
return nd
|
|
@@ -11936,20 +11943,20 @@ return nd
|
|
|
11936
11943
|
const direct = `${build}(kids,fieldMap,span,rawKids,${captureWide ? "tlog" : "EMPTY_TL"},st)`;
|
|
11937
11944
|
value = hostCst ? `nd=_pfHost!==undefined?${hostCall}:${direct}` : `nd=${direct}`;
|
|
11938
11945
|
} else {
|
|
11939
|
-
value = `nd=_pfHost!==undefined?_pfHost(${ty},hostKids,fieldMap,span,rawKids,tlog,st,${tags}):{
|
|
11946
|
+
value = `nd=_pfHost!==undefined?_pfHost(${ty},hostKids,fieldMap,span,rawKids,tlog,st,${tags}):new _ND(${ty},span,st??null,kids===EMPTY_CH?kids:[...kids])`;
|
|
11940
11947
|
}
|
|
11941
11948
|
const collapsible = keepChildren && (hostCst || build === void 0 && proj < 0);
|
|
11942
|
-
const openCapture = omitsRaw ? `const buf=
|
|
11949
|
+
const openCapture = omitsRaw ? `const buf=new _BUF(undefined,true,0)
|
|
11943
11950
|
ctx._cstBuf=buf
|
|
11944
11951
|
ctx._cstChildren=undefined
|
|
11945
11952
|
ctx._cstLeaves=undefined
|
|
11946
11953
|
ctx._cstRawChildren=undefined
|
|
11947
|
-
ctx._cstTriviaLog=undefined` : keepChildren ? `const buf=
|
|
11954
|
+
ctx._cstTriviaLog=undefined` : keepChildren ? `const buf=new _BUF(undefined,undefined,0)
|
|
11948
11955
|
ctx._cstBuf=buf
|
|
11949
11956
|
ctx._cstChildren=undefined
|
|
11950
11957
|
ctx._cstLeaves=undefined
|
|
11951
11958
|
ctx._cstRawChildren=undefined
|
|
11952
|
-
ctx._cstTriviaLog=undefined` : `const buf=
|
|
11959
|
+
ctx._cstTriviaLog=undefined` : `const buf=new _BUF(true,undefined,0)
|
|
11953
11960
|
ctx._cstBuf=buf
|
|
11954
11961
|
ctx._cstChildren=undefined
|
|
11955
11962
|
ctx._cstLeaves=undefined
|
|
@@ -11987,7 +11994,7 @@ ctx._cstTriviaLog=sTl
|
|
|
11987
11994
|
ctx.captureTrivia=sCap
|
|
11988
11995
|
if(v===FAIL)return FAIL
|
|
11989
11996
|
const end=EC.e
|
|
11990
|
-
const span=${tracked ? "spanLines(ctx,pos,end)" : "
|
|
11997
|
+
const span=${tracked ? "spanLines(ctx,pos,end)" : "new _SP(pos,end)"}
|
|
11991
11998
|
const st=${readsState ? "ctx.state" : "undefined"}
|
|
11992
11999
|
let nd
|
|
11993
12000
|
${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]
|
|
@@ -12274,6 +12281,7 @@ function rebuildLineScan(s, subtree) {
|
|
|
12274
12281
|
}
|
|
12275
12282
|
|
|
12276
12283
|
// src/combinators/literal.ts
|
|
12284
|
+
import { PlainLeaf as PlainLeaf7, PlainSpan as PlainSpan8 } from "../cst/plain.js";
|
|
12277
12285
|
function asciiFoldEq(a, b) {
|
|
12278
12286
|
if (a.length !== b.length) return false;
|
|
12279
12287
|
for (let i = 0; i < a.length; i++) {
|
|
@@ -12331,9 +12339,9 @@ function literal(value, opts = {}) {
|
|
|
12331
12339
|
const code = value.charCodeAt(0);
|
|
12332
12340
|
return function parse3(input, pos, ctx) {
|
|
12333
12341
|
if (input.charCodeAt(pos) === code) {
|
|
12334
|
-
const span =
|
|
12342
|
+
const span = new PlainSpan8(pos, pos + 1);
|
|
12335
12343
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, span.end);
|
|
12336
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
12344
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf7(value, span));
|
|
12337
12345
|
return { ok: true, value, span };
|
|
12338
12346
|
}
|
|
12339
12347
|
return failAt(ctx, expected, pos);
|
|
@@ -12345,9 +12353,9 @@ function literal(value, opts = {}) {
|
|
|
12345
12353
|
}
|
|
12346
12354
|
const matchedValue = caseInsensitive ? input.slice(pos, end) : value;
|
|
12347
12355
|
if (caseInsensitive ? asciiFoldEq(matchedValue, value) : input.startsWith(value, pos)) {
|
|
12348
|
-
const span =
|
|
12356
|
+
const span = new PlainSpan8(pos, end);
|
|
12349
12357
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, end);
|
|
12350
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
12358
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf7(matchedValue, span));
|
|
12351
12359
|
return { ok: true, value: matchedValue, span };
|
|
12352
12360
|
}
|
|
12353
12361
|
return failAt(ctx, expected, pos);
|
|
@@ -12429,6 +12437,7 @@ function ref() {
|
|
|
12429
12437
|
}
|
|
12430
12438
|
|
|
12431
12439
|
// src/combinators/scanTo.ts
|
|
12440
|
+
import { PlainLeaf as PlainLeaf8, PlainSpan as PlainSpan9 } from "../cst/plain.js";
|
|
12432
12441
|
function resolveScanSkip(explicitSkip, raw, ctx) {
|
|
12433
12442
|
if (raw) return [];
|
|
12434
12443
|
const trivia2 = ctx.trivia;
|
|
@@ -12466,7 +12475,7 @@ function scanTo(sentinel, { skip, raw = false, orEOF = false, recoverAt, stopAt
|
|
|
12466
12475
|
probeCtx._errors = ctx._errors;
|
|
12467
12476
|
const emit = (end) => {
|
|
12468
12477
|
if (end > pos && cstCaptureActive(ctx)) {
|
|
12469
|
-
const leaf2 =
|
|
12478
|
+
const leaf2 = new PlainLeaf8(input.slice(pos, end), new PlainSpan9(pos, end));
|
|
12470
12479
|
pushCstLeaf(ctx, leaf2);
|
|
12471
12480
|
}
|
|
12472
12481
|
};
|
|
@@ -12745,6 +12754,9 @@ function clearOf(ranges, input, from, to) {
|
|
|
12745
12754
|
return true;
|
|
12746
12755
|
}
|
|
12747
12756
|
|
|
12757
|
+
// src/table/assemble.ts
|
|
12758
|
+
import { PlainBuf as PlainBuf2, PlainField, PlainLeaf as PlainLeaf9, PlainNode as PlainNode2, PlainSpan as PlainSpan10 } from "../cst/plain.js";
|
|
12759
|
+
|
|
12748
12760
|
// src/table/fail-clean.ts
|
|
12749
12761
|
function passChild(code, ip) {
|
|
12750
12762
|
switch (code[ip]) {
|
|
@@ -13055,7 +13067,7 @@ function assemble(t2, prog, cfg) {
|
|
|
13055
13067
|
const NULLABLE = /* @__PURE__ */ new Map();
|
|
13056
13068
|
const CLEAN = REC ? () => false : failCleanAnalysis(code);
|
|
13057
13069
|
function pushLeaf(ctx, value, s, e) {
|
|
13058
|
-
const lf =
|
|
13070
|
+
const lf = new PlainLeaf9(value, new PlainSpan10(s, e));
|
|
13059
13071
|
pushCstLeaf(ctx, lf);
|
|
13060
13072
|
}
|
|
13061
13073
|
function plainBuildNode(child, build, trailing) {
|
|
@@ -13088,7 +13100,7 @@ function assemble(t2, prog, cfg) {
|
|
|
13088
13100
|
ctx.captureTrivia = sCap;
|
|
13089
13101
|
if (value === FAIL) return FAIL;
|
|
13090
13102
|
const end = EC.e;
|
|
13091
|
-
const span =
|
|
13103
|
+
const span = new PlainSpan10(pos, end);
|
|
13092
13104
|
const node2 = build(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
|
|
13093
13105
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13094
13106
|
pushCstChild(ctx, node2, rawEntry(node2, input, pos, end));
|
|
@@ -13133,7 +13145,7 @@ function assemble(t2, prog, cfg) {
|
|
|
13133
13145
|
ctx.captureTrivia = sCap;
|
|
13134
13146
|
if (value === FAIL) return FAIL;
|
|
13135
13147
|
const end = EC.e;
|
|
13136
|
-
const node2 = build(captured, void 0,
|
|
13148
|
+
const node2 = build(captured, void 0, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
|
|
13137
13149
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13138
13150
|
pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
|
|
13139
13151
|
}
|
|
@@ -13170,7 +13182,7 @@ function assemble(t2, prog, cfg) {
|
|
|
13170
13182
|
ctx.captureTrivia = sCap;
|
|
13171
13183
|
if (value === FAIL) return FAIL;
|
|
13172
13184
|
const end = EC.e;
|
|
13173
|
-
const node2 = build(captured, fieldMap,
|
|
13185
|
+
const node2 = build(captured, fieldMap, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
|
|
13174
13186
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13175
13187
|
pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
|
|
13176
13188
|
}
|
|
@@ -13207,7 +13219,7 @@ function assemble(t2, prog, cfg) {
|
|
|
13207
13219
|
ctx.captureTrivia = sCap;
|
|
13208
13220
|
if (value === FAIL) return FAIL;
|
|
13209
13221
|
const end = EC.e;
|
|
13210
|
-
const span =
|
|
13222
|
+
const span = new PlainSpan10(pos, end);
|
|
13211
13223
|
const node2 = kids.length === 1 ? kids[0] : build(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
|
|
13212
13224
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13213
13225
|
pushCstChild(ctx, node2, rawEntry(node2, input, pos, end));
|
|
@@ -13244,7 +13256,7 @@ function assemble(t2, prog, cfg) {
|
|
|
13244
13256
|
ctx.captureTrivia = sCap;
|
|
13245
13257
|
if (value === FAIL) return FAIL;
|
|
13246
13258
|
const end = EC.e;
|
|
13247
|
-
const node2 = captured.length === 1 ? captured[0] : build(captured, void 0,
|
|
13259
|
+
const node2 = captured.length === 1 ? captured[0] : build(captured, void 0, new PlainSpan10(pos, end), EMPTY_CH, EMPTY_TL2, void 0);
|
|
13248
13260
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
13249
13261
|
pushCstChild(ctx, node2, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node2, input, pos, end) : void 0);
|
|
13250
13262
|
}
|
|
@@ -13677,7 +13689,7 @@ function assemble(t2, prog, cfg) {
|
|
|
13677
13689
|
return (input, pos, selEnd, key, ctx, need, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot) => {
|
|
13678
13690
|
const savedRouted = ctx._routed;
|
|
13679
13691
|
if (need) rollbackTriviaAt(ctx, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot);
|
|
13680
|
-
ctx._routed = { value: key, span:
|
|
13692
|
+
ctx._routed = { value: key, span: new PlainSpan10(pos, selEnd) };
|
|
13681
13693
|
let v;
|
|
13682
13694
|
try {
|
|
13683
13695
|
v = child(input, pos, ctx);
|
|
@@ -14110,7 +14122,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14110
14122
|
case OP_EXPECT: {
|
|
14111
14123
|
const child = link(code[ip + 1]);
|
|
14112
14124
|
const xf = fx[code[ip + 2]];
|
|
14113
|
-
const expectSpan = (ctx, pos) => prog.lines === 1 ? spanLines(ctx, pos, pos) :
|
|
14125
|
+
const expectSpan = (ctx, pos) => prog.lines === 1 ? spanLines(ctx, pos, pos) : new PlainSpan10(pos, pos);
|
|
14114
14126
|
if (REC) {
|
|
14115
14127
|
return (input, pos, ctx) => {
|
|
14116
14128
|
const v = child(input, pos, ctx);
|
|
@@ -14142,7 +14154,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14142
14154
|
return (input, pos, ctx) => {
|
|
14143
14155
|
const v = child(input, pos, ctx);
|
|
14144
14156
|
if (v === FAIL) return FAIL;
|
|
14145
|
-
ctx._fields?.push(
|
|
14157
|
+
ctx._fields?.push(new PlainField(name, v, new PlainSpan10(pos, EC.e)));
|
|
14146
14158
|
return v;
|
|
14147
14159
|
};
|
|
14148
14160
|
}
|
|
@@ -14166,7 +14178,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14166
14178
|
return (input, pos, ctx) => {
|
|
14167
14179
|
const v = child(input, pos, ctx);
|
|
14168
14180
|
if (v === FAIL) return FAIL;
|
|
14169
|
-
return fn(v,
|
|
14181
|
+
return fn(v, new PlainSpan10(pos, EC.e));
|
|
14170
14182
|
};
|
|
14171
14183
|
}
|
|
14172
14184
|
case OP_SCAN: {
|
|
@@ -14270,7 +14282,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14270
14282
|
ctx._fx = ROUTED_FX;
|
|
14271
14283
|
return FAIL;
|
|
14272
14284
|
}
|
|
14273
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
14285
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(item.value, item.span));
|
|
14274
14286
|
EC.e = item.span.end;
|
|
14275
14287
|
return item.value;
|
|
14276
14288
|
};
|
|
@@ -14456,7 +14468,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14456
14468
|
if (v === FAIL) return FAIL;
|
|
14457
14469
|
const end = EC.e;
|
|
14458
14470
|
const value = input.slice(pos, end);
|
|
14459
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
14471
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
|
|
14460
14472
|
EC.e = end;
|
|
14461
14473
|
return value;
|
|
14462
14474
|
};
|
|
@@ -14490,7 +14502,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14490
14502
|
if (ctx._probe !== void 0) failAt(ctx, suffixExpected, end);
|
|
14491
14503
|
}
|
|
14492
14504
|
const value = input.slice(pos, end);
|
|
14493
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
14505
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
|
|
14494
14506
|
EC.e = end;
|
|
14495
14507
|
return value;
|
|
14496
14508
|
};
|
|
@@ -14533,7 +14545,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14533
14545
|
}
|
|
14534
14546
|
if (end < 0) return FAIL;
|
|
14535
14547
|
const value = input.slice(pos, end);
|
|
14536
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
14548
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
|
|
14537
14549
|
EC.e = end;
|
|
14538
14550
|
return value;
|
|
14539
14551
|
};
|
|
@@ -14542,7 +14554,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14542
14554
|
const end = run(input, pos, ctx);
|
|
14543
14555
|
if (end < 0) return FAIL;
|
|
14544
14556
|
const value = input.slice(pos, end);
|
|
14545
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
14557
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf9(value, new PlainSpan10(pos, end)));
|
|
14546
14558
|
EC.e = end;
|
|
14547
14559
|
return value;
|
|
14548
14560
|
};
|
|
@@ -14575,12 +14587,8 @@ function assemble(t2, prog, cfg) {
|
|
|
14575
14587
|
}
|
|
14576
14588
|
if (v === FAIL) return FAIL;
|
|
14577
14589
|
const end = EC.e;
|
|
14578
|
-
const out = fn(v,
|
|
14579
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
14580
|
-
_tag: "leaf",
|
|
14581
|
-
value: op === OP_SOURCE_LEAF && hostCst ? input.slice(pos, end) : out,
|
|
14582
|
-
span: { start: pos, end }
|
|
14583
|
-
});
|
|
14590
|
+
const out = fn(v, new PlainSpan10(pos, end));
|
|
14591
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf9(op === OP_SOURCE_LEAF && hostCst ? input.slice(pos, end) : out, new PlainSpan10(pos, end)));
|
|
14584
14592
|
EC.e = end;
|
|
14585
14593
|
return out;
|
|
14586
14594
|
};
|
|
@@ -14715,7 +14723,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14715
14723
|
const cur = runSyncTerms(input, pos, ctx, values);
|
|
14716
14724
|
if (cur < 0) return FAIL;
|
|
14717
14725
|
EC.e = cur;
|
|
14718
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
14726
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
|
|
14719
14727
|
};
|
|
14720
14728
|
}
|
|
14721
14729
|
if (wantValues) {
|
|
@@ -14809,7 +14817,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14809
14817
|
const cur = runAdjTerms(input, pos, ctx, values);
|
|
14810
14818
|
if (cur < 0) return FAIL;
|
|
14811
14819
|
EC.e = cur;
|
|
14812
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
14820
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
|
|
14813
14821
|
};
|
|
14814
14822
|
}
|
|
14815
14823
|
if (wantValues) {
|
|
@@ -14834,7 +14842,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14834
14842
|
return (input, pos, ctx) => {
|
|
14835
14843
|
const v = k0(input, pos, ctx);
|
|
14836
14844
|
if (v === FAIL) return FAIL;
|
|
14837
|
-
return projection === 0 ? v : fn([v],
|
|
14845
|
+
return projection === 0 ? v : fn([v], new PlainSpan10(pos, EC.e));
|
|
14838
14846
|
};
|
|
14839
14847
|
}
|
|
14840
14848
|
if (wantValues) {
|
|
@@ -14859,7 +14867,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14859
14867
|
const cur = step(k1, input, EC.e, ctx);
|
|
14860
14868
|
if (cur < 0) return FAIL;
|
|
14861
14869
|
EC.e = cur;
|
|
14862
|
-
return projection === 0 ? v0 : projection === 1 ? TERMV : fn([v0, TERMV],
|
|
14870
|
+
return projection === 0 ? v0 : projection === 1 ? TERMV : fn([v0, TERMV], new PlainSpan10(pos, cur));
|
|
14863
14871
|
};
|
|
14864
14872
|
}
|
|
14865
14873
|
if (wantValues) {
|
|
@@ -14893,7 +14901,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14893
14901
|
cur = step(k2, input, cur, ctx);
|
|
14894
14902
|
if (cur < 0) return FAIL;
|
|
14895
14903
|
EC.e = cur;
|
|
14896
|
-
return projection === 0 ? v0 : projection === 1 ? v1 : projection === 2 ? TERMV : fn([v0, v1, TERMV],
|
|
14904
|
+
return projection === 0 ? v0 : projection === 1 ? v1 : projection === 2 ? TERMV : fn([v0, v1, TERMV], new PlainSpan10(pos, cur));
|
|
14897
14905
|
};
|
|
14898
14906
|
}
|
|
14899
14907
|
if (wantValues) {
|
|
@@ -14990,7 +14998,7 @@ function assemble(t2, prog, cfg) {
|
|
|
14990
14998
|
const cur = runDirectTerms(input, pos, ctx, values);
|
|
14991
14999
|
if (cur < 0) return FAIL;
|
|
14992
15000
|
EC.e = cur;
|
|
14993
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
15001
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan10(pos, cur));
|
|
14994
15002
|
};
|
|
14995
15003
|
}
|
|
14996
15004
|
if (wantValues) {
|
|
@@ -15888,10 +15896,10 @@ function assemble(t2, prog, cfg) {
|
|
|
15888
15896
|
return FAIL;
|
|
15889
15897
|
}
|
|
15890
15898
|
const value = regexValue ? input.slice(pos, end) : spec;
|
|
15891
|
-
const leaf2 =
|
|
15899
|
+
const leaf2 = new PlainLeaf9(value, new PlainSpan10(pos, end));
|
|
15892
15900
|
const kids = [leaf2];
|
|
15893
15901
|
const rawKids = [leaf2];
|
|
15894
|
-
const span =
|
|
15902
|
+
const span = new PlainSpan10(pos, end);
|
|
15895
15903
|
EC.e = end;
|
|
15896
15904
|
const nd = build2(kids, void 0, span, rawKids, EMPTY_TL2, void 0);
|
|
15897
15905
|
if (ctx._cstBuf !== void 0 || ctx._cstChildren !== void 0) {
|
|
@@ -15973,7 +15981,7 @@ function assemble(t2, prog, cfg) {
|
|
|
15973
15981
|
const sCh = ctx._cstChildren;
|
|
15974
15982
|
const sCap = ctx.captureTrivia;
|
|
15975
15983
|
const sBuf = ctx._cstBuf;
|
|
15976
|
-
const buf = rawOnly ?
|
|
15984
|
+
const buf = rawOnly ? new PlainBuf2(true, void 0, 0) : omitsRaw ? new PlainBuf2(void 0, true, 0) : new PlainBuf2(void 0, void 0, 0);
|
|
15977
15985
|
ctx._cstBuf = buf;
|
|
15978
15986
|
ctx.captureTrivia = captureWide;
|
|
15979
15987
|
const savedFields = ctx._fields;
|
|
@@ -15995,7 +16003,7 @@ function assemble(t2, prog, cfg) {
|
|
|
15995
16003
|
ctx.captureTrivia = sCap;
|
|
15996
16004
|
if (v === FAIL) return FAIL;
|
|
15997
16005
|
const end = EC.e;
|
|
15998
|
-
const span = tracked ? spanLines(ctx, pos, end) :
|
|
16006
|
+
const span = tracked ? spanLines(ctx, pos, end) : new PlainSpan10(pos, end);
|
|
15999
16007
|
const st = readsState ? ctx.state : void 0;
|
|
16000
16008
|
let nd;
|
|
16001
16009
|
if (unwrap && kids.length === 1) {
|
|
@@ -16019,7 +16027,7 @@ function assemble(t2, prog, cfg) {
|
|
|
16019
16027
|
} else if (host !== void 0) {
|
|
16020
16028
|
nd = host(type, hostKids, fieldMap, span, rawKids, tlog, st, tags);
|
|
16021
16029
|
} else {
|
|
16022
|
-
nd =
|
|
16030
|
+
nd = new PlainNode2(type, span, st ?? null, kids === EMPTY_CH ? kids : [...kids]);
|
|
16023
16031
|
}
|
|
16024
16032
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
16025
16033
|
pushCstChild(ctx, nd, rawEntry(nd, input, pos, end));
|
|
@@ -16045,7 +16053,7 @@ function assemble(t2, prog, cfg) {
|
|
|
16045
16053
|
const at = fe === void 0 || fe < 0 ? pos : fe;
|
|
16046
16054
|
return { ok: false, expected: ctx._fx ?? EMPTY_FX2, span: { start: at, end: at } };
|
|
16047
16055
|
}
|
|
16048
|
-
return { ok: true, value: v, span:
|
|
16056
|
+
return { ok: true, value: v, span: new PlainSpan10(pos, EC.e) };
|
|
16049
16057
|
}
|
|
16050
16058
|
};
|
|
16051
16059
|
}
|
|
@@ -16160,7 +16168,12 @@ function assemble(t2, prog, cfg) {
|
|
|
16160
16168
|
LEAD,
|
|
16161
16169
|
triviaFieldCapture,
|
|
16162
16170
|
skipDeferredTrivia,
|
|
16163
|
-
collapseEmpty
|
|
16171
|
+
collapseEmpty,
|
|
16172
|
+
PlainSpan10,
|
|
16173
|
+
PlainLeaf9,
|
|
16174
|
+
PlainNode2,
|
|
16175
|
+
PlainField,
|
|
16176
|
+
PlainBuf2
|
|
16164
16177
|
);
|
|
16165
16178
|
emitReached = new Set(pre.reached);
|
|
16166
16179
|
if (emitted.ext !== void 0) HYBRID = emitted;
|
|
@@ -16247,7 +16260,12 @@ function assemble(t2, prog, cfg) {
|
|
|
16247
16260
|
LEAD,
|
|
16248
16261
|
triviaFieldCapture,
|
|
16249
16262
|
skipDeferredTrivia,
|
|
16250
|
-
collapseEmpty
|
|
16263
|
+
collapseEmpty,
|
|
16264
|
+
PlainSpan10,
|
|
16265
|
+
PlainLeaf9,
|
|
16266
|
+
PlainNode2,
|
|
16267
|
+
PlainField,
|
|
16268
|
+
PlainBuf2
|
|
16251
16269
|
);
|
|
16252
16270
|
emitReached = em.reached;
|
|
16253
16271
|
} catch (e) {
|
|
@@ -16505,7 +16523,11 @@ function tableRules(source, metadataOrEntry = {}) {
|
|
|
16505
16523
|
return map[entry];
|
|
16506
16524
|
}
|
|
16507
16525
|
|
|
16526
|
+
// src/version.ts
|
|
16527
|
+
var PARSEMAN_VERSION = "0.59.1";
|
|
16528
|
+
|
|
16508
16529
|
// src/table/emit.ts
|
|
16530
|
+
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`)});`;
|
|
16509
16531
|
function jsString(s) {
|
|
16510
16532
|
return JSON.stringify(s);
|
|
16511
16533
|
}
|
|
@@ -16580,7 +16602,7 @@ function emitAssemblies(prog, cfgs) {
|
|
|
16580
16602
|
throw e;
|
|
16581
16603
|
}
|
|
16582
16604
|
const plan = em.plan;
|
|
16583
|
-
out.push(`{key:${key},factory:function(${EMITTED_PARAMS.join(",")}){${em.source}
|
|
16605
|
+
out.push(`{key:${key},factory:function(${EMITTED_PARAMS.join(",")}){${FACTORY_ARITY_GUARD}${em.source}
|
|
16584
16606
|
},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(",")}]}`);
|
|
16585
16607
|
}
|
|
16586
16608
|
return [`a:[${out.join(",")}],`];
|
|
@@ -18203,6 +18225,7 @@ function encodeForRun(ruleMap, opts) {
|
|
|
18203
18225
|
}
|
|
18204
18226
|
|
|
18205
18227
|
// src/compiler/linker.ts
|
|
18228
|
+
import { PlainNode as PlainNode3, PlainTaggedNode } from "../cst/plain.js";
|
|
18206
18229
|
function normalizeCstCollapse(collapse) {
|
|
18207
18230
|
if (collapse === true) return () => true;
|
|
18208
18231
|
if (Array.isArray(collapse)) {
|
|
@@ -18212,7 +18235,7 @@ function normalizeCstCollapse(collapse) {
|
|
|
18212
18235
|
return typeof collapse === "function" ? collapse : void 0;
|
|
18213
18236
|
}
|
|
18214
18237
|
function buildCstNode(type, children2, _fields, span, _rawChildren, _triviaLog, state, tags) {
|
|
18215
|
-
return tags !== void 0 && tags.length > 0 ?
|
|
18238
|
+
return tags !== void 0 && tags.length > 0 ? new PlainTaggedNode(type, tags, copySpan(span), state ?? null, [...children2]) : new PlainNode3(type, copySpan(span), state ?? null, [...children2]);
|
|
18216
18239
|
}
|
|
18217
18240
|
function cstBuildHost(typeOrOptions, children2, _fields, span, rawChildren, triviaLog, state, _tags) {
|
|
18218
18241
|
if (typeof typeOrOptions === "string") {
|