parseman 0.51.2 → 0.52.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/commitment.d.ts.map +1 -1
- package/dist/analysis/diagnostics.js +53 -20
- package/dist/analysis/diagnostics.js.map +1 -1
- package/dist/cli/index.js +53 -20
- package/dist/cli/index.js.map +1 -1
- package/dist/combinators/attempt.d.ts +11 -1
- package/dist/combinators/attempt.d.ts.map +1 -1
- package/dist/combinators/map.d.ts.map +1 -1
- package/dist/combinators/node.d.ts +6 -2
- package/dist/combinators/node.d.ts.map +1 -1
- package/dist/compiler/token-capability.js +4 -0
- package/dist/compiler/token-capability.js.map +1 -1
- package/dist/cst/trivia-kinds.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -22
- package/dist/index.js.map +1 -1
- package/dist/plugin/index.js +55 -22
- package/dist/plugin/index.js.map +1 -1
- package/dist/spec/index.js +28 -5
- package/dist/spec/index.js.map +1 -1
- package/dist/table/assemble.d.ts.map +1 -1
- package/dist/table/emit-assembly.d.ts.map +1 -1
- package/dist/table/encode-baseline.d.ts.map +1 -1
- package/dist/table/exec.d.ts.map +1 -1
- package/dist/table/index.js +37 -15
- package/dist/table/index.js.map +1 -1
- package/dist/table/ops.d.ts +7 -5
- package/dist/table/ops.d.ts.map +1 -1
- package/dist/table/site-labels.d.ts.map +1 -1
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/analysis/commitment.ts +3 -1
- package/src/analysis/rebuild.ts +1 -1
- package/src/combinators/attempt.ts +26 -3
- package/src/combinators/first-set.ts +5 -1
- package/src/combinators/map.ts +5 -1
- package/src/combinators/node.ts +12 -3
- package/src/compiler/ir-serialize.ts +1 -1
- package/src/coverage.ts +1 -1
- package/src/cst/trivia-kinds.ts +6 -0
- package/src/index.ts +1 -0
- package/src/plugin/evaluator.ts +1 -1
- package/src/table/assemble.ts +22 -8
- package/src/table/emit-assembly.ts +8 -3
- package/src/table/encode-baseline.ts +5 -1
- package/src/table/encode.ts +13 -13
- package/src/table/exec.ts +6 -2
- package/src/table/ops.ts +7 -5
- package/src/table/site-labels.ts +3 -1
- package/src/types.ts +8 -1
- package/src/version.ts +1 -1
package/dist/spec/index.js
CHANGED
|
@@ -221,6 +221,10 @@ function firstSetBody(p, seen, resolve, activeTrivia) {
|
|
|
221
221
|
case "node":
|
|
222
222
|
case "sepBy":
|
|
223
223
|
case "expect":
|
|
224
|
+
// A transaction accepts exactly what its inner accepts. Its own `_meta` is
|
|
225
|
+
// the inner's construction-time set, which reads `any` when the inner opens
|
|
226
|
+
// with a rule reference — resolve through it like any other wrapper.
|
|
227
|
+
case "attempt":
|
|
224
228
|
return fs(d.parser);
|
|
225
229
|
case "grammar":
|
|
226
230
|
return firstSetOf(
|
|
@@ -1360,6 +1364,10 @@ function peelLabel(p) {
|
|
|
1360
1364
|
return null;
|
|
1361
1365
|
}
|
|
1362
1366
|
function analyzeLabeledTrivia(trivia2) {
|
|
1367
|
+
if (trivia2._def.tag === "trivia") {
|
|
1368
|
+
const own = trivia2._meta.labeledTriviaSpec;
|
|
1369
|
+
if (own !== void 0) return own;
|
|
1370
|
+
}
|
|
1363
1371
|
if (trivia2 === labeledTrivia0) return labeledSpec0;
|
|
1364
1372
|
if (trivia2 === labeledTrivia1) return labeledSpec1;
|
|
1365
1373
|
if (trivia2 === labeledTrivia2) return labeledSpec2;
|
|
@@ -3980,13 +3988,24 @@ function dispatch(selector, ...arms) {
|
|
|
3980
3988
|
}
|
|
3981
3989
|
|
|
3982
3990
|
// src/combinators/attempt.ts
|
|
3983
|
-
function
|
|
3991
|
+
function containOption(options) {
|
|
3992
|
+
if (options === void 0) return false;
|
|
3993
|
+
for (const key of Object.keys(options)) {
|
|
3994
|
+
if (key !== "contain") throw new TypeError(`attempt(): unknown option ${JSON.stringify(key)}`);
|
|
3995
|
+
}
|
|
3996
|
+
if (options.contain !== void 0 && typeof options.contain !== "boolean") {
|
|
3997
|
+
throw new TypeError("attempt(): `contain` must be a boolean");
|
|
3998
|
+
}
|
|
3999
|
+
return options.contain === true;
|
|
4000
|
+
}
|
|
4001
|
+
function attempt(parser2, options) {
|
|
4002
|
+
const contain = containOption(options);
|
|
3984
4003
|
const guardable = parser2._meta.firstSet.kind !== "any" && !matchesEmpty(parser2);
|
|
3985
4004
|
let failExpected;
|
|
3986
4005
|
return {
|
|
3987
4006
|
_tag: "attempt",
|
|
3988
4007
|
_meta: parser2._meta,
|
|
3989
|
-
_def: { tag: "attempt", parser: parser2 },
|
|
4008
|
+
_def: contain ? { tag: "attempt", parser: parser2, contain: true } : { tag: "attempt", parser: parser2 },
|
|
3990
4009
|
parse(input, pos, ctx) {
|
|
3991
4010
|
if (guardable && ctx._probe === void 0 && !ctx._tolerant && !startsFirstSet(parser2, input, pos)) {
|
|
3992
4011
|
if (failExpected === void 0) {
|
|
@@ -4003,7 +4022,7 @@ function attempt(parser2) {
|
|
|
4003
4022
|
rollbackCstCapture(ctx, mark);
|
|
4004
4023
|
if (log !== void 0 && ctx._triviaLog && ctx._triviaLog.length !== log) ctx._triviaLog.length = log;
|
|
4005
4024
|
if (rootLog !== void 0 && ctx._rootTriviaLog && ctx._rootTriviaLog.length !== rootLog) ctx._rootTriviaLog.length = rootLog;
|
|
4006
|
-
if (result.committed) return result;
|
|
4025
|
+
if (result.committed && !contain) return result;
|
|
4007
4026
|
return { ok: false, expected: result.expected, span: { start: pos, end: pos } };
|
|
4008
4027
|
}
|
|
4009
4028
|
};
|
|
@@ -4759,7 +4778,7 @@ function node(typeOrCombinator, combinatorOrBuild, buildOrOpts, maybeOpts) {
|
|
|
4759
4778
|
throw new Error("node() options cannot combine project with unwrap or collapse");
|
|
4760
4779
|
}
|
|
4761
4780
|
const def = unwrap || collapse || project !== void 0 || captureTrivia || trailingTrivia || buildArity !== void 0 || tags !== void 0 && tags.length > 0 ? { ...baseDef, ...unwrap ? { unwrap: true } : {}, ...collapse ? { collapse: true } : {}, ...project !== void 0 ? { project } : {}, ...captureTrivia ? { captureTrivia: true } : {}, ...trailingTrivia ? { trailingTrivia: true } : {}, ...buildArity !== void 0 ? { buildArity } : {}, ...tags !== void 0 && tags.length > 0 ? { tags } : {} } : baseDef;
|
|
4762
|
-
const capturesTrivia = captureTrivia ||
|
|
4781
|
+
const capturesTrivia = captureTrivia || (build ? buildReadsTrivia(def) : project === void 0);
|
|
4763
4782
|
const clonesState = build ? buildReadsState(def) : project === void 0;
|
|
4764
4783
|
const hasOwnFields = parserHasOwnFields(combinator);
|
|
4765
4784
|
const capturesFields = hasOwnFields && (build ? buildReadsFields(def) : project === void 0);
|
|
@@ -4873,13 +4892,17 @@ function transform(combinator, fn) {
|
|
|
4873
4892
|
};
|
|
4874
4893
|
}
|
|
4875
4894
|
function trivia(combinator) {
|
|
4876
|
-
const
|
|
4895
|
+
const labeled = analyzeLabeledTrivia(combinator);
|
|
4896
|
+
const kindLabels = labeled?.labels;
|
|
4877
4897
|
return {
|
|
4878
4898
|
_tag: combinator._tag,
|
|
4879
4899
|
_meta: {
|
|
4880
4900
|
...combinator._meta,
|
|
4881
4901
|
isTrivia: true,
|
|
4882
4902
|
triviaScanner: fastTriviaScanner(combinator),
|
|
4903
|
+
// Every labeled scan of this trivia reads its spec; the module's four-slot
|
|
4904
|
+
// memo alone thrashes on a grammar with more than four trivia tables.
|
|
4905
|
+
labeledTriviaSpec: labeled,
|
|
4883
4906
|
...kindLabels ? { triviaKindLabels: kindLabels } : {}
|
|
4884
4907
|
},
|
|
4885
4908
|
_def: { tag: "trivia", parser: combinator },
|