parseman 0.50.6 → 0.51.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/choice-cost.d.ts.map +1 -1
- package/dist/analysis/commitment.d.ts.map +1 -1
- package/dist/analysis/diagnostics.js +214 -67
- package/dist/analysis/diagnostics.js.map +2 -2
- package/dist/analysis/duplication.d.ts.map +1 -1
- package/dist/analysis/gating.d.ts.map +1 -1
- package/dist/cli/index.js +220 -68
- package/dist/cli/index.js.map +2 -2
- package/dist/combinators/dispatch.d.ts.map +1 -1
- package/dist/combinators/first-set.d.ts +2 -26
- package/dist/combinators/first-set.d.ts.map +1 -1
- package/dist/combinators/scanTo.d.ts +23 -1
- package/dist/combinators/scanTo.d.ts.map +1 -1
- package/dist/compiler/fields.d.ts.map +1 -1
- package/dist/compiler/grammar-coverage-ids.d.ts.map +1 -1
- package/dist/compiler/ir-serialize.d.ts.map +1 -1
- package/dist/compiler/token-capability.js +40 -29
- package/dist/compiler/token-capability.js.map +1 -1
- package/dist/coverage.d.ts.map +1 -1
- package/dist/cst/reflection.d.ts.map +1 -1
- package/dist/index.js +241 -74
- package/dist/index.js.map +2 -2
- package/dist/plugin/index.js +228 -71
- package/dist/plugin/index.js.map +2 -2
- package/dist/spec/index.js +164 -48
- package/dist/spec/index.js.map +2 -2
- package/dist/table/assemble.d.ts.map +1 -1
- package/dist/table/emit.d.ts.map +1 -1
- package/dist/table/encode.d.ts.map +1 -1
- package/dist/table/exec.d.ts.map +1 -1
- package/dist/table/index.js +220 -68
- package/dist/table/index.js.map +2 -2
- package/dist/table/program.d.ts +2 -0
- package/dist/table/program.d.ts.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/analysis/choice-cost.ts +6 -1
- package/src/analysis/commitment.ts +10 -2
- package/src/analysis/duplication.ts +7 -2
- package/src/analysis/gating.ts +6 -1
- package/src/analysis/rebuild.ts +1 -1
- package/src/combinators/dispatch.ts +4 -1
- package/src/combinators/first-set.ts +58 -36
- package/src/combinators/scanTo.ts +163 -9
- package/src/compiler/fields.ts +8 -2
- package/src/compiler/grammar-coverage-ids.ts +6 -1
- package/src/compiler/ir-serialize.ts +7 -2
- package/src/compiler/token-alphabet.ts +1 -1
- package/src/coverage.ts +7 -1
- package/src/cst/reflection.ts +6 -1
- package/src/table/assemble.ts +11 -1
- package/src/table/emit.ts +4 -0
- package/src/table/encode.ts +16 -8
- package/src/table/exec.ts +7 -1
- package/src/table/program.ts +2 -0
- package/src/types.ts +1 -1
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choice-cost.d.ts","sourceRoot":"","sources":["../../src/analysis/choice-cost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+IG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAwC,MAAM,aAAa,CAAA;AACnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAIpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAI3C,gFAAgF;AAChF,MAAM,MAAM,UAAU,GAAG;IACvB,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAA;IACZ,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;qFACqF;AACrF,eAAO,MAAM,aAAa,MAAO,UAAU,KAAG,MACI,CAAA;AAIlD,yDAAyD;AACzD,MAAM,MAAM,gBAAgB;AAC1B;;sFAEsF;AACpF,gBAAgB;AAClB,yEAAyE;GACvE,yBAAyB;AAC3B;;8BAE8B;GAC5B,+BAA+B;AACjC;;gCAEgC;GAC9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,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,IAAI,GAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAa,GAAG,OAAO,CAgCtG;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,IAAI,GAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAa,GAAG,OAAO,CAqC7G;AAED,2FAA2F;AAC3F,wBAAgB,gBAAgB,CAC9B,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EACtB,IAAI,GAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAa,EAC1C,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CA6CT;AAwCD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,GAC7D;IAAE,iBAAiB,EAAE,OAAO,CAAC;IAAC,iBAAiB,EAAE,OAAO,CAAA;CAAE,CAwB5D"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// src/combinators/first-set.ts
|
|
2
|
-
function classifyFinalChoice(arms, resolve) {
|
|
2
|
+
function classifyFinalChoice(arms, resolve, activeTrivia) {
|
|
3
3
|
const firstSets = [];
|
|
4
4
|
const nullable2 = [];
|
|
5
5
|
let exclusive = true;
|
|
6
6
|
for (const arm of arms) {
|
|
7
7
|
const empty2 = matchesEmpty(arm, /* @__PURE__ */ new Set(), resolve);
|
|
8
8
|
nullable2.push(empty2);
|
|
9
|
-
firstSets.push(empty2 ? { kind: "any" } : firstSetOf(arm, /* @__PURE__ */ new Set(), resolve));
|
|
9
|
+
firstSets.push(empty2 ? { kind: "any" } : firstSetOf(arm, /* @__PURE__ */ new Set(), resolve, activeTrivia));
|
|
10
10
|
if (empty2) exclusive = false;
|
|
11
11
|
}
|
|
12
12
|
if (exclusive) {
|
|
@@ -67,7 +67,7 @@ function intersects(a, b) {
|
|
|
67
67
|
return false;
|
|
68
68
|
}
|
|
69
69
|
function fromChar(code) {
|
|
70
|
-
return
|
|
70
|
+
return fromRange(code, code);
|
|
71
71
|
}
|
|
72
72
|
function startsFirstSet(combinator, input, pos) {
|
|
73
73
|
const fs = combinator._meta.firstSet;
|
|
@@ -160,11 +160,10 @@ function matchesEmptyBody(p, seen, resolve) {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
function isZeroWidthAssertion(p) {
|
|
163
|
-
|
|
164
|
-
return tag === "not" || tag === "adjacency";
|
|
163
|
+
return p._tag === "not" || p._tag === "adjacency";
|
|
165
164
|
}
|
|
166
165
|
function isPositiveLookahead(p) {
|
|
167
|
-
return p.
|
|
166
|
+
return p._tag === "peek";
|
|
168
167
|
}
|
|
169
168
|
function narrowBy(acc, constraint) {
|
|
170
169
|
if (constraint.kind === "any") return acc;
|
|
@@ -180,34 +179,42 @@ function narrowBy(acc, constraint) {
|
|
|
180
179
|
return ranges.length === 0 ? { kind: "empty" } : { kind: "ranges", ranges };
|
|
181
180
|
}
|
|
182
181
|
function applyAssertion(fs, assertion) {
|
|
183
|
-
|
|
184
|
-
if (fs.kind === "empty") return assertion;
|
|
185
|
-
return narrowBy(fs, assertion) ?? fs;
|
|
182
|
+
return assertion === null ? fs : fs.kind === "empty" ? assertion : narrowBy(fs, assertion);
|
|
186
183
|
}
|
|
187
|
-
function
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
184
|
+
function sequenceSet(parsers, fs, empties, trivia2) {
|
|
185
|
+
const afterBoundary = (i) => {
|
|
186
|
+
const rest = at(i);
|
|
187
|
+
return trivia2 ? union(rest, fs(trivia2)) : rest;
|
|
188
|
+
};
|
|
189
|
+
const at = (i) => {
|
|
190
|
+
const p = parsers[i];
|
|
191
191
|
if (isPositiveLookahead(p)) {
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
const constraint = fs(p);
|
|
193
|
+
return i + 1 === parsers.length ? constraint : applyAssertion(afterBoundary(i + 1), constraint);
|
|
194
194
|
}
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
if (isZeroWidthAssertion(p)) {
|
|
196
|
+
return i + 1 === parsers.length ? empty() : afterBoundary(i + 1);
|
|
197
|
+
}
|
|
198
|
+
const first = fs(p);
|
|
199
|
+
if (!empties(p) || i + 1 === parsers.length) return first;
|
|
200
|
+
return union(first, afterBoundary(i + 1));
|
|
201
|
+
};
|
|
202
|
+
return at(0);
|
|
203
|
+
}
|
|
204
|
+
function sequenceFirstSet(parsers) {
|
|
205
|
+
return sequenceSet(parsers, (p) => p._meta.firstSet, matchesEmpty);
|
|
199
206
|
}
|
|
200
|
-
function firstSetOf(p, seen = /* @__PURE__ */ new Set(), resolve) {
|
|
207
|
+
function firstSetOf(p, seen = /* @__PURE__ */ new Set(), resolve, activeTrivia) {
|
|
201
208
|
if (seen.has(p)) return any();
|
|
202
209
|
seen.add(p);
|
|
203
210
|
try {
|
|
204
|
-
return firstSetBody(p, seen, resolve);
|
|
211
|
+
return firstSetBody(p, seen, resolve, activeTrivia);
|
|
205
212
|
} finally {
|
|
206
213
|
seen.delete(p);
|
|
207
214
|
}
|
|
208
215
|
}
|
|
209
|
-
function firstSetBody(p, seen, resolve) {
|
|
210
|
-
const fs = (c) => firstSetOf(c, seen, resolve);
|
|
216
|
+
function firstSetBody(p, seen, resolve, activeTrivia) {
|
|
217
|
+
const fs = (c) => firstSetOf(c, seen, resolve, activeTrivia);
|
|
211
218
|
const empties = (c) => matchesEmpty(c, /* @__PURE__ */ new Set(), resolve);
|
|
212
219
|
const d = p._def;
|
|
213
220
|
switch (d.tag) {
|
|
@@ -233,17 +240,7 @@ function firstSetBody(p, seen, resolve) {
|
|
|
233
240
|
return out;
|
|
234
241
|
}
|
|
235
242
|
case "sequence": {
|
|
236
|
-
|
|
237
|
-
let assertion = null;
|
|
238
|
-
for (const term of d.parsers) {
|
|
239
|
-
if (isPositiveLookahead(term)) {
|
|
240
|
-
assertion = narrowBy(assertion, fs(term));
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
if (!isZeroWidthAssertion(term)) out = union(out, fs(term));
|
|
244
|
-
if (!empties(term)) return applyAssertion(out, assertion);
|
|
245
|
-
}
|
|
246
|
-
return applyAssertion(out, assertion);
|
|
243
|
+
return sequenceSet(d.parsers, fs, empties, activeTrivia);
|
|
247
244
|
}
|
|
248
245
|
case "peek": {
|
|
249
246
|
const inner = d.parser;
|
|
@@ -258,12 +255,16 @@ function firstSetBody(p, seen, resolve) {
|
|
|
258
255
|
case "token":
|
|
259
256
|
case "leaf":
|
|
260
257
|
case "node":
|
|
261
|
-
case "grammar":
|
|
262
|
-
case "expect":
|
|
263
|
-
return fs(d.parser);
|
|
264
258
|
case "sepBy":
|
|
259
|
+
case "expect":
|
|
265
260
|
return fs(d.parser);
|
|
266
|
-
|
|
261
|
+
case "grammar":
|
|
262
|
+
return firstSetOf(
|
|
263
|
+
d.parser,
|
|
264
|
+
seen,
|
|
265
|
+
resolve,
|
|
266
|
+
d.clearTrivia ? null : d.triviaParser ?? activeTrivia
|
|
267
|
+
);
|
|
267
268
|
default:
|
|
268
269
|
return p._meta.firstSet;
|
|
269
270
|
}
|
|
@@ -2373,7 +2374,12 @@ function childrenOf(d) {
|
|
|
2373
2374
|
case "recover":
|
|
2374
2375
|
return [d.parser, d.sentinel];
|
|
2375
2376
|
case "scanTo":
|
|
2376
|
-
return [
|
|
2377
|
+
return [
|
|
2378
|
+
d.sentinel,
|
|
2379
|
+
...d.skip,
|
|
2380
|
+
...d.recoverAt === void 0 ? [] : [d.recoverAt],
|
|
2381
|
+
...d.stopAt === void 0 ? [] : [d.stopAt]
|
|
2382
|
+
];
|
|
2377
2383
|
case "grammar":
|
|
2378
2384
|
return d.triviaParser ? [d.parser, d.triviaParser] : [d.parser];
|
|
2379
2385
|
case "routed":
|
|
@@ -3227,7 +3233,7 @@ function hasNodeDef(p, seen = /* @__PURE__ */ new Set()) {
|
|
|
3227
3233
|
case "sepBy":
|
|
3228
3234
|
return hasNodeDef(d.parser, seen) || hasNodeDef(d.separator, seen);
|
|
3229
3235
|
case "scanTo":
|
|
3230
|
-
return hasNodeDef(d.sentinel, seen) || d.skip.some((x) => hasNodeDef(x, seen));
|
|
3236
|
+
return hasNodeDef(d.sentinel, seen) || d.skip.some((x) => hasNodeDef(x, seen)) || d.recoverAt !== void 0 && hasNodeDef(d.recoverAt, seen) || d.stopAt !== void 0 && hasNodeDef(d.stopAt, seen);
|
|
3231
3237
|
case "recover":
|
|
3232
3238
|
return hasNodeDef(d.parser, seen) || hasNodeDef(d.sentinel, seen);
|
|
3233
3239
|
case "expect":
|
|
@@ -3266,7 +3272,7 @@ function mayCommitFailure(p, seen = /* @__PURE__ */ new Set(), resolve) {
|
|
|
3266
3272
|
case "withCtx":
|
|
3267
3273
|
return mayCommitFailure(d.parser, seen, resolve);
|
|
3268
3274
|
case "scanTo":
|
|
3269
|
-
return mayCommitFailure(d.sentinel, seen, resolve) || d.skip.some((x) => mayCommitFailure(x, seen, resolve));
|
|
3275
|
+
return mayCommitFailure(d.sentinel, seen, resolve) || d.skip.some((x) => mayCommitFailure(x, seen, resolve)) || d.recoverAt !== void 0 && mayCommitFailure(d.recoverAt, seen, resolve) || d.stopAt !== void 0 && mayCommitFailure(d.stopAt, seen, resolve);
|
|
3270
3276
|
case "lazy": {
|
|
3271
3277
|
try {
|
|
3272
3278
|
return mayCommitFailure(d.thunk(), seen, resolve);
|
|
@@ -4110,7 +4116,7 @@ function parserHasOwnFields(p, seen = /* @__PURE__ */ new Set()) {
|
|
|
4110
4116
|
case "grammar":
|
|
4111
4117
|
return parserHasOwnFields(d.parser, seen) || (d.triviaParser ? parserHasOwnFields(d.triviaParser, seen) : false);
|
|
4112
4118
|
case "scanTo":
|
|
4113
|
-
return parserHasOwnFields(d.sentinel, seen) || d.skip.some((x) => parserHasOwnFields(x, seen));
|
|
4119
|
+
return parserHasOwnFields(d.sentinel, seen) || d.skip.some((x) => parserHasOwnFields(x, seen)) || d.recoverAt !== void 0 && parserHasOwnFields(d.recoverAt, seen) || d.stopAt !== void 0 && parserHasOwnFields(d.stopAt, seen);
|
|
4114
4120
|
case "recover":
|
|
4115
4121
|
return parserHasOwnFields(d.parser, seen) || parserHasOwnFields(d.sentinel, seen);
|
|
4116
4122
|
case "routed":
|
|
@@ -4164,7 +4170,7 @@ function parserUsesRouted(parser2, seen = /* @__PURE__ */ new Set()) {
|
|
|
4164
4170
|
case "grammar":
|
|
4165
4171
|
return parserUsesRouted(def.parser, seen) || (def.triviaParser ? parserUsesRouted(def.triviaParser, seen) : false);
|
|
4166
4172
|
case "scanTo":
|
|
4167
|
-
return parserUsesRouted(def.sentinel, seen) || def.skip.some((entry) => parserUsesRouted(entry, seen));
|
|
4173
|
+
return parserUsesRouted(def.sentinel, seen) || def.skip.some((entry) => parserUsesRouted(entry, seen)) || def.recoverAt !== void 0 && parserUsesRouted(def.recoverAt, seen) || def.stopAt !== void 0 && parserUsesRouted(def.stopAt, seen);
|
|
4168
4174
|
case "recover":
|
|
4169
4175
|
return parserUsesRouted(def.parser, seen) || parserUsesRouted(def.sentinel, seen);
|
|
4170
4176
|
case "lazy":
|
|
@@ -6495,7 +6501,9 @@ var Encoder = class {
|
|
|
6495
6501
|
followClass(parsers, i) {
|
|
6496
6502
|
let fs = { kind: "empty" };
|
|
6497
6503
|
const rr = this.refResolver();
|
|
6498
|
-
for (let j = i + 1; j < parsers.length; j++)
|
|
6504
|
+
for (let j = i + 1; j < parsers.length; j++) {
|
|
6505
|
+
fs = union(fs, firstSetOf(parsers[j], /* @__PURE__ */ new Set(), rr, this.activeTrivia));
|
|
6506
|
+
}
|
|
6499
6507
|
return this.charClass(fs);
|
|
6500
6508
|
}
|
|
6501
6509
|
constant(v) {
|
|
@@ -6712,7 +6720,7 @@ var Encoder = class {
|
|
|
6712
6720
|
*/
|
|
6713
6721
|
subtree(c) {
|
|
6714
6722
|
const ip = this.node(c).ip;
|
|
6715
|
-
const fs = firstSetOf(c, /* @__PURE__ */ new Set(), this.refResolver());
|
|
6723
|
+
const fs = firstSetOf(c, /* @__PURE__ */ new Set(), this.refResolver(), this.activeTrivia);
|
|
6716
6724
|
return [ip, fs.kind === "empty" ? -2 : this.charClass(fs)];
|
|
6717
6725
|
}
|
|
6718
6726
|
/** Pool one scan spec. One per combinator: `node()` memoizes by identity. */
|
|
@@ -6858,6 +6866,8 @@ var Encoder = class {
|
|
|
6858
6866
|
flags: (d.raw ? 1 : 0) | (d.orEOF ? 2 : 0),
|
|
6859
6867
|
skip: d.skip.map((c) => this.subtree(c)),
|
|
6860
6868
|
sentinel: this.subtree(d.sentinel),
|
|
6869
|
+
...d.recoverAt === void 0 ? {} : { recoverAt: this.subtree(d.recoverAt) },
|
|
6870
|
+
...d.stopAt === void 0 ? {} : { stopAt: this.subtree(d.stopAt) },
|
|
6861
6871
|
sent: sentDef.tag === "literal" ? sentDef.value : null
|
|
6862
6872
|
}));
|
|
6863
6873
|
}
|
|
@@ -6931,12 +6941,12 @@ var Encoder = class {
|
|
|
6931
6941
|
return this.covWrap(gated, armCovIds?.[src], 1);
|
|
6932
6942
|
});
|
|
6933
6943
|
const rr = this.refResolver();
|
|
6934
|
-
const finalChoice = classifyFinalChoice(arms, rr);
|
|
6944
|
+
const finalChoice = classifyFinalChoice(arms, rr, this.activeTrivia);
|
|
6935
6945
|
const transactionalFirst = arms.map((arm, i) => {
|
|
6936
6946
|
if (!finalChoice.nullable[i]) return void 0;
|
|
6937
6947
|
const def = arm._def;
|
|
6938
6948
|
if (def.tag !== "attempt" || matchesEmpty(def.parser, /* @__PURE__ */ new Set(), rr)) return void 0;
|
|
6939
|
-
return firstSetOf(def.parser, /* @__PURE__ */ new Set(), rr);
|
|
6949
|
+
return firstSetOf(def.parser, /* @__PURE__ */ new Set(), rr, this.activeTrivia);
|
|
6940
6950
|
});
|
|
6941
6951
|
const gateFirst = finalChoice.firstSets.map((first, i) => transactionalFirst[i] ?? first);
|
|
6942
6952
|
const classes = gateFirst.map((first, i) => finalChoice.nullable[i] && transactionalFirst[i] === void 0 ? -1 : this.charClass(first));
|
|
@@ -6983,7 +6993,7 @@ var Encoder = class {
|
|
|
6983
6993
|
case "oneOrMore": {
|
|
6984
6994
|
const child = this.node(d.parser).ip;
|
|
6985
6995
|
const rr = this.refResolver();
|
|
6986
|
-
const itemClass = matchesEmpty(d.parser, /* @__PURE__ */ new Set(), rr) ? -1 : this.existingCharClass(firstSetOf(d.parser, /* @__PURE__ */ new Set(), rr));
|
|
6996
|
+
const itemClass = matchesEmpty(d.parser, /* @__PURE__ */ new Set(), rr) ? -1 : this.existingCharClass(firstSetOf(d.parser, /* @__PURE__ */ new Set(), rr, this.activeTrivia));
|
|
6987
6997
|
const op = d.valueUnused ? OP_REPV : OP_REP;
|
|
6988
6998
|
const min = d.tag === "many" ? 0 : d.min;
|
|
6989
6999
|
return this.rec ? this.emit(op, child, min, d.max ?? -1, -1, 0, this.expected(deriveExpected(d.parser)), itemClass) : this.emit(op, child, min, d.max ?? -1, -1, 0);
|
|
@@ -7001,7 +7011,7 @@ var Encoder = class {
|
|
|
7001
7011
|
sep,
|
|
7002
7012
|
flags,
|
|
7003
7013
|
this.expected(deriveExpected(d.parser)),
|
|
7004
|
-
this.charClass(firstSetOf(d.separator, /* @__PURE__ */ new Set(), this.refResolver()))
|
|
7014
|
+
this.charClass(firstSetOf(d.separator, /* @__PURE__ */ new Set(), this.refResolver(), this.activeTrivia))
|
|
7005
7015
|
);
|
|
7006
7016
|
}
|
|
7007
7017
|
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);
|
|
@@ -7056,7 +7066,7 @@ var Encoder = class {
|
|
|
7056
7066
|
d.tags === void 0 ? -1 : this.constant(d.tags)
|
|
7057
7067
|
);
|
|
7058
7068
|
if (matchesEmpty(d.parser)) return body;
|
|
7059
|
-
const fs = d.parser._def.tag === "lazy" ? firstSetOf(d.parser, /* @__PURE__ */ new Set(), this.refResolver()) : d.parser._meta.firstSet;
|
|
7069
|
+
const fs = d.parser._def.tag === "lazy" ? firstSetOf(d.parser, /* @__PURE__ */ new Set(), this.refResolver(), this.activeTrivia) : d.parser._meta.firstSet;
|
|
7060
7070
|
if (fs.kind === "any") return body;
|
|
7061
7071
|
const cls = this.charClass(fs);
|
|
7062
7072
|
if (cls < 0) return body;
|
|
@@ -7170,7 +7180,7 @@ var Encoder = class {
|
|
|
7170
7180
|
case "attempt": {
|
|
7171
7181
|
const inner = this.emit(OP_ATTEMPT, this.node(d.parser).ip);
|
|
7172
7182
|
if (!this.failureNeedsRollback(d.parser, void 0)) this.failureRollbackCleanSites.add(inner);
|
|
7173
|
-
const fs = d.parser._def.tag === "lazy" ? firstSetOf(d.parser, /* @__PURE__ */ new Set(), this.refResolver()) : d.parser._meta.firstSet;
|
|
7183
|
+
const fs = d.parser._def.tag === "lazy" ? firstSetOf(d.parser, /* @__PURE__ */ new Set(), this.refResolver(), this.activeTrivia) : d.parser._meta.firstSet;
|
|
7174
7184
|
if (fs.kind === "any" || matchesEmpty(d.parser)) return inner;
|
|
7175
7185
|
const cls = this.charClass(fs);
|
|
7176
7186
|
if (cls < 0) return inner;
|
|
@@ -7291,6 +7301,8 @@ var Encoder = class {
|
|
|
7291
7301
|
const refs = [];
|
|
7292
7302
|
for (const s of this.scans) {
|
|
7293
7303
|
if (s.sentinel !== void 0) refs.push(s.sentinel);
|
|
7304
|
+
if (s.recoverAt !== void 0) refs.push(s.recoverAt);
|
|
7305
|
+
if (s.stopAt !== void 0) refs.push(s.stopAt);
|
|
7294
7306
|
refs.push(...s.skip);
|
|
7295
7307
|
}
|
|
7296
7308
|
for (const set of this.scanSkipSets) refs.push(...set);
|
|
@@ -7310,7 +7322,9 @@ var Encoder = class {
|
|
|
7310
7322
|
this.scans = this.scans.map((s) => ({
|
|
7311
7323
|
...s,
|
|
7312
7324
|
skip: s.skip.map(res),
|
|
7313
|
-
...s.sentinel === void 0 ? {} : { sentinel: res(s.sentinel) }
|
|
7325
|
+
...s.sentinel === void 0 ? {} : { sentinel: res(s.sentinel) },
|
|
7326
|
+
...s.recoverAt === void 0 ? {} : { recoverAt: res(s.recoverAt) },
|
|
7327
|
+
...s.stopAt === void 0 ? {} : { stopAt: res(s.stopAt) }
|
|
7314
7328
|
}));
|
|
7315
7329
|
this.scanSkipSets = this.scanSkipSets.map((set) => set.map(res));
|
|
7316
7330
|
}
|
|
@@ -10929,7 +10943,7 @@ function resolveScanSkip(explicitSkip, raw, ctx) {
|
|
|
10929
10943
|
out.push(...explicitSkip);
|
|
10930
10944
|
return out;
|
|
10931
10945
|
}
|
|
10932
|
-
function scanTo(sentinel, { skip, raw = false, orEOF = false } = {}) {
|
|
10946
|
+
function scanTo(sentinel, { skip, raw = false, orEOF = false, recoverAt, stopAt } = {}) {
|
|
10933
10947
|
const meta = {
|
|
10934
10948
|
firstSet: any(),
|
|
10935
10949
|
canMatchNewline: true,
|
|
@@ -10939,7 +10953,15 @@ function scanTo(sentinel, { skip, raw = false, orEOF = false } = {}) {
|
|
|
10939
10953
|
return {
|
|
10940
10954
|
_tag: "scanTo",
|
|
10941
10955
|
_meta: meta,
|
|
10942
|
-
_def: {
|
|
10956
|
+
_def: {
|
|
10957
|
+
tag: "scanTo",
|
|
10958
|
+
sentinel,
|
|
10959
|
+
skip: explicitSkip,
|
|
10960
|
+
raw,
|
|
10961
|
+
orEOF,
|
|
10962
|
+
...recoverAt === void 0 ? {} : { recoverAt },
|
|
10963
|
+
...stopAt === void 0 ? {} : { stopAt }
|
|
10964
|
+
},
|
|
10943
10965
|
parse(input, pos, ctx) {
|
|
10944
10966
|
let cur = pos;
|
|
10945
10967
|
const skip2 = resolveScanSkip(explicitSkip, raw, ctx);
|
|
@@ -10951,28 +10973,130 @@ function scanTo(sentinel, { skip, raw = false, orEOF = false } = {}) {
|
|
|
10951
10973
|
pushCstLeaf(ctx, leaf2);
|
|
10952
10974
|
}
|
|
10953
10975
|
};
|
|
10954
|
-
|
|
10955
|
-
|
|
10956
|
-
|
|
10976
|
+
if (recoverAt === void 0 && stopAt === void 0) {
|
|
10977
|
+
while (cur < input.length) {
|
|
10978
|
+
const s = sentinel.parse(input, cur, probeCtx);
|
|
10979
|
+
if (s.ok) {
|
|
10980
|
+
if (ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, cur);
|
|
10981
|
+
emit(cur);
|
|
10982
|
+
return { ok: true, value: input.slice(pos, cur), span: { start: pos, end: cur } };
|
|
10983
|
+
}
|
|
10984
|
+
let advanced = false;
|
|
10985
|
+
for (const skipper of skip2) {
|
|
10986
|
+
const r = skipper.parse(input, cur, probeCtx);
|
|
10987
|
+
if (r.ok && r.span.end > cur) {
|
|
10988
|
+
cur = r.span.end;
|
|
10989
|
+
advanced = true;
|
|
10990
|
+
break;
|
|
10991
|
+
}
|
|
10992
|
+
}
|
|
10993
|
+
if (!advanced) cur++;
|
|
10994
|
+
}
|
|
10995
|
+
if (orEOF) {
|
|
10957
10996
|
if (ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, cur);
|
|
10958
10997
|
emit(cur);
|
|
10959
10998
|
return { ok: true, value: input.slice(pos, cur), span: { start: pos, end: cur } };
|
|
10960
10999
|
}
|
|
11000
|
+
const sentDef2 = sentinel._def;
|
|
11001
|
+
const expected2 = sentDef2.tag === "literal" ? [JSON.stringify(sentDef2.value)] : ["sentinel"];
|
|
11002
|
+
return { ok: false, expected: expected2, span: { start: pos, end: cur } };
|
|
11003
|
+
}
|
|
11004
|
+
let recovery = -1;
|
|
11005
|
+
let firstSentinel = -1;
|
|
11006
|
+
let sentinelCount = 0;
|
|
11007
|
+
let recoveryErrorCount = -1;
|
|
11008
|
+
let sentinelErrorCount = -1;
|
|
11009
|
+
const succeed = (end) => {
|
|
11010
|
+
if (ctx.trackLines) recordLineRangeFromContext(ctx, input, pos, end);
|
|
11011
|
+
emit(end);
|
|
11012
|
+
return { ok: true, value: input.slice(pos, end), span: { start: pos, end } };
|
|
11013
|
+
};
|
|
11014
|
+
const recoveredEnd = () => {
|
|
11015
|
+
const acceptSentinel = firstSentinel >= 0 && (sentinelCount & 1) === 1;
|
|
11016
|
+
const errors = ctx._errors;
|
|
11017
|
+
if (errors !== void 0) {
|
|
11018
|
+
const keep = acceptSentinel ? sentinelErrorCount : recoveryErrorCount;
|
|
11019
|
+
if (keep >= 0 && errors.length > keep) errors.length = keep;
|
|
11020
|
+
}
|
|
11021
|
+
return acceptSentinel ? firstSentinel : recovery;
|
|
11022
|
+
};
|
|
11023
|
+
while (cur < input.length) {
|
|
11024
|
+
const sentinelProbeErrorCount = ctx._errors?.length ?? -1;
|
|
11025
|
+
const s = sentinel.parse(input, cur, probeCtx);
|
|
11026
|
+
const sentinelProbeErrors = ctx._errors;
|
|
11027
|
+
if (sentinelProbeErrors !== void 0 && sentinelProbeErrorCount >= 0 && sentinelProbeErrors.length > sentinelProbeErrorCount) {
|
|
11028
|
+
sentinelProbeErrors.length = sentinelProbeErrorCount;
|
|
11029
|
+
}
|
|
11030
|
+
if (s.ok) {
|
|
11031
|
+
if (recovery < 0) return succeed(cur);
|
|
11032
|
+
if (s.span.end <= cur) {
|
|
11033
|
+
throw new TypeError("scanTo recovery requires a sentinel that consumes input");
|
|
11034
|
+
}
|
|
11035
|
+
if (firstSentinel < 0) {
|
|
11036
|
+
firstSentinel = cur;
|
|
11037
|
+
sentinelErrorCount = sentinelProbeErrorCount;
|
|
11038
|
+
}
|
|
11039
|
+
sentinelCount++;
|
|
11040
|
+
cur = s.span.end;
|
|
11041
|
+
continue;
|
|
11042
|
+
}
|
|
11043
|
+
if (stopAt !== void 0) {
|
|
11044
|
+
const errorCount = ctx._errors?.length ?? -1;
|
|
11045
|
+
const stop = stopAt.parse(input, cur, probeCtx);
|
|
11046
|
+
const errors = ctx._errors;
|
|
11047
|
+
if (errors !== void 0 && errorCount >= 0 && errors.length > errorCount) {
|
|
11048
|
+
errors.length = errorCount;
|
|
11049
|
+
}
|
|
11050
|
+
if (stop.ok) {
|
|
11051
|
+
if (recovery < 0) {
|
|
11052
|
+
recovery = cur;
|
|
11053
|
+
recoveryErrorCount = errorCount;
|
|
11054
|
+
}
|
|
11055
|
+
return succeed(recoveredEnd());
|
|
11056
|
+
}
|
|
11057
|
+
}
|
|
10961
11058
|
let advanced = false;
|
|
10962
11059
|
for (const skipper of skip2) {
|
|
11060
|
+
const errorCount = ctx._errors?.length ?? -1;
|
|
10963
11061
|
const r = skipper.parse(input, cur, probeCtx);
|
|
10964
11062
|
if (r.ok && r.span.end > cur) {
|
|
10965
11063
|
cur = r.span.end;
|
|
10966
11064
|
advanced = true;
|
|
10967
11065
|
break;
|
|
10968
11066
|
}
|
|
11067
|
+
const errors = ctx._errors;
|
|
11068
|
+
if (errors !== void 0 && errorCount >= 0 && errors.length > errorCount) {
|
|
11069
|
+
errors.length = errorCount;
|
|
11070
|
+
}
|
|
10969
11071
|
}
|
|
10970
|
-
if (
|
|
11072
|
+
if (advanced) continue;
|
|
11073
|
+
if (recoverAt !== void 0) {
|
|
11074
|
+
const errorCount = ctx._errors?.length ?? -1;
|
|
11075
|
+
const recover = recoverAt.parse(input, cur, probeCtx);
|
|
11076
|
+
const errors = ctx._errors;
|
|
11077
|
+
if (errors !== void 0 && errorCount >= 0 && errors.length > errorCount) {
|
|
11078
|
+
errors.length = errorCount;
|
|
11079
|
+
}
|
|
11080
|
+
if (recover.ok) {
|
|
11081
|
+
if (recover.span.end <= cur) {
|
|
11082
|
+
throw new TypeError("scanTo recoverAt must consume input");
|
|
11083
|
+
}
|
|
11084
|
+
if (recovery < 0) {
|
|
11085
|
+
recovery = cur;
|
|
11086
|
+
recoveryErrorCount = errorCount;
|
|
11087
|
+
}
|
|
11088
|
+
if (firstSentinel >= 0 && (sentinelCount & 1) === 1) {
|
|
11089
|
+
return succeed(recoveredEnd());
|
|
11090
|
+
}
|
|
11091
|
+
cur = recover.span.end;
|
|
11092
|
+
continue;
|
|
11093
|
+
}
|
|
11094
|
+
}
|
|
11095
|
+
cur++;
|
|
10971
11096
|
}
|
|
11097
|
+
if (recovery >= 0) return succeed(recoveredEnd());
|
|
10972
11098
|
if (orEOF) {
|
|
10973
|
-
|
|
10974
|
-
emit(cur);
|
|
10975
|
-
return { ok: true, value: input.slice(pos, cur), span: { start: pos, end: cur } };
|
|
11099
|
+
return succeed(cur);
|
|
10976
11100
|
}
|
|
10977
11101
|
const sentDef = sentinel._def;
|
|
10978
11102
|
const expected = sentDef.tag === "literal" ? [JSON.stringify(sentDef.value)] : ["sentinel"];
|
|
@@ -11260,6 +11384,8 @@ function assemble(t2, prog, cfg) {
|
|
|
11260
11384
|
for (const s of prog.scans ?? []) {
|
|
11261
11385
|
for (const r of s.skip) labelExtraIps.push(r[0]);
|
|
11262
11386
|
if (s.sentinel !== void 0) labelExtraIps.push(s.sentinel[0]);
|
|
11387
|
+
if (s.recoverAt !== void 0) labelExtraIps.push(s.recoverAt[0]);
|
|
11388
|
+
if (s.stopAt !== void 0) labelExtraIps.push(s.stopAt[0]);
|
|
11263
11389
|
}
|
|
11264
11390
|
for (const set of prog.scanSkip ?? []) for (const r of set) labelExtraIps.push(r[0]);
|
|
11265
11391
|
const closureLabels = computeSiteLabels(
|
|
@@ -13945,6 +14071,8 @@ function assemble(t2, prog, cfg) {
|
|
|
13945
14071
|
for (const s of prog.scans ?? []) {
|
|
13946
14072
|
for (const r of s.skip) extraIps.push(r[0]);
|
|
13947
14073
|
if (s.sentinel !== void 0) extraIps.push(s.sentinel[0]);
|
|
14074
|
+
if (s.recoverAt !== void 0) extraIps.push(s.recoverAt[0]);
|
|
14075
|
+
if (s.stopAt !== void 0) extraIps.push(s.stopAt[0]);
|
|
13948
14076
|
}
|
|
13949
14077
|
for (const set of prog.scanSkip ?? []) for (const r of set) extraIps.push(r[0]);
|
|
13950
14078
|
const roots = [...Object.values(prog.rules), ...extraIps];
|
|
@@ -14156,7 +14284,13 @@ function assemble(t2, prog, cfg) {
|
|
|
14156
14284
|
continue;
|
|
14157
14285
|
}
|
|
14158
14286
|
const sentDef = typeof s.sent === "string" ? { tag: "literal", value: s.sent, caseInsensitive: false } : void 0;
|
|
14159
|
-
scansArr.push(scanTo(subtreeComb(s.sentinel, sentDef), {
|
|
14287
|
+
scansArr.push(scanTo(subtreeComb(s.sentinel, sentDef), {
|
|
14288
|
+
skip,
|
|
14289
|
+
raw,
|
|
14290
|
+
orEOF: (s.flags & 2) !== 0,
|
|
14291
|
+
...s.recoverAt === void 0 ? {} : { recoverAt: subtreeComb(s.recoverAt) },
|
|
14292
|
+
...s.stopAt === void 0 ? {} : { stopAt: subtreeComb(s.stopAt) }
|
|
14293
|
+
}));
|
|
14160
14294
|
}
|
|
14161
14295
|
const scans = scansArr;
|
|
14162
14296
|
const scanSkip = (prog.scanSkip ?? []).map((set) => set.map((r) => subtreeComb(r)));
|
|
@@ -14373,6 +14507,8 @@ function emitRef(r) {
|
|
|
14373
14507
|
function emitScanSpec(s) {
|
|
14374
14508
|
const parts = [`kind:${s.kind}`, `flags:${s.flags}`, `skip:[${s.skip.map(emitRef).join(",")}]`];
|
|
14375
14509
|
if (s.sentinel !== void 0) parts.push(`sentinel:${emitRef(s.sentinel)}`);
|
|
14510
|
+
if (s.recoverAt !== void 0) parts.push(`recoverAt:${emitRef(s.recoverAt)}`);
|
|
14511
|
+
if (s.stopAt !== void 0) parts.push(`stopAt:${emitRef(s.stopAt)}`);
|
|
14376
14512
|
if (s.sent !== void 0) parts.push(`sent:${s.sent === null ? "null" : jsString(s.sent)}`);
|
|
14377
14513
|
if (s.open !== void 0) parts.push(`open:${jsString(s.open)}`);
|
|
14378
14514
|
if (s.close !== void 0) parts.push(`close:${jsString(s.close)}`);
|
|
@@ -14388,6 +14524,8 @@ function emitAssemblies(prog, cfgs) {
|
|
|
14388
14524
|
for (const s of prog.scans ?? []) {
|
|
14389
14525
|
for (const r of s.skip) extraIps.push(r[0]);
|
|
14390
14526
|
if (s.sentinel !== void 0) extraIps.push(s.sentinel[0]);
|
|
14527
|
+
if (s.recoverAt !== void 0) extraIps.push(s.recoverAt[0]);
|
|
14528
|
+
if (s.stopAt !== void 0) extraIps.push(s.stopAt[0]);
|
|
14391
14529
|
}
|
|
14392
14530
|
for (const set of prog.scanSkip ?? []) for (const r of set) extraIps.push(r[0]);
|
|
14393
14531
|
const out = [];
|
|
@@ -14530,7 +14668,12 @@ function children(def, winners) {
|
|
|
14530
14668
|
case "sepBy":
|
|
14531
14669
|
return [def.parser, def.separator];
|
|
14532
14670
|
case "scanTo":
|
|
14533
|
-
return [
|
|
14671
|
+
return [
|
|
14672
|
+
def.sentinel,
|
|
14673
|
+
...def.skip,
|
|
14674
|
+
...def.recoverAt === void 0 ? [] : [def.recoverAt],
|
|
14675
|
+
...def.stopAt === void 0 ? [] : [def.stopAt]
|
|
14676
|
+
];
|
|
14534
14677
|
case "lazy": {
|
|
14535
14678
|
let resolved;
|
|
14536
14679
|
try {
|
|
@@ -14643,7 +14786,7 @@ function payloadKey(p, d) {
|
|
|
14643
14786
|
case "expect":
|
|
14644
14787
|
return `expect\0${d.label ?? ""}\0${d.expected.join("")}`;
|
|
14645
14788
|
case "scanTo":
|
|
14646
|
-
return `scanTo\0${d.raw}\0${d.orEOF}`;
|
|
14789
|
+
return `scanTo\0${d.raw}\0${d.orEOF}\0${d.recoverAt !== void 0}\0${d.stopAt !== void 0}`;
|
|
14647
14790
|
case "guard":
|
|
14648
14791
|
return `guard\0${fnKey(d.predSrc, d.predicate)}`;
|
|
14649
14792
|
case "adjacency":
|
|
@@ -14758,8 +14901,12 @@ function segment(d, index) {
|
|
|
14758
14901
|
return index === 0 ? "sepBy.item" : "sepBy.sep";
|
|
14759
14902
|
case "recover":
|
|
14760
14903
|
return index === 0 ? "recover.body" : "recover.sentinel";
|
|
14761
|
-
case "scanTo":
|
|
14762
|
-
|
|
14904
|
+
case "scanTo": {
|
|
14905
|
+
if (index === 0) return "scanTo.sentinel";
|
|
14906
|
+
if (index <= d.skip.length) return `scanTo.skip[${index - 1}]`;
|
|
14907
|
+
if (d.recoverAt !== void 0 && index === d.skip.length + 1) return "scanTo.recoverAt";
|
|
14908
|
+
return "scanTo.stopAt";
|
|
14909
|
+
}
|
|
14763
14910
|
default:
|
|
14764
14911
|
return d.tag;
|
|
14765
14912
|
}
|
|
@@ -16287,7 +16434,7 @@ function subtreeContains(p, targets) {
|
|
|
16287
16434
|
const kids = [];
|
|
16288
16435
|
if (Array.isArray(rec.parsers)) kids.push(...rec.parsers);
|
|
16289
16436
|
if (Array.isArray(rec.skip)) kids.push(...rec.skip);
|
|
16290
|
-
for (const k of ["parser", "main", "skipped", "separator", "sentinel", "selector", "otherwise", "fallback", "triviaParser"])
|
|
16437
|
+
for (const k of ["parser", "main", "skipped", "separator", "sentinel", "recoverAt", "stopAt", "selector", "otherwise", "fallback", "triviaParser"])
|
|
16291
16438
|
if (rec[k]) kids.push(rec[k]);
|
|
16292
16439
|
if (d.tag === "dispatch") {
|
|
16293
16440
|
for (const c2 of d.cases) kids.push(c2.parser);
|