parseman 0.58.2 → 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 +344 -130
- package/dist/analysis/diagnostics.js.map +3 -3
- package/dist/cli/index.js +346 -131
- 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/first-set.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 +28 -4
- package/dist/compiler/token-capability.js.map +2 -2
- package/dist/compiler/token-scanner.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/index.js +350 -138
- package/dist/index.js.map +3 -3
- package/dist/language-service/index.js +29 -5
- package/dist/language-service/index.js.map +3 -3
- package/dist/lead-ranges.d.ts +26 -0
- package/dist/lead-ranges.d.ts.map +1 -0
- 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 +352 -140
- package/dist/plugin/index.js.map +3 -3
- package/dist/recovery/scan.d.ts.map +1 -1
- package/dist/regex/classes.d.ts +5 -3
- package/dist/regex/classes.d.ts.map +1 -1
- package/dist/regex/first-set.d.ts +7 -1
- package/dist/regex/first-set.d.ts.map +1 -1
- package/dist/run/index.js +14 -4
- package/dist/run/index.js.map +3 -3
- 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/compile-rule-map.d.ts.map +1 -1
- package/dist/table/emit-assembly.d.ts +9 -2
- 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-baseline.d.ts.map +1 -1
- package/dist/table/index.js +330 -129
- package/dist/table/index.js.map +3 -3
- package/dist/table/program.d.ts.map +1 -1
- package/dist/table/run-support.d.ts.map +1 -1
- package/dist/table/scan-shapes.d.ts +1 -1
- package/dist/table/scan-shapes.d.ts.map +1 -1
- package/dist/table/site-labels.d.ts.map +1 -1
- package/dist/table/trivia-gap.d.ts +11 -1
- package/dist/table/trivia-gap.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -1
- package/src/combinators/choice.ts +4 -0
- package/src/combinators/dispatch.ts +2 -1
- package/src/combinators/field-trivia.ts +6 -5
- package/src/combinators/first-set.ts +13 -4
- 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 +33 -13
- package/src/combinators/scanTo.ts +2 -1
- package/src/combinators/token.ts +3 -6
- package/src/compiler/linker.ts +4 -2
- package/src/compiler/token-scanner.ts +4 -1
- 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/lead-ranges.ts +53 -0
- package/src/line-index.ts +37 -0
- package/src/plugin/entry-supercompiler.ts +3 -2
- package/src/recovery/scan.ts +4 -4
- package/src/regex/classes.ts +22 -7
- package/src/regex/first-set.ts +67 -12
- package/src/table/assemble.ts +75 -38
- package/src/table/compile-rule-map.ts +5 -3
- package/src/table/emit-assembly.ts +69 -32
- package/src/table/emit.ts +9 -1
- package/src/table/encode-baseline.ts +2 -1
- package/src/table/program.ts +2 -1
- package/src/table/run-support.ts +4 -7
- package/src/table/scan-shapes.ts +5 -2
- package/src/table/site-labels.ts +2 -1
- package/src/table/trivia-gap.ts +19 -0
- package/src/version.ts +1 -1
package/dist/table/index.js
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
// src/lead-ranges.ts
|
|
2
|
+
function rangesHaveLead(ranges, code) {
|
|
3
|
+
for (const r of ranges) if (code >= r.lo && code <= r.hi) return true;
|
|
4
|
+
if (code <= 65535) return false;
|
|
5
|
+
const high = 55296 + (code - 65536 >> 10);
|
|
6
|
+
for (const r of ranges) if (high >= r.lo && high <= r.hi) return true;
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
function leadRanges(ranges) {
|
|
10
|
+
let out;
|
|
11
|
+
for (const r of ranges) {
|
|
12
|
+
const lo = Math.max(r.lo, 55296), hi = Math.min(r.hi, 56319);
|
|
13
|
+
if (lo <= hi) (out ??= [...ranges]).push({ lo: 65536 + (lo - 55296 << 10), hi: 65536 + (hi - 55296 << 10) + 1023 });
|
|
14
|
+
}
|
|
15
|
+
return out ?? ranges;
|
|
16
|
+
}
|
|
17
|
+
function implicitLeadsDropped(ranges) {
|
|
18
|
+
const implied = leadRanges(ranges.filter((r) => r.lo <= 65535)).filter((r) => r.lo > 65535);
|
|
19
|
+
const out = [];
|
|
20
|
+
for (const r of ranges) {
|
|
21
|
+
let pieces = [{ lo: r.lo, hi: r.hi }];
|
|
22
|
+
if (r.hi > 65535) for (const c of implied) {
|
|
23
|
+
pieces = pieces.flatMap((q2) => q2.hi < c.lo || q2.lo > c.hi ? [q2] : [...q2.lo < c.lo ? [{ lo: q2.lo, hi: c.lo - 1 }] : [], ...q2.hi > c.hi ? [{ lo: c.hi + 1, hi: q2.hi }] : []]);
|
|
24
|
+
}
|
|
25
|
+
out.push(...pieces);
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
|
|
1
30
|
// src/combinators/first-set.ts
|
|
2
31
|
function classifyFinalChoice(arms, resolve, activeTrivia) {
|
|
3
32
|
const firstSets = [];
|
|
@@ -59,8 +88,9 @@ function union(a, b) {
|
|
|
59
88
|
function intersects(a, b) {
|
|
60
89
|
if (a.kind === "any" || b.kind === "any") return true;
|
|
61
90
|
if (a.kind === "empty" || b.kind === "empty") return false;
|
|
62
|
-
|
|
63
|
-
|
|
91
|
+
const bs = leadRanges(b.ranges);
|
|
92
|
+
for (const ra of leadRanges(a.ranges)) {
|
|
93
|
+
for (const rb of bs) {
|
|
64
94
|
if (ra.lo <= rb.hi && rb.lo <= ra.hi) return true;
|
|
65
95
|
}
|
|
66
96
|
}
|
|
@@ -76,6 +106,9 @@ function startsFirstSet(combinator, input, pos) {
|
|
|
76
106
|
const code = input.codePointAt(pos);
|
|
77
107
|
if (code === void 0) return false;
|
|
78
108
|
for (const r of fs.ranges) if (code >= r.lo && code <= r.hi) return true;
|
|
109
|
+
if (code <= 65535) return false;
|
|
110
|
+
const high = 55296 + (code - 65536 >> 10);
|
|
111
|
+
for (const r of fs.ranges) if (high >= r.lo && high <= r.hi) return true;
|
|
79
112
|
return false;
|
|
80
113
|
}
|
|
81
114
|
function fromRange(lo, hi) {
|
|
@@ -176,12 +209,13 @@ function narrowBy(acc, constraint) {
|
|
|
176
209
|
if (acc.kind === "any") return constraint;
|
|
177
210
|
if (acc.kind === "empty" || constraint.kind === "empty") return { kind: "empty" };
|
|
178
211
|
const ranges = [];
|
|
179
|
-
|
|
212
|
+
const bs = leadRanges(constraint.ranges);
|
|
213
|
+
for (const a of leadRanges(acc.ranges)) for (const b of bs) {
|
|
180
214
|
const lo = Math.max(a.lo, b.lo);
|
|
181
215
|
const hi = Math.min(a.hi, b.hi);
|
|
182
216
|
if (lo <= hi) ranges.push({ lo, hi });
|
|
183
217
|
}
|
|
184
|
-
return ranges.length === 0 ? { kind: "empty" } : { kind: "ranges", ranges };
|
|
218
|
+
return ranges.length === 0 ? { kind: "empty" } : { kind: "ranges", ranges: implicitLeadsDropped(ranges) };
|
|
185
219
|
}
|
|
186
220
|
function applyAssertion(fs, assertion) {
|
|
187
221
|
return assertion === null ? fs : fs.kind === "empty" ? assertion : narrowBy(fs, assertion);
|
|
@@ -349,6 +383,7 @@ function createDetachedParseContext(trackLines, state) {
|
|
|
349
383
|
}
|
|
350
384
|
|
|
351
385
|
// src/line-index.ts
|
|
386
|
+
import { PlainLineSpan, PlainSpan } from "../cst/plain.js";
|
|
352
387
|
function createLineIndex() {
|
|
353
388
|
return { lineStarts: [0] };
|
|
354
389
|
}
|
|
@@ -401,6 +436,14 @@ function annotateSpan(span, index) {
|
|
|
401
436
|
endColumn: e.col
|
|
402
437
|
};
|
|
403
438
|
}
|
|
439
|
+
function lineSpanFromContext(span, ctx) {
|
|
440
|
+
if (!ctx.trackLines) return span;
|
|
441
|
+
const index = ctx._lineIndex ?? (ctx._lineStarts ? { lineStarts: ctx._lineStarts } : void 0);
|
|
442
|
+
if (!index) return span;
|
|
443
|
+
const s = offsetToLineCol(index, span.start);
|
|
444
|
+
const e = offsetToLineCol(index, span.end);
|
|
445
|
+
return new PlainLineSpan(span.start, span.end, s.line, s.col, e.line, e.col);
|
|
446
|
+
}
|
|
404
447
|
function annotateSpanFromLineContext(span, ctx) {
|
|
405
448
|
if (!ctx.trackLines) return span;
|
|
406
449
|
const index = ctx._lineIndex ?? (ctx._lineStarts ? { lineStarts: ctx._lineStarts } : void 0);
|
|
@@ -605,15 +648,19 @@ function rebuildLineScan(s, subtree) {
|
|
|
605
648
|
}
|
|
606
649
|
|
|
607
650
|
// src/cst/capture-buffer.ts
|
|
651
|
+
import { PlainBuf, PlainLeaf } from "../cst/plain.js";
|
|
608
652
|
function cstCaptureActive(ctx) {
|
|
609
653
|
return ctx._cstBuf !== void 0 || ctx._cstLeaves !== void 0;
|
|
610
654
|
}
|
|
655
|
+
function isLeaf(v) {
|
|
656
|
+
return typeof v === "object" && v !== null && v._tag === "leaf";
|
|
657
|
+
}
|
|
611
658
|
function pushCstLeaf(ctx, leaf2) {
|
|
612
659
|
if (!ctx.trackLines) {
|
|
613
660
|
pushCstChild(ctx, leaf2, leaf2);
|
|
614
661
|
return;
|
|
615
662
|
}
|
|
616
|
-
const annotated = leaf2 && typeof leaf2 === "object" && leaf2.span ? { ...leaf2, span: annotateSpanFromLineContext(leaf2.span, ctx) } : leaf2;
|
|
663
|
+
const annotated = isLeaf(leaf2) ? new PlainLeaf(leaf2.value, lineSpanFromContext(leaf2.span, ctx)) : leaf2 && typeof leaf2 === "object" && leaf2.span ? { ...leaf2, span: annotateSpanFromLineContext(leaf2.span, ctx) } : leaf2;
|
|
617
664
|
pushCstChild(ctx, annotated, annotated);
|
|
618
665
|
}
|
|
619
666
|
function pushCstChild(ctx, built, rawEntry2) {
|
|
@@ -806,11 +853,17 @@ function shorthandRanges(ch2) {
|
|
|
806
853
|
if (ch2 === "s") return SPACE_RANGES;
|
|
807
854
|
return [[48, 57], [65, 90], [97, 122], [95, 95]];
|
|
808
855
|
}
|
|
809
|
-
function readUnicodeEscape(body, i) {
|
|
856
|
+
function readUnicodeEscape(body, i, unicode = false) {
|
|
810
857
|
if (body[i] !== "\\" || body[i + 1] !== "u") return null;
|
|
811
858
|
const hex = body.slice(i + 2, i + 6);
|
|
812
859
|
if (!/^[0-9a-fA-F]{4}$/.test(hex)) return null;
|
|
813
|
-
|
|
860
|
+
const cp = Number.parseInt(hex, 16);
|
|
861
|
+
if (unicode && cp >= 55296 && cp <= 56319 && body[i + 6] === "\\" && body[i + 7] === "u") {
|
|
862
|
+
const lowHex = body.slice(i + 8, i + 12);
|
|
863
|
+
const low = /^[0-9a-fA-F]{4}$/.test(lowHex) ? Number.parseInt(lowHex, 16) : -1;
|
|
864
|
+
if (low >= 56320 && low <= 57343) return { cp: 65536 + (cp - 55296 << 10) + (low - 56320), next: i + 12 };
|
|
865
|
+
}
|
|
866
|
+
return { cp, next: i + 6 };
|
|
814
867
|
}
|
|
815
868
|
var META = new Set("()[]{}*+?|^$.".split(""));
|
|
816
869
|
function literalCodePoints(frag) {
|
|
@@ -822,6 +875,7 @@ function literalCodePoints(frag) {
|
|
|
822
875
|
const e = frag[i + 1];
|
|
823
876
|
if (e === void 0) return null;
|
|
824
877
|
if (!(e in CLASS_ESCAPES) && /\w/.test(e)) return null;
|
|
878
|
+
if (e === "0" && frag[i + 2] !== void 0 && frag[i + 2] >= "0" && frag[i + 2] <= "9") return null;
|
|
825
879
|
out.push(e in CLASS_ESCAPES ? CLASS_ESCAPES[e] : e.codePointAt(0));
|
|
826
880
|
i += 2;
|
|
827
881
|
continue;
|
|
@@ -862,14 +916,14 @@ function parseClassOperand(body) {
|
|
|
862
916
|
if (cps && cps.length === 1) return { ranges: [[cps[0], cps[0]]], negated: false };
|
|
863
917
|
return null;
|
|
864
918
|
}
|
|
865
|
-
function parseClassRanges(body) {
|
|
919
|
+
function parseClassRanges(body, unicode = false) {
|
|
866
920
|
const ranges = [];
|
|
867
921
|
let i = 0;
|
|
868
922
|
const readAtom = () => {
|
|
869
923
|
const ch2 = body[i];
|
|
870
924
|
if (ch2 === void 0) return null;
|
|
871
925
|
if (ch2 === "\\") {
|
|
872
|
-
const uni = readUnicodeEscape(body, i);
|
|
926
|
+
const uni = readUnicodeEscape(body, i, unicode);
|
|
873
927
|
if (uni) {
|
|
874
928
|
i = uni.next;
|
|
875
929
|
return { cp: uni.cp };
|
|
@@ -877,13 +931,15 @@ function parseClassRanges(body) {
|
|
|
877
931
|
const e = body[i + 1];
|
|
878
932
|
if (e === void 0) return null;
|
|
879
933
|
i += 2;
|
|
934
|
+
if (e === "0" && body[i] !== void 0 && body[i] >= "0" && body[i] <= "9" || e >= "1" && e <= "9") return null;
|
|
880
935
|
if (e in CLASS_ESCAPES) return { cp: CLASS_ESCAPES[e] };
|
|
881
936
|
if (e === "d" || e === "w" || e === "s") return { set: shorthandRanges(e) };
|
|
882
937
|
if (e >= "a" && e <= "z" || e >= "A" && e <= "Z") return null;
|
|
883
938
|
return { cp: e.codePointAt(0) };
|
|
884
939
|
}
|
|
885
|
-
i
|
|
886
|
-
|
|
940
|
+
const cp = unicode ? body.codePointAt(i) : body.charCodeAt(i);
|
|
941
|
+
i += cp > 65535 ? 2 : 1;
|
|
942
|
+
return { cp };
|
|
887
943
|
};
|
|
888
944
|
while (i < body.length) {
|
|
889
945
|
const lo = readAtom();
|
|
@@ -1519,6 +1575,7 @@ function triviaKindMask(labels, keep) {
|
|
|
1519
1575
|
}
|
|
1520
1576
|
|
|
1521
1577
|
// src/recovery/scan.ts
|
|
1578
|
+
import { PlainSpan as PlainSpan2 } from "../cst/plain.js";
|
|
1522
1579
|
function probeAt(sentinel, input, pos, ctx) {
|
|
1523
1580
|
const s = {
|
|
1524
1581
|
_probe: ctx._probe,
|
|
@@ -1586,9 +1643,7 @@ function firstSetSentinel(fs) {
|
|
|
1586
1643
|
parse(input, pos) {
|
|
1587
1644
|
const code = pos < input.length ? input.codePointAt(pos) : void 0;
|
|
1588
1645
|
if (code !== void 0) {
|
|
1589
|
-
|
|
1590
|
-
if (code >= r.lo && code <= r.hi) return { ok: true, value: null, span: { start: pos, end: pos } };
|
|
1591
|
-
}
|
|
1646
|
+
if (rangesHaveLead(ranges, code)) return { ok: true, value: null, span: { start: pos, end: pos } };
|
|
1592
1647
|
}
|
|
1593
1648
|
return { ok: false, expected: [], span: { start: pos, end: pos } };
|
|
1594
1649
|
}
|
|
@@ -1597,7 +1652,7 @@ function firstSetSentinel(fs) {
|
|
|
1597
1652
|
function recoverScan(input, from, ctx, sync, expected) {
|
|
1598
1653
|
let scanPos = from;
|
|
1599
1654
|
while (scanPos < input.length && !probeAt(sync, input, scanPos, ctx)) scanPos++;
|
|
1600
|
-
const span =
|
|
1655
|
+
const span = new PlainSpan2(from, scanPos);
|
|
1601
1656
|
if (ctx.trackLines) recordLineRangeFromContext(ctx, input, from, scanPos);
|
|
1602
1657
|
const error = { _tag: "parseError", span: ctx.trackLines ? annotateSpanFromLineContext(span, ctx) : span, expected };
|
|
1603
1658
|
ctx._errors?.push(error);
|
|
@@ -2673,6 +2728,9 @@ function inFirstSet(code, fs) {
|
|
|
2673
2728
|
if (fs.kind === "any") return true;
|
|
2674
2729
|
if (fs.kind === "empty") return false;
|
|
2675
2730
|
for (const r of fs.ranges) if (code >= r.lo && code <= r.hi) return true;
|
|
2731
|
+
if (code <= 65535) return false;
|
|
2732
|
+
const high = 55296 + (code - 65536 >> 10);
|
|
2733
|
+
for (const r of fs.ranges) if (high >= r.lo && high <= r.hi) return true;
|
|
2676
2734
|
return false;
|
|
2677
2735
|
}
|
|
2678
2736
|
function areDisjoint(sets) {
|
|
@@ -2697,17 +2755,18 @@ function buildAsciiDispatch(parsers) {
|
|
|
2697
2755
|
}
|
|
2698
2756
|
|
|
2699
2757
|
// src/combinators/field-trivia.ts
|
|
2758
|
+
import { PlainSpan as PlainSpan3, PlainTriviaField } from "../cst/plain.js";
|
|
2700
2759
|
var LEAD = { at: -1 };
|
|
2701
2760
|
var FIELD_LEADING_TRIVIA = 1;
|
|
2702
2761
|
var FIELD_TRAILING_TRIVIA = 2;
|
|
2703
2762
|
function triviaFieldCapture(name, value, input, start, end, leadFrom, trailEnd) {
|
|
2704
|
-
return
|
|
2763
|
+
return new PlainTriviaField(
|
|
2705
2764
|
name,
|
|
2706
2765
|
value,
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2766
|
+
new PlainSpan3(start, end),
|
|
2767
|
+
leadFrom >= 0 && leadFrom < start ? input.slice(leadFrom, start) : "",
|
|
2768
|
+
trailEnd > end ? input.slice(end, trailEnd) : ""
|
|
2769
|
+
);
|
|
2711
2770
|
}
|
|
2712
2771
|
function leadsTrivia(p) {
|
|
2713
2772
|
return p._def.tag === "field" && p._def.leadingTrivia === true;
|
|
@@ -3016,7 +3075,7 @@ function rangesHaveNewline(ranges) {
|
|
|
3016
3075
|
return ranges.some(([lo, hi]) => lo <= 10 && 10 <= hi);
|
|
3017
3076
|
}
|
|
3018
3077
|
var BAIL = /* @__PURE__ */ Symbol("regex-bail");
|
|
3019
|
-
function parseRegex(src) {
|
|
3078
|
+
function parseRegex(src, unicode = false, sets = false) {
|
|
3020
3079
|
let i = 0;
|
|
3021
3080
|
const parseAlt = () => {
|
|
3022
3081
|
const arms = [parseSeq()];
|
|
@@ -3086,9 +3145,11 @@ function parseRegex(src) {
|
|
|
3086
3145
|
i++;
|
|
3087
3146
|
return charNode(fromRange(123, 123), false);
|
|
3088
3147
|
// a `{` with nothing to quantify is a literal brace
|
|
3089
|
-
default:
|
|
3090
|
-
i
|
|
3091
|
-
|
|
3148
|
+
default: {
|
|
3149
|
+
const cp = unicode ? src.codePointAt(i) : src.charCodeAt(i);
|
|
3150
|
+
i += cp > 65535 ? 2 : 1;
|
|
3151
|
+
return charNode(fromRange(cp, cp), ch2 === "\n");
|
|
3152
|
+
}
|
|
3092
3153
|
}
|
|
3093
3154
|
};
|
|
3094
3155
|
const parseGroup = () => {
|
|
@@ -3121,6 +3182,32 @@ function parseRegex(src) {
|
|
|
3121
3182
|
let k = i + 1;
|
|
3122
3183
|
const negated = src[k] === "^";
|
|
3123
3184
|
if (negated) k++;
|
|
3185
|
+
if (sets) {
|
|
3186
|
+
let depth = 1;
|
|
3187
|
+
let nested = false;
|
|
3188
|
+
while (k < src.length && depth > 0) {
|
|
3189
|
+
const c = src[k];
|
|
3190
|
+
if (c === "\\") {
|
|
3191
|
+
if (src[k + 1] === "q") nested = true;
|
|
3192
|
+
k += 2;
|
|
3193
|
+
continue;
|
|
3194
|
+
}
|
|
3195
|
+
if (c === "[") {
|
|
3196
|
+
depth++;
|
|
3197
|
+
nested = true;
|
|
3198
|
+
} else if (c === "]") {
|
|
3199
|
+
depth--;
|
|
3200
|
+
if (depth === 0) break;
|
|
3201
|
+
} else if ((c === "-" || c === "&") && src[k + 1] === c) nested = true;
|
|
3202
|
+
k++;
|
|
3203
|
+
}
|
|
3204
|
+
if (src[k] !== "]") throw BAIL;
|
|
3205
|
+
if (nested) {
|
|
3206
|
+
i = k + 1;
|
|
3207
|
+
return charNode(any(), true);
|
|
3208
|
+
}
|
|
3209
|
+
k = i + 1 + (negated ? 1 : 0);
|
|
3210
|
+
}
|
|
3124
3211
|
let body = "";
|
|
3125
3212
|
while (k < src.length && src[k] !== "]") {
|
|
3126
3213
|
if (src[k] === "\\") {
|
|
@@ -3133,7 +3220,7 @@ function parseRegex(src) {
|
|
|
3133
3220
|
}
|
|
3134
3221
|
if (src[k] !== "]") throw BAIL;
|
|
3135
3222
|
i = k + 1;
|
|
3136
|
-
const ranges = parseClassRanges(body);
|
|
3223
|
+
const ranges = parseClassRanges(body, unicode);
|
|
3137
3224
|
if (negated) return charNode(any(), !ranges || !rangesHaveNewline(ranges));
|
|
3138
3225
|
if (!ranges) return charNode(any(), true);
|
|
3139
3226
|
return charNode(rangesToSet(ranges), rangesHaveNewline(ranges));
|
|
@@ -3141,9 +3228,20 @@ function parseRegex(src) {
|
|
|
3141
3228
|
const parseEscape = () => {
|
|
3142
3229
|
const e = src[i + 1];
|
|
3143
3230
|
if (e === void 0) throw BAIL;
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
i
|
|
3231
|
+
const uni = readUnicodeEscape(src, i, unicode);
|
|
3232
|
+
if (uni !== null) {
|
|
3233
|
+
i = uni.next;
|
|
3234
|
+
return charNode(fromRange(uni.cp, uni.cp), uni.cp === 10);
|
|
3235
|
+
}
|
|
3236
|
+
if (e === "u" && src[i + 2] === "{") {
|
|
3237
|
+
const close = src.indexOf("}", i + 3);
|
|
3238
|
+
const hex = close < 0 ? "" : src.slice(i + 3, close);
|
|
3239
|
+
if (!unicode || !/^[0-9a-fA-F]{1,6}$/.test(hex)) {
|
|
3240
|
+
i += 2;
|
|
3241
|
+
return ANY;
|
|
3242
|
+
}
|
|
3243
|
+
const cp = Number.parseInt(hex, 16);
|
|
3244
|
+
i = close + 1;
|
|
3147
3245
|
return charNode(fromRange(cp, cp), cp === 10);
|
|
3148
3246
|
}
|
|
3149
3247
|
if (e === "x" && /^[0-9a-fA-F]{2}$/.test(src.slice(i + 2, i + 4))) {
|
|
@@ -3151,6 +3249,16 @@ function parseRegex(src) {
|
|
|
3151
3249
|
i += 4;
|
|
3152
3250
|
return charNode(fromRange(cp, cp), cp === 10);
|
|
3153
3251
|
}
|
|
3252
|
+
if (e === "c") {
|
|
3253
|
+
const x = src[i + 2];
|
|
3254
|
+
if (x !== void 0 && /^[A-Za-z]$/.test(x)) {
|
|
3255
|
+
const cp = x.charCodeAt(0) % 32;
|
|
3256
|
+
i += 3;
|
|
3257
|
+
return charNode(fromRange(cp, cp), cp === 10);
|
|
3258
|
+
}
|
|
3259
|
+
i += 2;
|
|
3260
|
+
return ANY;
|
|
3261
|
+
}
|
|
3154
3262
|
i += 2;
|
|
3155
3263
|
switch (e) {
|
|
3156
3264
|
case "d":
|
|
@@ -3178,8 +3286,16 @@ function parseRegex(src) {
|
|
|
3178
3286
|
return charNode(fromRange(12, 12), false);
|
|
3179
3287
|
case "v":
|
|
3180
3288
|
return charNode(fromRange(11, 11), false);
|
|
3289
|
+
// `\0` then a digit is a legacy octal escape (`\012` is a newline), not NUL.
|
|
3181
3290
|
case "0":
|
|
3182
|
-
return charNode(fromRange(0, 0), false);
|
|
3291
|
+
return src[i] !== void 0 && src[i] >= "0" && src[i] <= "9" ? ANY : charNode(fromRange(0, 0), false);
|
|
3292
|
+
// A property escape (`\p{…}`/`\P{…}`) matches one character of a class this
|
|
3293
|
+
// analyzer does not enumerate; `\k<name>` is a backreference, which may match empty.
|
|
3294
|
+
case "p":
|
|
3295
|
+
case "P":
|
|
3296
|
+
return charNode(any(), true);
|
|
3297
|
+
case "k":
|
|
3298
|
+
return ANY;
|
|
3183
3299
|
default:
|
|
3184
3300
|
if (e >= "1" && e <= "9") return ANY;
|
|
3185
3301
|
return charNode(fromRange(e.codePointAt(0), e.codePointAt(0)), e === "\n");
|
|
@@ -3253,10 +3369,10 @@ function regexCanMatchEmpty(source) {
|
|
|
3253
3369
|
return true;
|
|
3254
3370
|
}
|
|
3255
3371
|
}
|
|
3256
|
-
function firstSetFromRegex(source) {
|
|
3372
|
+
function firstSetFromRegex(source, flags = "") {
|
|
3257
3373
|
let ast;
|
|
3258
3374
|
try {
|
|
3259
|
-
ast = parseRegex(source);
|
|
3375
|
+
ast = parseRegex(source, flags.includes("u") || flags.includes("v"), flags.includes("v"));
|
|
3260
3376
|
} catch {
|
|
3261
3377
|
return { firstSet: any(), canMatchNewline: true };
|
|
3262
3378
|
}
|
|
@@ -3265,6 +3381,7 @@ function firstSetFromRegex(source) {
|
|
|
3265
3381
|
}
|
|
3266
3382
|
|
|
3267
3383
|
// src/combinators/regex.ts
|
|
3384
|
+
import { PlainLeaf as PlainLeaf2, PlainSpan as PlainSpan4 } from "../cst/plain.js";
|
|
3268
3385
|
var SCAN_BAIL_AT = 64;
|
|
3269
3386
|
function inRanges3(cp, ranges) {
|
|
3270
3387
|
for (let i = 0; i < ranges.length; i++) {
|
|
@@ -3305,8 +3422,18 @@ function shortScanner(source, flags) {
|
|
|
3305
3422
|
return minOne && end === pos ? null : end;
|
|
3306
3423
|
};
|
|
3307
3424
|
}
|
|
3425
|
+
function coversNonAscii(ranges) {
|
|
3426
|
+
let next = 128;
|
|
3427
|
+
for (const r of [...ranges].sort((a, b) => a.lo - b.lo)) {
|
|
3428
|
+
if (r.lo > next) return false;
|
|
3429
|
+
if (r.hi >= next) next = r.hi + 1;
|
|
3430
|
+
if (next > 65535) return true;
|
|
3431
|
+
}
|
|
3432
|
+
return false;
|
|
3433
|
+
}
|
|
3308
3434
|
function asciiCaseFold(fs) {
|
|
3309
3435
|
if (fs.kind !== "ranges") return fs;
|
|
3436
|
+
if (fs.ranges.some((r) => r.hi >= 128) && !coversNonAscii(fs.ranges)) return any();
|
|
3310
3437
|
const ranges = fs.ranges.map((r) => ({ lo: r.lo, hi: r.hi }));
|
|
3311
3438
|
const add = (lo, hi) => {
|
|
3312
3439
|
if (lo <= hi) ranges.push({ lo, hi });
|
|
@@ -3331,7 +3458,7 @@ function regex(pattern, flags = "") {
|
|
|
3331
3458
|
const resolvedFlags = typeof pattern === "string" ? flags : pattern.flags;
|
|
3332
3459
|
const anchored = new RegExp(source, "y" + resolvedFlags.replace(/[gy]/g, ""));
|
|
3333
3460
|
const scan = shortScanner(source, resolvedFlags);
|
|
3334
|
-
const raw = firstSetFromRegex(source);
|
|
3461
|
+
const raw = firstSetFromRegex(source, resolvedFlags);
|
|
3335
3462
|
const firstSet2 = !resolvedFlags.includes("i") ? raw.firstSet : resolvedFlags.includes("u") || resolvedFlags.includes("v") ? any() : asciiCaseFold(raw.firstSet);
|
|
3336
3463
|
const canMatchNewline = raw.canMatchNewline;
|
|
3337
3464
|
const meta = { firstSet: firstSet2, canMatchNewline, isTrivia: false };
|
|
@@ -3367,9 +3494,9 @@ function regex(pattern, flags = "") {
|
|
|
3367
3494
|
if (scanEnd !== void 0) {
|
|
3368
3495
|
if (scanEnd === null) return failAt(ctx, directTerminalFailureExpected(def), pos);
|
|
3369
3496
|
const value = input.slice(pos, scanEnd);
|
|
3370
|
-
const span2 =
|
|
3497
|
+
const span2 = new PlainSpan4(pos, scanEnd);
|
|
3371
3498
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, scanEnd);
|
|
3372
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
3499
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf2(value, span2));
|
|
3373
3500
|
return { ok: true, value, span: span2 };
|
|
3374
3501
|
}
|
|
3375
3502
|
anchored.lastIndex = pos;
|
|
@@ -3377,9 +3504,9 @@ function regex(pattern, flags = "") {
|
|
|
3377
3504
|
if (m === null) {
|
|
3378
3505
|
return failAt(ctx, directTerminalFailureExpected(def), pos);
|
|
3379
3506
|
}
|
|
3380
|
-
const span =
|
|
3507
|
+
const span = new PlainSpan4(pos, pos + m[0].length);
|
|
3381
3508
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, span.end);
|
|
3382
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
3509
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf2(m[0], span));
|
|
3383
3510
|
return { ok: true, value: m[0], span };
|
|
3384
3511
|
}
|
|
3385
3512
|
};
|
|
@@ -3406,6 +3533,7 @@ function buildLexBodyRecognizer(spec, constants) {
|
|
|
3406
3533
|
}
|
|
3407
3534
|
|
|
3408
3535
|
// src/table/run-support.ts
|
|
3536
|
+
import { PlainLeaf as PlainLeaf3, PlainLineSpan as PlainLineSpan2, PlainSpan as PlainSpan5 } from "../cst/plain.js";
|
|
3409
3537
|
function lineCol(ctx, offset) {
|
|
3410
3538
|
const starts = ctx._lineStarts ?? [0];
|
|
3411
3539
|
let lo = 0, hi = starts.length - 1;
|
|
@@ -3418,18 +3546,14 @@ function lineCol(ctx, offset) {
|
|
|
3418
3546
|
}
|
|
3419
3547
|
function spanLines(ctx, start, end) {
|
|
3420
3548
|
const s = lineCol(ctx, start), e = lineCol(ctx, end);
|
|
3421
|
-
return
|
|
3549
|
+
return new PlainLineSpan2(start, end, s[0], s[1], e[0], e[1]);
|
|
3422
3550
|
}
|
|
3423
3551
|
function rawEntry(v, input, s, e) {
|
|
3424
3552
|
if (typeof v === "object" && v !== null) {
|
|
3425
3553
|
const tg = v._tag;
|
|
3426
3554
|
if (tg === "node" || tg === "leaf" || tg === "parseError") return v;
|
|
3427
3555
|
}
|
|
3428
|
-
return
|
|
3429
|
-
_tag: "leaf",
|
|
3430
|
-
value: typeof v === "string" ? v : typeof v === "object" && v !== null ? input.slice(s, e) : "",
|
|
3431
|
-
span: { start: s, end: e }
|
|
3432
|
-
};
|
|
3556
|
+
return new PlainLeaf3(typeof v === "string" ? v : typeof v === "object" && v !== null ? input.slice(s, e) : "", new PlainSpan5(s, e));
|
|
3433
3557
|
}
|
|
3434
3558
|
function lead(input, pos) {
|
|
3435
3559
|
if (pos >= input.length) return -1;
|
|
@@ -3443,7 +3567,7 @@ function collapseEmpty(ctx, build, input, pos, end, readsRaw) {
|
|
|
3443
3567
|
const collected = ctx._cstBuf !== void 0 || ctx._cstChildren !== void 0;
|
|
3444
3568
|
if (collected) popCstChild(ctx);
|
|
3445
3569
|
const raw = readsRaw ? [rawEntry(void 0, input, pos, end)] : EMPTY_KIDS;
|
|
3446
|
-
const nd = build(EMPTY_KIDS, void 0,
|
|
3570
|
+
const nd = build(EMPTY_KIDS, void 0, new PlainSpan5(pos, end), raw, EMPTY_TRIVIA, void 0);
|
|
3447
3571
|
if (collected) pushCstChild(ctx, nd, ctx._cstBuf?.noRaw === true ? void 0 : rawEntry(nd, input, pos, end));
|
|
3448
3572
|
return nd;
|
|
3449
3573
|
}
|
|
@@ -4113,7 +4237,7 @@ function decodeClassSpec(spec) {
|
|
|
4113
4237
|
function resolveClass(spec) {
|
|
4114
4238
|
const ascii = new Uint8Array(128);
|
|
4115
4239
|
const hi = [];
|
|
4116
|
-
for (const { lo, hi: up } of decodeClassSpec(spec)) {
|
|
4240
|
+
for (const { lo, hi: up } of leadRanges(decodeClassSpec(spec))) {
|
|
4117
4241
|
if (lo < 128) for (let c = lo; c <= Math.min(up, 127); c++) ascii[c] = 1;
|
|
4118
4242
|
if (up >= 128) hi.push(Math.max(lo, 128), up);
|
|
4119
4243
|
}
|
|
@@ -4324,6 +4448,7 @@ function expandCompactFolded(f) {
|
|
|
4324
4448
|
}
|
|
4325
4449
|
|
|
4326
4450
|
// src/combinators/literal.ts
|
|
4451
|
+
import { PlainLeaf as PlainLeaf4, PlainSpan as PlainSpan6 } from "../cst/plain.js";
|
|
4327
4452
|
function asciiFoldEq(a, b) {
|
|
4328
4453
|
if (a.length !== b.length) return false;
|
|
4329
4454
|
for (let i = 0; i < a.length; i++) {
|
|
@@ -4381,9 +4506,9 @@ function literal(value, opts = {}) {
|
|
|
4381
4506
|
const code = value.charCodeAt(0);
|
|
4382
4507
|
return function parse2(input, pos, ctx) {
|
|
4383
4508
|
if (input.charCodeAt(pos) === code) {
|
|
4384
|
-
const span =
|
|
4509
|
+
const span = new PlainSpan6(pos, pos + 1);
|
|
4385
4510
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, span.end);
|
|
4386
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
4511
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf4(value, span));
|
|
4387
4512
|
return { ok: true, value, span };
|
|
4388
4513
|
}
|
|
4389
4514
|
return failAt(ctx, expected, pos);
|
|
@@ -4395,9 +4520,9 @@ function literal(value, opts = {}) {
|
|
|
4395
4520
|
}
|
|
4396
4521
|
const matchedValue = caseInsensitive ? input.slice(pos, end) : value;
|
|
4397
4522
|
if (caseInsensitive ? asciiFoldEq(matchedValue, value) : input.startsWith(value, pos)) {
|
|
4398
|
-
const span =
|
|
4523
|
+
const span = new PlainSpan6(pos, end);
|
|
4399
4524
|
if (canMatchNewline && ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, end);
|
|
4400
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
4525
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf4(matchedValue, span));
|
|
4401
4526
|
return { ok: true, value: matchedValue, span };
|
|
4402
4527
|
}
|
|
4403
4528
|
return failAt(ctx, expected, pos);
|
|
@@ -4938,6 +5063,7 @@ function buildReadsState(def) {
|
|
|
4938
5063
|
}
|
|
4939
5064
|
|
|
4940
5065
|
// src/combinators/token.ts
|
|
5066
|
+
import { PlainLeaf as PlainLeaf5 } from "../cst/plain.js";
|
|
4941
5067
|
function semanticLeafValue(_ctx, _input, _start, _end, value) {
|
|
4942
5068
|
return value;
|
|
4943
5069
|
}
|
|
@@ -4991,7 +5117,7 @@ function token(root) {
|
|
|
4991
5117
|
if (!result.ok) return result;
|
|
4992
5118
|
const span = result.span;
|
|
4993
5119
|
const value = input.slice(pos, span.end);
|
|
4994
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
5120
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf5(value, span));
|
|
4995
5121
|
return { ok: true, value, span };
|
|
4996
5122
|
}
|
|
4997
5123
|
};
|
|
@@ -5039,11 +5165,7 @@ function makeLeaf(root, fn, sourceCstValue) {
|
|
|
5039
5165
|
}
|
|
5040
5166
|
if (!result.ok) return result;
|
|
5041
5167
|
const value = fn(result.value, result.span);
|
|
5042
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
5043
|
-
_tag: "leaf",
|
|
5044
|
-
value: cstValue(ctx, input, pos, result.span.end, value),
|
|
5045
|
-
span: result.span
|
|
5046
|
-
});
|
|
5168
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf5(cstValue(ctx, input, pos, result.span.end, value), result.span));
|
|
5047
5169
|
return { ok: true, value, span: result.span };
|
|
5048
5170
|
}
|
|
5049
5171
|
};
|
|
@@ -5056,6 +5178,7 @@ function sourceLeaf(root, fn) {
|
|
|
5056
5178
|
}
|
|
5057
5179
|
|
|
5058
5180
|
// src/combinators/scanTo.ts
|
|
5181
|
+
import { PlainLeaf as PlainLeaf6, PlainSpan as PlainSpan7 } from "../cst/plain.js";
|
|
5059
5182
|
function resolveScanSkip(explicitSkip, raw, ctx) {
|
|
5060
5183
|
if (raw) return [];
|
|
5061
5184
|
const trivia2 = ctx.trivia;
|
|
@@ -5093,7 +5216,7 @@ function scanTo(sentinel, { skip, raw = false, orEOF = false, recoverAt, stopAt
|
|
|
5093
5216
|
probeCtx._errors = ctx._errors;
|
|
5094
5217
|
const emit = (end) => {
|
|
5095
5218
|
if (end > pos && cstCaptureActive(ctx)) {
|
|
5096
|
-
const leaf2 =
|
|
5219
|
+
const leaf2 = new PlainLeaf6(input.slice(pos, end), new PlainSpan7(pos, end));
|
|
5097
5220
|
pushCstLeaf(ctx, leaf2);
|
|
5098
5221
|
}
|
|
5099
5222
|
};
|
|
@@ -5386,6 +5509,15 @@ function skipDeferredTrivia(input, cur, ctx) {
|
|
|
5386
5509
|
if (plain) remember(cur, scan, ctx, input, triviaP);
|
|
5387
5510
|
return scan;
|
|
5388
5511
|
}
|
|
5512
|
+
function triviaLeadTable(triviaP) {
|
|
5513
|
+
const fs = triviaP._meta.firstSet;
|
|
5514
|
+
if (fs.kind === "any") return null;
|
|
5515
|
+
const table = new Uint8Array(128);
|
|
5516
|
+
if (fs.kind === "ranges") {
|
|
5517
|
+
for (const r of fs.ranges) for (let c = Math.max(0, r.lo); c <= Math.min(127, r.hi); c++) table[c] = 1;
|
|
5518
|
+
}
|
|
5519
|
+
return table;
|
|
5520
|
+
}
|
|
5389
5521
|
function clearRunEnd(input, cur, ctx, triviaP, plain) {
|
|
5390
5522
|
const rootKinds = ctx._rootTriviaKindIndex;
|
|
5391
5523
|
const spec = triviaP?._meta.labeledTriviaSpec;
|
|
@@ -5435,6 +5567,7 @@ function clearOf(ranges, input, from, to) {
|
|
|
5435
5567
|
}
|
|
5436
5568
|
|
|
5437
5569
|
// src/combinators/dispatch.ts
|
|
5570
|
+
import { PlainLeaf as PlainLeaf7 } from "../cst/plain.js";
|
|
5438
5571
|
function parserUsesRouted(parser2, seen = /* @__PURE__ */ new Set()) {
|
|
5439
5572
|
if (seen.has(parser2)) return false;
|
|
5440
5573
|
seen.add(parser2);
|
|
@@ -5503,6 +5636,7 @@ function asciiFoldKey(key) {
|
|
|
5503
5636
|
}
|
|
5504
5637
|
|
|
5505
5638
|
// src/combinators/node.ts
|
|
5639
|
+
import { PlainNode, PlainSpan as PlainSpan8 } from "../cst/plain.js";
|
|
5506
5640
|
function unwrapChild(child) {
|
|
5507
5641
|
return child !== null && typeof child === "object" && child._tag === "leaf" ? child.value : child;
|
|
5508
5642
|
}
|
|
@@ -5516,6 +5650,9 @@ function projectChild(children2, project, type) {
|
|
|
5516
5650
|
return unwrapChild(children2[project]);
|
|
5517
5651
|
}
|
|
5518
5652
|
|
|
5653
|
+
// src/table/assemble.ts
|
|
5654
|
+
import { PlainBuf as PlainBuf2, PlainField, PlainLeaf as PlainLeaf8, PlainNode as PlainNode2, PlainSpan as PlainSpan9 } from "../cst/plain.js";
|
|
5655
|
+
|
|
5519
5656
|
// src/table/ops.ts
|
|
5520
5657
|
var OP_LIT = 1;
|
|
5521
5658
|
var OP_RX = 2;
|
|
@@ -5737,6 +5874,7 @@ function parseSeqParts(source) {
|
|
|
5737
5874
|
cp2 = uni.cp;
|
|
5738
5875
|
i = uni.next;
|
|
5739
5876
|
} else if (e === void 0) return null;
|
|
5877
|
+
else if (e >= "0" && e <= "9" && (e !== "0" || source[i + 2] !== void 0 && source[i + 2] >= "0" && source[i + 2] <= "9")) return null;
|
|
5740
5878
|
else if (e in CLASS_ESCAPES) {
|
|
5741
5879
|
cp2 = CLASS_ESCAPES[e];
|
|
5742
5880
|
i += 2;
|
|
@@ -6286,7 +6424,7 @@ function parseScanShapeCore(source) {
|
|
|
6286
6424
|
return null;
|
|
6287
6425
|
}
|
|
6288
6426
|
function scanShapeFromRegex(source, flags) {
|
|
6289
|
-
if (/[
|
|
6427
|
+
if (/[msuv]/.test(flags)) return null;
|
|
6290
6428
|
if (/i/.test(flags)) return caseFoldShape(source);
|
|
6291
6429
|
return parseScanShape(source);
|
|
6292
6430
|
}
|
|
@@ -6891,7 +7029,7 @@ function triviaLeadRanges(tri, trivia2) {
|
|
|
6891
7029
|
const fs = trivia2[tri]?._meta.firstSet;
|
|
6892
7030
|
if (fs === void 0) return void 0;
|
|
6893
7031
|
if (fs.kind === "empty") return [];
|
|
6894
|
-
return fs.kind === "ranges" && fs.ranges !== void 0 ? fs.ranges : void 0;
|
|
7032
|
+
return fs.kind === "ranges" && fs.ranges !== void 0 ? leadRanges(fs.ranges) : void 0;
|
|
6895
7033
|
}
|
|
6896
7034
|
|
|
6897
7035
|
// src/table/scalar-terminal.ts
|
|
@@ -7249,7 +7387,14 @@ var EMITTED_PARAMS = [
|
|
|
7249
7387
|
"skipDeferredTrivia",
|
|
7250
7388
|
// Appended for the pass-through collapse (`run-support.ts`); old factories
|
|
7251
7389
|
// ignore it.
|
|
7252
|
-
"collapseEmpty"
|
|
7390
|
+
"collapseEmpty",
|
|
7391
|
+
// Appended for constructor-built tree objects (`cst/plain.d.ts`): a `new` call has
|
|
7392
|
+
// no allocation site, so V8 cannot pretenure them. Old factories ignore them.
|
|
7393
|
+
"_SP",
|
|
7394
|
+
"_LF",
|
|
7395
|
+
"_ND",
|
|
7396
|
+
"_FC",
|
|
7397
|
+
"_BUF"
|
|
7253
7398
|
];
|
|
7254
7399
|
var RUNTIME_PRELUDE = `
|
|
7255
7400
|
let _pfScan=null
|
|
@@ -7273,9 +7418,9 @@ if(s!==null)return skipTriviaScanned(s,input,cur,ctx)
|
|
|
7273
7418
|
if(needsDeferredTriviaCommit(ctx))return skipDeferredTrivia(input,cur,ctx)
|
|
7274
7419
|
return advanceTrivia(input,cur,ctx)
|
|
7275
7420
|
}
|
|
7276
|
-
function _pushLeaf(ctx,value,s,e){pushCstLeaf(ctx,
|
|
7421
|
+
function _pushLeaf(ctx,value,s,e){pushCstLeaf(ctx,new _LF(value,new _SP(s,e)))}
|
|
7277
7422
|
function _pushLeafBuf(ctx,value,s,e){
|
|
7278
|
-
const l=
|
|
7423
|
+
const l=new _LF(value,new _SP(s,e))
|
|
7279
7424
|
const b=ctx._cstBuf
|
|
7280
7425
|
if(b.ch!==undefined)b.ch.push(l)
|
|
7281
7426
|
else if(b.single!==undefined){b.ch=[b.single,l];b.single=undefined}
|
|
@@ -7333,7 +7478,7 @@ if(ctx._rootTriviaLog!==undefined&&ctx._rootTriviaLog.length!==rt)ctx._rootTrivi
|
|
|
7333
7478
|
`;
|
|
7334
7479
|
var NO_RAW_RUNTIME_PRELUDE = `
|
|
7335
7480
|
function _pushLeafNoRawBuf(ctx,value,s,e){
|
|
7336
|
-
const l=
|
|
7481
|
+
const l=new _LF(value,new _SP(s,e))
|
|
7337
7482
|
const b=ctx._cstBuf
|
|
7338
7483
|
if(b.ch!==undefined)b.ch.push(l)
|
|
7339
7484
|
else if(b.single!==undefined){b.ch=[b.single,l];b.single=undefined}
|
|
@@ -7421,7 +7566,7 @@ if(ctx._errors!==undefined&&ctx._errors.length!==${t}er)ctx._errors.length=${t}e
|
|
|
7421
7566
|
if (!s.fd && !s.er) return `if(${t}n)rollbackTriviaAt(ctx,${t}raw,${t}tl,${t}lv,undefined,undefined,${t}lg,${t}rt)`;
|
|
7422
7567
|
return `if(${t}n){rollbackTriviaAt(ctx,${t}raw,${t}tl,${t}lv,${s.fd ? `${t}fd` : "undefined"},${s.er ? `${t}er` : "undefined"},${t}lg,${t}rt)}`;
|
|
7423
7568
|
}
|
|
7424
|
-
function emitTerm(callee, dst, t, l, skip) {
|
|
7569
|
+
function emitTerm(callee, dst, t, l, skip, miss) {
|
|
7425
7570
|
const fast = `const ${t}v=${callee}(input,cur,ctx)
|
|
7426
7571
|
if(${t}v===FAIL)return FAIL
|
|
7427
7572
|
${dst}=${t}v
|
|
@@ -7439,7 +7584,12 @@ if(${t}v===FAIL)return FAIL
|
|
|
7439
7584
|
${dst}=${t}v
|
|
7440
7585
|
if(EC.e>${t}s)cur=EC.e
|
|
7441
7586
|
else{rollbackScannedTriviaAt(ctx,${t}tl,${t}stl,${t}lg,${t}slg,${t}rt,${t}srt)}`;
|
|
7442
|
-
if (l.tri !== TRI_UNKNOWN) return scanned
|
|
7587
|
+
if (l.tri !== TRI_UNKNOWN) return miss === void 0 ? scanned : `const ${t}c=input.charCodeAt(cur)
|
|
7588
|
+
if(${miss(`${t}c`)}){
|
|
7589
|
+
${fast}
|
|
7590
|
+
}else{
|
|
7591
|
+
${scanned}
|
|
7592
|
+
}`;
|
|
7443
7593
|
return `if(ctx.trivia===undefined){
|
|
7444
7594
|
${fast}
|
|
7445
7595
|
}else{
|
|
@@ -7495,7 +7645,7 @@ function rebuildPools(cc, fx, disp, plan) {
|
|
|
7495
7645
|
})
|
|
7496
7646
|
};
|
|
7497
7647
|
}
|
|
7498
|
-
function emitAssemblySource(t, prog, cfg, extraIps = [], staticBuild = false, select) {
|
|
7648
|
+
function emitAssemblySource(t, prog, cfg, extraIps = [], staticBuild = false, select, scanSinkNeutral = false) {
|
|
7499
7649
|
const { code, k, fx, disp, dsp, triviaLabelled } = t;
|
|
7500
7650
|
const swapLegal = !cfg.trackLines;
|
|
7501
7651
|
const hostCst = cfg.hostCst;
|
|
@@ -7571,7 +7721,7 @@ function emitAssemblySource(t, prog, cfg, extraIps = [], staticBuild = false, se
|
|
|
7571
7721
|
const op = code[ip];
|
|
7572
7722
|
sinkBits.set(
|
|
7573
7723
|
ip,
|
|
7574
|
-
op === OP_SCAN ? 3 : (op === OP_FIELD ? 1 : 0) | (op === OP_EXPECT || REC && (op === OP_REP || op === OP_REPV) ? 2 : 0)
|
|
7724
|
+
op === OP_SCAN || !scanSinkNeutral && op === OP_LEX_PROGRAM && t.lexPrograms[code[ip + 1]].scan !== void 0 ? 3 : (op === OP_FIELD ? 1 : 0) | (op === OP_EXPECT || REC && (op === OP_REP || op === OP_REPV) ? 2 : 0)
|
|
7575
7725
|
);
|
|
7576
7726
|
}
|
|
7577
7727
|
const sinkKids = [];
|
|
@@ -7744,6 +7894,12 @@ return 1
|
|
|
7744
7894
|
return `if(${gateMissTest(child)}){${miss}}
|
|
7745
7895
|
`;
|
|
7746
7896
|
}
|
|
7897
|
+
function triviaMiss(ki) {
|
|
7898
|
+
const leads = triviaLeadRanges(ki, t.trivia);
|
|
7899
|
+
if (leads === void 0 || leads.length > 16) return void 0;
|
|
7900
|
+
if (leads.length === 0) return (c) => `${c}<55296`;
|
|
7901
|
+
return (c) => `${c}<55296&&!(${leads.map((r) => r.lo === r.hi ? `${c}===${r.lo}` : `(${c}>=${r.lo}&&${c}<=${r.hi})`).join("||")})`;
|
|
7902
|
+
}
|
|
7747
7903
|
function skipFor(l) {
|
|
7748
7904
|
if (l.tri < 0) return "_skipTrivia";
|
|
7749
7905
|
const ki = l.tri;
|
|
@@ -7754,8 +7910,13 @@ return 1
|
|
|
7754
7910
|
const nm = `_sk${skipPool.size}`;
|
|
7755
7911
|
skipPool.set(key, nm);
|
|
7756
7912
|
if (!hasScan) {
|
|
7757
|
-
|
|
7758
|
-
|
|
7913
|
+
const miss = triviaMiss(ki);
|
|
7914
|
+
const pre = miss === void 0 ? "" : `const c=input.charCodeAt(cur)
|
|
7915
|
+
if(${miss("c")})return cur
|
|
7916
|
+
`;
|
|
7917
|
+
skipDefs.push(l.buf ? `function ${nm}(input,cur,ctx){${pre === "" ? "" : `
|
|
7918
|
+
${pre}`}return skipDeferredTrivia(input,cur,ctx)}` : `function ${nm}(input,cur,ctx){
|
|
7919
|
+
${pre}if(needsDeferredTriviaCommit(ctx))return skipDeferredTrivia(input,cur,ctx)
|
|
7759
7920
|
return advanceTrivia(input,cur,ctx)}`);
|
|
7760
7921
|
return nm;
|
|
7761
7922
|
}
|
|
@@ -7994,7 +8155,7 @@ try{return ${child}(input,pos,ctx)}finally{ctx.state=saved}
|
|
|
7994
8155
|
return `${head}
|
|
7995
8156
|
const v=${child}(input,pos,ctx)
|
|
7996
8157
|
if(v===FAIL)return FAIL
|
|
7997
|
-
return ${fn}(v,
|
|
8158
|
+
return ${fn}(v,new _SP(pos,EC.e))
|
|
7998
8159
|
}`;
|
|
7999
8160
|
}
|
|
8000
8161
|
case OP_LABEL: {
|
|
@@ -8015,7 +8176,7 @@ return v
|
|
|
8015
8176
|
const v=${child}(input,pos,ctx)
|
|
8016
8177
|
if(v===FAIL)return FAIL
|
|
8017
8178
|
const f=ctx._fields
|
|
8018
|
-
if(f!==undefined)f.push({name
|
|
8179
|
+
if(f!==undefined)f.push(new _FC(${name},v,new _SP(pos,EC.e)))
|
|
8019
8180
|
return v
|
|
8020
8181
|
}`;
|
|
8021
8182
|
}
|
|
@@ -8040,7 +8201,7 @@ return v
|
|
|
8040
8201
|
return `${head}
|
|
8041
8202
|
const v=${child}(input,pos,ctx)
|
|
8042
8203
|
if(v!==FAIL)return v
|
|
8043
|
-
const err={_tag:'parseError',span:${prog.lines === 1 ? "spanLines(ctx,pos,pos)" : "
|
|
8204
|
+
const err={_tag:'parseError',span:${prog.lines === 1 ? "spanLines(ctx,pos,pos)" : "new _SP(pos,pos)"},expected:${xf}}
|
|
8044
8205
|
const es=ctx._errors
|
|
8045
8206
|
if(es!==undefined)es.push(err)
|
|
8046
8207
|
${REC ? "if(ctx._tolerant===true)captureError(ctx,err)\n" : ""}ctx._fc=false
|
|
@@ -8051,7 +8212,7 @@ return err
|
|
|
8051
8212
|
case OP_ROUTED: {
|
|
8052
8213
|
const fb = code[ip + 1];
|
|
8053
8214
|
const fallback = fb >= 0 ? link(fb) : void 0;
|
|
8054
|
-
const push = `pushCstLeaf(ctx,
|
|
8215
|
+
const push = `pushCstLeaf(ctx,new _LF(it.value,it.span))`;
|
|
8055
8216
|
return `${head}
|
|
8056
8217
|
const it=ctx._routed
|
|
8057
8218
|
if(it===undefined||pos!==it.span.start){
|
|
@@ -8132,8 +8293,8 @@ ctx._triviaLog=sOtl
|
|
|
8132
8293
|
}
|
|
8133
8294
|
if(v===FAIL)return FAIL
|
|
8134
8295
|
const e=EC.e
|
|
8135
|
-
const out=${isToken ? "input.slice(pos,e)" : `${fn}(v,
|
|
8136
|
-
if(wasCap)pushCstLeaf(ctx,{
|
|
8296
|
+
const out=${isToken ? "input.slice(pos,e)" : `${fn}(v,new _SP(pos,e))`}
|
|
8297
|
+
if(wasCap)pushCstLeaf(ctx,new _LF(${capturesSource ? "input.slice(pos,e)" : "out"},new _SP(pos,e)))
|
|
8137
8298
|
EC.e=e
|
|
8138
8299
|
return out
|
|
8139
8300
|
}`;
|
|
@@ -8157,7 +8318,7 @@ ${hasSuffix && (lineFlags & 2) !== 0 ? "if(sm)_trackLines(ctx,input,e)" : ""}
|
|
|
8157
8318
|
${hasSuffix ? `if(!sm){ctx._fe=e;ctx._fx=${suffixExpected};if(ctx._probe!==undefined)failAt(ctx,${suffixExpected},e)}` : ""}
|
|
8158
8319
|
const v=${pending ? "tp?_pfTokValue:" : ""}input.slice(pos,e)
|
|
8159
8320
|
${pending ? "if(tp){_pfTokBody=-1;_pfTokValue=undefined}" : ""}
|
|
8160
|
-
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,
|
|
8321
|
+
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
8161
8322
|
EC.e=e
|
|
8162
8323
|
return v
|
|
8163
8324
|
}`;
|
|
@@ -8196,7 +8357,7 @@ ctx._rootTriviaLog=sRtl
|
|
|
8196
8357
|
}
|
|
8197
8358
|
if(e<0)return FAIL
|
|
8198
8359
|
const v=input.slice(pos,e)
|
|
8199
|
-
if(wasCap)pushCstLeaf(ctx,
|
|
8360
|
+
if(wasCap)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
8200
8361
|
EC.e=e
|
|
8201
8362
|
return v
|
|
8202
8363
|
}`;
|
|
@@ -8204,7 +8365,7 @@ return v
|
|
|
8204
8365
|
const e=${run}(input,pos,ctx)
|
|
8205
8366
|
if(e<0)return FAIL
|
|
8206
8367
|
const v=input.slice(pos,e)
|
|
8207
|
-
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,
|
|
8368
|
+
if(ctx._cstBuf!==undefined||ctx._cstLeaves!==undefined)pushCstLeaf(ctx,new _LF(v,new _SP(pos,e)))
|
|
8208
8369
|
EC.e=e
|
|
8209
8370
|
return v
|
|
8210
8371
|
}`;
|
|
@@ -8318,7 +8479,7 @@ return v
|
|
|
8318
8479
|
}` : `${parts.join("\n")}
|
|
8319
8480
|
}`;
|
|
8320
8481
|
if (n === 1) {
|
|
8321
|
-
parts.push(fused ? projection === 0 ? "return v0" : `return ${fn}([v0],
|
|
8482
|
+
parts.push(fused ? projection === 0 ? "return v0" : `return ${fn}([v0],new _SP(pos,EC.e))` : wantValues ? "return [v0]" : "return undefined");
|
|
8322
8483
|
return close();
|
|
8323
8484
|
}
|
|
8324
8485
|
parts.push("let cur=EC.e");
|
|
@@ -8339,12 +8500,12 @@ return v
|
|
|
8339
8500
|
);
|
|
8340
8501
|
} else {
|
|
8341
8502
|
const callee = leadingTriviaFieldAt(code, k, childIp) ? `(LEAD.at=cur,${kids[i]})` : kids[i];
|
|
8342
|
-
parts.push(holdsGap(code, k, base, n, i, nullable2) ? emitHoldTerm(callee, vn, tmp(), L, skipFor(L)) : emitTerm(callee, vn, tmp(), L, skipFor(L)));
|
|
8503
|
+
parts.push(holdsGap(code, k, base, n, i, nullable2) ? emitHoldTerm(callee, vn, tmp(), L, skipFor(L)) : emitTerm(callee, vn, tmp(), L, skipFor(L), L.tri >= 0 ? triviaMiss(L.tri) : void 0));
|
|
8343
8504
|
}
|
|
8344
8505
|
names.push(vn);
|
|
8345
8506
|
}
|
|
8346
8507
|
parts.push("EC.e=cur");
|
|
8347
|
-
parts.push(fused ? projection >= 0 ? `return ${names[projection]}` : `return ${fn}([${names.join(",")}],
|
|
8508
|
+
parts.push(fused ? projection >= 0 ? `return ${names[projection]}` : `return ${fn}([${names.join(",")}],new _SP(pos,cur))` : wantValues ? `return [${names.join(",")}]` : "return undefined");
|
|
8348
8509
|
return close();
|
|
8349
8510
|
}
|
|
8350
8511
|
case OP_CHOICE: {
|
|
@@ -8603,7 +8764,7 @@ ${spec.match.map((m, i) => `${i === 0 ? "" : "else "}if(${dispatchClaim(m)})arm=
|
|
|
8603
8764
|
const routedCall = (target) => `{const savedRouted=ctx._routed
|
|
8604
8765
|
${emitRollback(m1, L.buf, L.raw, sinks)}
|
|
8605
8766
|
${emitMark(m2, L.buf, L.raw, sinks, false)}
|
|
8606
|
-
ctx._routed={value:key,span:
|
|
8767
|
+
ctx._routed={value:key,span:new _SP(pos,selEnd)}
|
|
8607
8768
|
try{v=${target}(input,pos,ctx)}finally{ctx._routed=savedRouted}
|
|
8608
8769
|
break}`;
|
|
8609
8770
|
const plainCall = (target) => `v=${target}(input,selEnd,ctx);break`;
|
|
@@ -8798,8 +8959,8 @@ return out
|
|
|
8798
8959
|
const end=${recognize}(input,pos)
|
|
8799
8960
|
if(end<0){ctx._fe=pos;ctx._fx=${xf};return FAIL}
|
|
8800
8961
|
const value=${value2}
|
|
8801
|
-
const leaf=
|
|
8802
|
-
const kids=[leaf],rawKids=[leaf],span=
|
|
8962
|
+
const leaf=new _LF(value,new _SP(pos,end))
|
|
8963
|
+
const kids=[leaf],rawKids=[leaf],span=new _SP(pos,end)
|
|
8803
8964
|
EC.e=end
|
|
8804
8965
|
const nd=${build2}(kids,undefined,span,rawKids,EMPTY_TL,undefined)
|
|
8805
8966
|
${L.buf && L.raw === RAW_OMIT ? "_pushNodeNoRawBuf(ctx,nd)" : L.buf && L.raw === RAW_CAPTURE ? "pushCstChild(ctx,nd,rawEntry(nd,input,pos,end))" : staticBuild ? "if(ctx._cstBuf!==undefined||ctx._cstChildren!==undefined)pushCstChild(ctx,nd,ctx._cstBuf!==undefined&&ctx._cstBuf.noRaw===true?undefined:ctx._cstBuf!==undefined||ctx._cstRawChildren!==undefined?rawEntry(nd,input,pos,end):undefined)" : "if(ctx._cstBuf!==undefined||ctx._cstChildren!==undefined)pushCstChild(ctx,nd,rawEntry(nd,input,pos,end))"}
|
|
@@ -8898,7 +9059,7 @@ ctx._cstTriviaLog=sTl
|
|
|
8898
9059
|
ctx.captureTrivia=sCap
|
|
8899
9060
|
if(v===FAIL)return FAIL
|
|
8900
9061
|
const end=EC.e
|
|
8901
|
-
${collapseChildren ? `const nd=captured.length===1?captured[0]:${build}(captured,undefined,
|
|
9062
|
+
${collapseChildren ? `const nd=captured.length===1?captured[0]:${build}(captured,undefined,new _SP(pos,end),EMPTY_CH,EMPTY_TL,undefined)` : `const nd=${build}(captured,${fields ? "fieldMap" : "undefined"},new _SP(pos,end),EMPTY_CH,EMPTY_TL,undefined)`}
|
|
8902
9063
|
${publish}
|
|
8903
9064
|
EC.e=end
|
|
8904
9065
|
return nd
|
|
@@ -8921,20 +9082,20 @@ return nd
|
|
|
8921
9082
|
const direct = `${build}(kids,fieldMap,span,rawKids,${captureWide ? "tlog" : "EMPTY_TL"},st)`;
|
|
8922
9083
|
value = hostCst ? `nd=_pfHost!==undefined?${hostCall}:${direct}` : `nd=${direct}`;
|
|
8923
9084
|
} else {
|
|
8924
|
-
value = `nd=_pfHost!==undefined?_pfHost(${ty},hostKids,fieldMap,span,rawKids,tlog,st,${tags}):{
|
|
9085
|
+
value = `nd=_pfHost!==undefined?_pfHost(${ty},hostKids,fieldMap,span,rawKids,tlog,st,${tags}):new _ND(${ty},span,st??null,kids===EMPTY_CH?kids:[...kids])`;
|
|
8925
9086
|
}
|
|
8926
9087
|
const collapsible = keepChildren && (hostCst || build === void 0 && proj < 0);
|
|
8927
|
-
const openCapture = omitsRaw ? `const buf=
|
|
9088
|
+
const openCapture = omitsRaw ? `const buf=new _BUF(undefined,true,0)
|
|
8928
9089
|
ctx._cstBuf=buf
|
|
8929
9090
|
ctx._cstChildren=undefined
|
|
8930
9091
|
ctx._cstLeaves=undefined
|
|
8931
9092
|
ctx._cstRawChildren=undefined
|
|
8932
|
-
ctx._cstTriviaLog=undefined` : keepChildren ? `const buf=
|
|
9093
|
+
ctx._cstTriviaLog=undefined` : keepChildren ? `const buf=new _BUF(undefined,undefined,0)
|
|
8933
9094
|
ctx._cstBuf=buf
|
|
8934
9095
|
ctx._cstChildren=undefined
|
|
8935
9096
|
ctx._cstLeaves=undefined
|
|
8936
9097
|
ctx._cstRawChildren=undefined
|
|
8937
|
-
ctx._cstTriviaLog=undefined` : `const buf=
|
|
9098
|
+
ctx._cstTriviaLog=undefined` : `const buf=new _BUF(true,undefined,0)
|
|
8938
9099
|
ctx._cstBuf=buf
|
|
8939
9100
|
ctx._cstChildren=undefined
|
|
8940
9101
|
ctx._cstLeaves=undefined
|
|
@@ -8972,7 +9133,7 @@ ctx._cstTriviaLog=sTl
|
|
|
8972
9133
|
ctx.captureTrivia=sCap
|
|
8973
9134
|
if(v===FAIL)return FAIL
|
|
8974
9135
|
const end=EC.e
|
|
8975
|
-
const span=${tracked ? "spanLines(ctx,pos,end)" : "
|
|
9136
|
+
const span=${tracked ? "spanLines(ctx,pos,end)" : "new _SP(pos,end)"}
|
|
8976
9137
|
const st=${readsState ? "ctx.state" : "undefined"}
|
|
8977
9138
|
let nd
|
|
8978
9139
|
${unwrap ? "if(kids.length===1)nd=unwrapChild(kids[0])\nelse " : ""}${collapse ? "if(kids.length===1)nd=kids[0]\nelse " : ""}${collapsible ? `if(_pfHost!==undefined&&_pfHost._parsemanCstCollapse!==undefined&&kids.length===1&&rawKids.length===1&&_pfHost._parsemanCstCollapse(${ty},kids[0],kids,rawKids))nd=kids[0]
|
|
@@ -9410,7 +9571,7 @@ function assemble(t, prog, cfg) {
|
|
|
9410
9571
|
const NULLABLE = /* @__PURE__ */ new Map();
|
|
9411
9572
|
const CLEAN = REC ? () => false : failCleanAnalysis(code);
|
|
9412
9573
|
function pushLeaf(ctx, value, s, e) {
|
|
9413
|
-
const lf =
|
|
9574
|
+
const lf = new PlainLeaf8(value, new PlainSpan9(s, e));
|
|
9414
9575
|
pushCstLeaf(ctx, lf);
|
|
9415
9576
|
}
|
|
9416
9577
|
function plainBuildNode(child, build, trailing) {
|
|
@@ -9443,7 +9604,7 @@ function assemble(t, prog, cfg) {
|
|
|
9443
9604
|
ctx.captureTrivia = sCap;
|
|
9444
9605
|
if (value === FAIL) return FAIL;
|
|
9445
9606
|
const end = EC.e;
|
|
9446
|
-
const span =
|
|
9607
|
+
const span = new PlainSpan9(pos, end);
|
|
9447
9608
|
const node = build(kids, void 0, span, rawKids, EMPTY_TL, void 0);
|
|
9448
9609
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
9449
9610
|
pushCstChild(ctx, node, rawEntry(node, input, pos, end));
|
|
@@ -9488,7 +9649,7 @@ function assemble(t, prog, cfg) {
|
|
|
9488
9649
|
ctx.captureTrivia = sCap;
|
|
9489
9650
|
if (value === FAIL) return FAIL;
|
|
9490
9651
|
const end = EC.e;
|
|
9491
|
-
const node = build(captured, void 0,
|
|
9652
|
+
const node = build(captured, void 0, new PlainSpan9(pos, end), EMPTY_CH, EMPTY_TL, void 0);
|
|
9492
9653
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
9493
9654
|
pushCstChild(ctx, node, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node, input, pos, end) : void 0);
|
|
9494
9655
|
}
|
|
@@ -9525,7 +9686,7 @@ function assemble(t, prog, cfg) {
|
|
|
9525
9686
|
ctx.captureTrivia = sCap;
|
|
9526
9687
|
if (value === FAIL) return FAIL;
|
|
9527
9688
|
const end = EC.e;
|
|
9528
|
-
const node = build(captured, fieldMap,
|
|
9689
|
+
const node = build(captured, fieldMap, new PlainSpan9(pos, end), EMPTY_CH, EMPTY_TL, void 0);
|
|
9529
9690
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
9530
9691
|
pushCstChild(ctx, node, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node, input, pos, end) : void 0);
|
|
9531
9692
|
}
|
|
@@ -9562,7 +9723,7 @@ function assemble(t, prog, cfg) {
|
|
|
9562
9723
|
ctx.captureTrivia = sCap;
|
|
9563
9724
|
if (value === FAIL) return FAIL;
|
|
9564
9725
|
const end = EC.e;
|
|
9565
|
-
const span =
|
|
9726
|
+
const span = new PlainSpan9(pos, end);
|
|
9566
9727
|
const node = kids.length === 1 ? kids[0] : build(kids, void 0, span, rawKids, EMPTY_TL, void 0);
|
|
9567
9728
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
9568
9729
|
pushCstChild(ctx, node, rawEntry(node, input, pos, end));
|
|
@@ -9599,7 +9760,7 @@ function assemble(t, prog, cfg) {
|
|
|
9599
9760
|
ctx.captureTrivia = sCap;
|
|
9600
9761
|
if (value === FAIL) return FAIL;
|
|
9601
9762
|
const end = EC.e;
|
|
9602
|
-
const node = captured.length === 1 ? captured[0] : build(captured, void 0,
|
|
9763
|
+
const node = captured.length === 1 ? captured[0] : build(captured, void 0, new PlainSpan9(pos, end), EMPTY_CH, EMPTY_TL, void 0);
|
|
9603
9764
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
9604
9765
|
pushCstChild(ctx, node, sBuf !== void 0 || sRaw !== void 0 ? rawEntry(node, input, pos, end) : void 0);
|
|
9605
9766
|
}
|
|
@@ -9708,7 +9869,23 @@ function assemble(t, prog, cfg) {
|
|
|
9708
9869
|
}
|
|
9709
9870
|
return out;
|
|
9710
9871
|
}
|
|
9872
|
+
const LEAD_TABLES = trivia2.map((tp) => tp === void 0 ? null : triviaLeadTable(tp));
|
|
9873
|
+
let LEAD_OF;
|
|
9874
|
+
let LEAD_TABLE = null;
|
|
9875
|
+
function cannotStartTrivia(input, cur, triviaP) {
|
|
9876
|
+
if (triviaP !== LEAD_OF) {
|
|
9877
|
+
LEAD_OF = triviaP;
|
|
9878
|
+
const slot = trivia2.indexOf(triviaP);
|
|
9879
|
+
LEAD_TABLE = slot >= 0 ? LEAD_TABLES[slot] : triviaLeadTable(triviaP);
|
|
9880
|
+
}
|
|
9881
|
+
const table = LEAD_TABLE;
|
|
9882
|
+
if (table === null) return false;
|
|
9883
|
+
const c = input.charCodeAt(cur);
|
|
9884
|
+
return c < 128 && table[c] === 0;
|
|
9885
|
+
}
|
|
9711
9886
|
function skipTrivia(input, cur, ctx) {
|
|
9887
|
+
const t2 = ctx.trivia;
|
|
9888
|
+
if (t2 !== void 0 && cannotStartTrivia(input, cur, t2)) return cur;
|
|
9712
9889
|
const s = SCAN;
|
|
9713
9890
|
if (s !== null && ctx._triviaLog === void 0 && !(ctx.captureTrivia === true && (ctx._cstBuf !== void 0 || ctx._cstTriviaLog !== void 0))) {
|
|
9714
9891
|
return s(input, cur);
|
|
@@ -9723,7 +9900,8 @@ function assemble(t, prog, cfg) {
|
|
|
9723
9900
|
const frames = [];
|
|
9724
9901
|
let depth = 0;
|
|
9725
9902
|
function nextTerm(child, input, cur, ctx) {
|
|
9726
|
-
|
|
9903
|
+
const t2 = ctx.trivia;
|
|
9904
|
+
if (t2 === void 0 || cannotStartTrivia(input, cur, t2)) {
|
|
9727
9905
|
const v2 = child(input, cur, ctx);
|
|
9728
9906
|
if (v2 === FAIL) return -1;
|
|
9729
9907
|
TERMV = v2;
|
|
@@ -9752,7 +9930,8 @@ function assemble(t, prog, cfg) {
|
|
|
9752
9930
|
return cur;
|
|
9753
9931
|
}
|
|
9754
9932
|
function nextTermBuffered(child, input, cur, ctx) {
|
|
9755
|
-
|
|
9933
|
+
const t2 = ctx.trivia;
|
|
9934
|
+
if (t2 === void 0 || cannotStartTrivia(input, cur, t2)) {
|
|
9756
9935
|
const v2 = child(input, cur, ctx);
|
|
9757
9936
|
if (v2 === FAIL) return -1;
|
|
9758
9937
|
TERMV = v2;
|
|
@@ -10014,7 +10193,7 @@ function assemble(t, prog, cfg) {
|
|
|
10014
10193
|
return (input, pos, selEnd, key, ctx, need, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot) => {
|
|
10015
10194
|
const savedRouted = ctx._routed;
|
|
10016
10195
|
if (need) rollbackTriviaAt(ctx, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot);
|
|
10017
|
-
ctx._routed = { value: key, span:
|
|
10196
|
+
ctx._routed = { value: key, span: new PlainSpan9(pos, selEnd) };
|
|
10018
10197
|
let v;
|
|
10019
10198
|
try {
|
|
10020
10199
|
v = child(input, pos, ctx);
|
|
@@ -10447,7 +10626,7 @@ function assemble(t, prog, cfg) {
|
|
|
10447
10626
|
case OP_EXPECT: {
|
|
10448
10627
|
const child = link(code[ip + 1]);
|
|
10449
10628
|
const xf = fx[code[ip + 2]];
|
|
10450
|
-
const expectSpan = (ctx, pos) => prog.lines === 1 ? spanLines(ctx, pos, pos) :
|
|
10629
|
+
const expectSpan = (ctx, pos) => prog.lines === 1 ? spanLines(ctx, pos, pos) : new PlainSpan9(pos, pos);
|
|
10451
10630
|
if (REC) {
|
|
10452
10631
|
return (input, pos, ctx) => {
|
|
10453
10632
|
const v = child(input, pos, ctx);
|
|
@@ -10479,7 +10658,7 @@ function assemble(t, prog, cfg) {
|
|
|
10479
10658
|
return (input, pos, ctx) => {
|
|
10480
10659
|
const v = child(input, pos, ctx);
|
|
10481
10660
|
if (v === FAIL) return FAIL;
|
|
10482
|
-
ctx._fields?.push(
|
|
10661
|
+
ctx._fields?.push(new PlainField(name, v, new PlainSpan9(pos, EC.e)));
|
|
10483
10662
|
return v;
|
|
10484
10663
|
};
|
|
10485
10664
|
}
|
|
@@ -10503,7 +10682,7 @@ function assemble(t, prog, cfg) {
|
|
|
10503
10682
|
return (input, pos, ctx) => {
|
|
10504
10683
|
const v = child(input, pos, ctx);
|
|
10505
10684
|
if (v === FAIL) return FAIL;
|
|
10506
|
-
return fn(v,
|
|
10685
|
+
return fn(v, new PlainSpan9(pos, EC.e));
|
|
10507
10686
|
};
|
|
10508
10687
|
}
|
|
10509
10688
|
case OP_SCAN: {
|
|
@@ -10554,6 +10733,7 @@ function assemble(t, prog, cfg) {
|
|
|
10554
10733
|
const scopeTrivia = ki < 0 ? void 0 : trivia2[ki];
|
|
10555
10734
|
const scopeLabels = scopeTrivia?._meta.triviaKindLabels;
|
|
10556
10735
|
const scanFor = swapLegal && ki >= 0 && !triviaLabelled[ki] ? triviaScan[ki] : null;
|
|
10736
|
+
const scopeLead = ki < 0 ? null : LEAD_TABLES[ki];
|
|
10557
10737
|
const child = link(code[ip + 2]);
|
|
10558
10738
|
const scopePiece = code[ip] === OP_SCOPE_CAP ? (input, pos, ctx) => {
|
|
10559
10739
|
const saved = ctx.trivia;
|
|
@@ -10561,6 +10741,9 @@ function assemble(t, prog, cfg) {
|
|
|
10561
10741
|
const savedScan = SCAN;
|
|
10562
10742
|
const savedCap = ctx.captureTrivia;
|
|
10563
10743
|
SCAN = scanFor;
|
|
10744
|
+
const savedLeadOf = LEAD_OF, savedLead = LEAD_TABLE;
|
|
10745
|
+
LEAD_OF = scopeTrivia;
|
|
10746
|
+
LEAD_TABLE = scopeLead;
|
|
10564
10747
|
ctx.trivia = scopeTrivia;
|
|
10565
10748
|
ctx.triviaKindLabels = scopeLabels;
|
|
10566
10749
|
ctx.captureTrivia = true;
|
|
@@ -10569,18 +10752,25 @@ function assemble(t, prog, cfg) {
|
|
|
10569
10752
|
ctx.trivia = saved;
|
|
10570
10753
|
ctx.triviaKindLabels = savedLabels;
|
|
10571
10754
|
SCAN = savedScan;
|
|
10755
|
+
LEAD_OF = savedLeadOf;
|
|
10756
|
+
LEAD_TABLE = savedLead;
|
|
10572
10757
|
return v;
|
|
10573
10758
|
} : (input, pos, ctx) => {
|
|
10574
10759
|
const saved = ctx.trivia;
|
|
10575
10760
|
const savedLabels = ctx.triviaKindLabels;
|
|
10576
10761
|
const savedScan = SCAN;
|
|
10577
10762
|
SCAN = scanFor;
|
|
10763
|
+
const savedLeadOf = LEAD_OF, savedLead = LEAD_TABLE;
|
|
10764
|
+
LEAD_OF = scopeTrivia;
|
|
10765
|
+
LEAD_TABLE = scopeLead;
|
|
10578
10766
|
ctx.trivia = scopeTrivia;
|
|
10579
10767
|
ctx.triviaKindLabels = scopeLabels;
|
|
10580
10768
|
const v = child(input, pos, ctx);
|
|
10581
10769
|
ctx.trivia = saved;
|
|
10582
10770
|
ctx.triviaKindLabels = savedLabels;
|
|
10583
10771
|
SCAN = savedScan;
|
|
10772
|
+
LEAD_OF = savedLeadOf;
|
|
10773
|
+
LEAD_TABLE = savedLead;
|
|
10584
10774
|
return v;
|
|
10585
10775
|
};
|
|
10586
10776
|
return scopeRootPolicy(scopePiece, code[ip] === OP_SCOPE_PLAIN ? 0 : code[ip + 3]);
|
|
@@ -10596,7 +10786,7 @@ function assemble(t, prog, cfg) {
|
|
|
10596
10786
|
ctx._fx = ROUTED_FX;
|
|
10597
10787
|
return FAIL;
|
|
10598
10788
|
}
|
|
10599
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
10789
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf8(item.value, item.span));
|
|
10600
10790
|
EC.e = item.span.end;
|
|
10601
10791
|
return item.value;
|
|
10602
10792
|
};
|
|
@@ -10782,7 +10972,7 @@ function assemble(t, prog, cfg) {
|
|
|
10782
10972
|
if (v === FAIL) return FAIL;
|
|
10783
10973
|
const end = EC.e;
|
|
10784
10974
|
const value = input.slice(pos, end);
|
|
10785
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
10975
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf8(value, new PlainSpan9(pos, end)));
|
|
10786
10976
|
EC.e = end;
|
|
10787
10977
|
return value;
|
|
10788
10978
|
};
|
|
@@ -10816,7 +11006,7 @@ function assemble(t, prog, cfg) {
|
|
|
10816
11006
|
if (ctx._probe !== void 0) failAt(ctx, suffixExpected, end);
|
|
10817
11007
|
}
|
|
10818
11008
|
const value = input.slice(pos, end);
|
|
10819
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
11009
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf8(value, new PlainSpan9(pos, end)));
|
|
10820
11010
|
EC.e = end;
|
|
10821
11011
|
return value;
|
|
10822
11012
|
};
|
|
@@ -10859,7 +11049,7 @@ function assemble(t, prog, cfg) {
|
|
|
10859
11049
|
}
|
|
10860
11050
|
if (end < 0) return FAIL;
|
|
10861
11051
|
const value = input.slice(pos, end);
|
|
10862
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
11052
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf8(value, new PlainSpan9(pos, end)));
|
|
10863
11053
|
EC.e = end;
|
|
10864
11054
|
return value;
|
|
10865
11055
|
};
|
|
@@ -10868,7 +11058,7 @@ function assemble(t, prog, cfg) {
|
|
|
10868
11058
|
const end = run(input, pos, ctx);
|
|
10869
11059
|
if (end < 0) return FAIL;
|
|
10870
11060
|
const value = input.slice(pos, end);
|
|
10871
|
-
if (cstCaptureActive(ctx)) pushCstLeaf(ctx,
|
|
11061
|
+
if (cstCaptureActive(ctx)) pushCstLeaf(ctx, new PlainLeaf8(value, new PlainSpan9(pos, end)));
|
|
10872
11062
|
EC.e = end;
|
|
10873
11063
|
return value;
|
|
10874
11064
|
};
|
|
@@ -10901,12 +11091,8 @@ function assemble(t, prog, cfg) {
|
|
|
10901
11091
|
}
|
|
10902
11092
|
if (v === FAIL) return FAIL;
|
|
10903
11093
|
const end = EC.e;
|
|
10904
|
-
const out = fn(v,
|
|
10905
|
-
if (wasCapturing) pushCstLeaf(ctx,
|
|
10906
|
-
_tag: "leaf",
|
|
10907
|
-
value: op === OP_SOURCE_LEAF && hostCst ? input.slice(pos, end) : out,
|
|
10908
|
-
span: { start: pos, end }
|
|
10909
|
-
});
|
|
11094
|
+
const out = fn(v, new PlainSpan9(pos, end));
|
|
11095
|
+
if (wasCapturing) pushCstLeaf(ctx, new PlainLeaf8(op === OP_SOURCE_LEAF && hostCst ? input.slice(pos, end) : out, new PlainSpan9(pos, end)));
|
|
10910
11096
|
EC.e = end;
|
|
10911
11097
|
return out;
|
|
10912
11098
|
};
|
|
@@ -11041,7 +11227,7 @@ function assemble(t, prog, cfg) {
|
|
|
11041
11227
|
const cur = runSyncTerms(input, pos, ctx, values);
|
|
11042
11228
|
if (cur < 0) return FAIL;
|
|
11043
11229
|
EC.e = cur;
|
|
11044
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
11230
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan9(pos, cur));
|
|
11045
11231
|
};
|
|
11046
11232
|
}
|
|
11047
11233
|
if (wantValues) {
|
|
@@ -11135,7 +11321,7 @@ function assemble(t, prog, cfg) {
|
|
|
11135
11321
|
const cur = runAdjTerms(input, pos, ctx, values);
|
|
11136
11322
|
if (cur < 0) return FAIL;
|
|
11137
11323
|
EC.e = cur;
|
|
11138
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
11324
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan9(pos, cur));
|
|
11139
11325
|
};
|
|
11140
11326
|
}
|
|
11141
11327
|
if (wantValues) {
|
|
@@ -11160,7 +11346,7 @@ function assemble(t, prog, cfg) {
|
|
|
11160
11346
|
return (input, pos, ctx) => {
|
|
11161
11347
|
const v = k0(input, pos, ctx);
|
|
11162
11348
|
if (v === FAIL) return FAIL;
|
|
11163
|
-
return projection === 0 ? v : fn([v],
|
|
11349
|
+
return projection === 0 ? v : fn([v], new PlainSpan9(pos, EC.e));
|
|
11164
11350
|
};
|
|
11165
11351
|
}
|
|
11166
11352
|
if (wantValues) {
|
|
@@ -11185,7 +11371,7 @@ function assemble(t, prog, cfg) {
|
|
|
11185
11371
|
const cur = step(k1, input, EC.e, ctx);
|
|
11186
11372
|
if (cur < 0) return FAIL;
|
|
11187
11373
|
EC.e = cur;
|
|
11188
|
-
return projection === 0 ? v0 : projection === 1 ? TERMV : fn([v0, TERMV],
|
|
11374
|
+
return projection === 0 ? v0 : projection === 1 ? TERMV : fn([v0, TERMV], new PlainSpan9(pos, cur));
|
|
11189
11375
|
};
|
|
11190
11376
|
}
|
|
11191
11377
|
if (wantValues) {
|
|
@@ -11219,7 +11405,7 @@ function assemble(t, prog, cfg) {
|
|
|
11219
11405
|
cur = step(k2, input, cur, ctx);
|
|
11220
11406
|
if (cur < 0) return FAIL;
|
|
11221
11407
|
EC.e = cur;
|
|
11222
|
-
return projection === 0 ? v0 : projection === 1 ? v1 : projection === 2 ? TERMV : fn([v0, v1, TERMV],
|
|
11408
|
+
return projection === 0 ? v0 : projection === 1 ? v1 : projection === 2 ? TERMV : fn([v0, v1, TERMV], new PlainSpan9(pos, cur));
|
|
11223
11409
|
};
|
|
11224
11410
|
}
|
|
11225
11411
|
if (wantValues) {
|
|
@@ -11316,7 +11502,7 @@ function assemble(t, prog, cfg) {
|
|
|
11316
11502
|
const cur = runDirectTerms(input, pos, ctx, values);
|
|
11317
11503
|
if (cur < 0) return FAIL;
|
|
11318
11504
|
EC.e = cur;
|
|
11319
|
-
return projection >= 0 ? values[projection] : fn(values,
|
|
11505
|
+
return projection >= 0 ? values[projection] : fn(values, new PlainSpan9(pos, cur));
|
|
11320
11506
|
};
|
|
11321
11507
|
}
|
|
11322
11508
|
if (wantValues) {
|
|
@@ -12214,10 +12400,10 @@ function assemble(t, prog, cfg) {
|
|
|
12214
12400
|
return FAIL;
|
|
12215
12401
|
}
|
|
12216
12402
|
const value = regexValue ? input.slice(pos, end) : spec;
|
|
12217
|
-
const leaf2 =
|
|
12403
|
+
const leaf2 = new PlainLeaf8(value, new PlainSpan9(pos, end));
|
|
12218
12404
|
const kids = [leaf2];
|
|
12219
12405
|
const rawKids = [leaf2];
|
|
12220
|
-
const span =
|
|
12406
|
+
const span = new PlainSpan9(pos, end);
|
|
12221
12407
|
EC.e = end;
|
|
12222
12408
|
const nd = build2(kids, void 0, span, rawKids, EMPTY_TL, void 0);
|
|
12223
12409
|
if (ctx._cstBuf !== void 0 || ctx._cstChildren !== void 0) {
|
|
@@ -12299,7 +12485,7 @@ function assemble(t, prog, cfg) {
|
|
|
12299
12485
|
const sCh = ctx._cstChildren;
|
|
12300
12486
|
const sCap = ctx.captureTrivia;
|
|
12301
12487
|
const sBuf = ctx._cstBuf;
|
|
12302
|
-
const buf = rawOnly ?
|
|
12488
|
+
const buf = rawOnly ? new PlainBuf2(true, void 0, 0) : omitsRaw ? new PlainBuf2(void 0, true, 0) : new PlainBuf2(void 0, void 0, 0);
|
|
12303
12489
|
ctx._cstBuf = buf;
|
|
12304
12490
|
ctx.captureTrivia = captureWide;
|
|
12305
12491
|
const savedFields = ctx._fields;
|
|
@@ -12321,7 +12507,7 @@ function assemble(t, prog, cfg) {
|
|
|
12321
12507
|
ctx.captureTrivia = sCap;
|
|
12322
12508
|
if (v === FAIL) return FAIL;
|
|
12323
12509
|
const end = EC.e;
|
|
12324
|
-
const span = tracked ? spanLines(ctx, pos, end) :
|
|
12510
|
+
const span = tracked ? spanLines(ctx, pos, end) : new PlainSpan9(pos, end);
|
|
12325
12511
|
const st = readsState ? ctx.state : void 0;
|
|
12326
12512
|
let nd;
|
|
12327
12513
|
if (unwrap && kids.length === 1) {
|
|
@@ -12345,7 +12531,7 @@ function assemble(t, prog, cfg) {
|
|
|
12345
12531
|
} else if (host !== void 0) {
|
|
12346
12532
|
nd = host(type, hostKids, fieldMap, span, rawKids, tlog, st, tags);
|
|
12347
12533
|
} else {
|
|
12348
|
-
nd =
|
|
12534
|
+
nd = new PlainNode2(type, span, st ?? null, kids === EMPTY_CH ? kids : [...kids]);
|
|
12349
12535
|
}
|
|
12350
12536
|
if (sBuf !== void 0 || sCh !== void 0) {
|
|
12351
12537
|
pushCstChild(ctx, nd, rawEntry(nd, input, pos, end));
|
|
@@ -12371,7 +12557,7 @@ function assemble(t, prog, cfg) {
|
|
|
12371
12557
|
const at = fe === void 0 || fe < 0 ? pos : fe;
|
|
12372
12558
|
return { ok: false, expected: ctx._fx ?? EMPTY_FX2, span: { start: at, end: at } };
|
|
12373
12559
|
}
|
|
12374
|
-
return { ok: true, value: v, span:
|
|
12560
|
+
return { ok: true, value: v, span: new PlainSpan9(pos, EC.e) };
|
|
12375
12561
|
}
|
|
12376
12562
|
};
|
|
12377
12563
|
}
|
|
@@ -12486,7 +12672,12 @@ function assemble(t, prog, cfg) {
|
|
|
12486
12672
|
LEAD,
|
|
12487
12673
|
triviaFieldCapture,
|
|
12488
12674
|
skipDeferredTrivia,
|
|
12489
|
-
collapseEmpty
|
|
12675
|
+
collapseEmpty,
|
|
12676
|
+
PlainSpan9,
|
|
12677
|
+
PlainLeaf8,
|
|
12678
|
+
PlainNode2,
|
|
12679
|
+
PlainField,
|
|
12680
|
+
PlainBuf2
|
|
12490
12681
|
);
|
|
12491
12682
|
emitReached = new Set(pre.reached);
|
|
12492
12683
|
if (emitted.ext !== void 0) HYBRID = emitted;
|
|
@@ -12573,7 +12764,12 @@ function assemble(t, prog, cfg) {
|
|
|
12573
12764
|
LEAD,
|
|
12574
12765
|
triviaFieldCapture,
|
|
12575
12766
|
skipDeferredTrivia,
|
|
12576
|
-
collapseEmpty
|
|
12767
|
+
collapseEmpty,
|
|
12768
|
+
PlainSpan9,
|
|
12769
|
+
PlainLeaf8,
|
|
12770
|
+
PlainNode2,
|
|
12771
|
+
PlainField,
|
|
12772
|
+
PlainBuf2
|
|
12577
12773
|
);
|
|
12578
12774
|
emitReached = em.reached;
|
|
12579
12775
|
} catch (e) {
|
|
@@ -13601,6 +13797,7 @@ import {
|
|
|
13601
13797
|
} from "../compiler/token-capability.js";
|
|
13602
13798
|
|
|
13603
13799
|
// src/combinators/keywords.ts
|
|
13800
|
+
import { PlainLeaf as PlainLeaf9, PlainSpan as PlainSpan10 } from "../cst/plain.js";
|
|
13604
13801
|
function escapeRe(s) {
|
|
13605
13802
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
13606
13803
|
}
|
|
@@ -15365,7 +15562,11 @@ function encodeTableProgram(ruleMap, settings = {}) {
|
|
|
15365
15562
|
return { prog, fnSrcs: enc.fnSrcs };
|
|
15366
15563
|
}
|
|
15367
15564
|
|
|
15565
|
+
// src/version.ts
|
|
15566
|
+
var PARSEMAN_VERSION = "0.59.0";
|
|
15567
|
+
|
|
15368
15568
|
// src/table/emit.ts
|
|
15569
|
+
var FACTORY_ARITY_GUARD = `if(arguments.length<${EMITTED_PARAMS.length})throw new Error(${JSON.stringify(`parseman: this parser was printed by parseman ${PARSEMAN_VERSION}; upgrade the parseman runtime to at least that version`)});`;
|
|
15369
15570
|
function jsString(s) {
|
|
15370
15571
|
return JSON.stringify(s);
|
|
15371
15572
|
}
|
|
@@ -15451,7 +15652,7 @@ function emitAssemblies(prog, cfgs) {
|
|
|
15451
15652
|
throw e;
|
|
15452
15653
|
}
|
|
15453
15654
|
const plan = em.plan;
|
|
15454
|
-
out.push(`{key:${key},factory:function(${EMITTED_PARAMS.join(",")}){${em.source}
|
|
15655
|
+
out.push(`{key:${key},factory:function(${EMITTED_PARAMS.join(",")}){${FACTORY_ARITY_GUARD}${em.source}
|
|
15455
15656
|
},plan:{classes:[${plan.classes.map((r) => `[${r.join(",")}]`).join(",")}],armExpected:[${plan.armExpected.map((r) => `[${r.join(",")}]`).join(",")}],masks:[${plan.masks.join(",")}]},reached:[${[...em.reached].join(",")}]}`);
|
|
15456
15657
|
}
|
|
15457
15658
|
return [`a:[${out.join(",")}],`];
|
|
@@ -17282,8 +17483,8 @@ function compileRuleMap(ruleMap, opts = {}) {
|
|
|
17282
17483
|
const roots = assemblyExtraIps(artifact);
|
|
17283
17484
|
let siteBytes, fixed;
|
|
17284
17485
|
try {
|
|
17285
|
-
siteBytes = emitAssemblySource(table, artifact, cfg, roots, true).siteBytes;
|
|
17286
|
-
fixed = emitAssemblySource(table, artifact, cfg, roots, true, /* @__PURE__ */ new Set()).source.length;
|
|
17486
|
+
siteBytes = emitAssemblySource(table, artifact, cfg, roots, true, void 0, true).siteBytes;
|
|
17487
|
+
fixed = emitAssemblySource(table, artifact, cfg, roots, true, /* @__PURE__ */ new Set(), true).source.length;
|
|
17287
17488
|
} catch (e) {
|
|
17288
17489
|
if (e instanceof Unemittable) return { ...none, refusal: e.construct };
|
|
17289
17490
|
throw e;
|
|
@@ -17299,7 +17500,7 @@ function compileRuleMap(ruleMap, opts = {}) {
|
|
|
17299
17500
|
refusal: `a site within its ${Math.floor(ceiling)} B selection ceiling (the prelude alone is ${fixed} B)`
|
|
17300
17501
|
};
|
|
17301
17502
|
}
|
|
17302
|
-
const bytes = emitAssemblySource(table, artifact, cfg, roots, true, sites).source.length;
|
|
17503
|
+
const bytes = emitAssemblySource(table, artifact, cfg, roots, true, sites, true).source.length;
|
|
17303
17504
|
if (bytes <= ceiling) return { sites, bytes: Math.ceil(bytes * SUPERCOMPILE_GROWTH) };
|
|
17304
17505
|
target *= Math.min(ceiling / bytes, 0.99);
|
|
17305
17506
|
}
|