parseman 0.39.1 → 0.40.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/README.md +8 -0
- package/dist/combinators/node.d.ts +15 -0
- package/dist/combinators/node.d.ts.map +1 -1
- package/dist/compiler/codegen.d.ts.map +1 -1
- package/dist/compiler/ir-serialize.d.ts.map +1 -1
- package/dist/index.cjs +55 -20
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -20
- package/dist/index.js.map +2 -2
- package/dist/plugin/evaluator.d.ts.map +1 -1
- package/dist/plugin/index.cjs +75 -24
- package/dist/plugin/index.cjs.map +2 -2
- package/dist/plugin/index.js +75 -24
- package/dist/plugin/index.js.map +2 -2
- package/dist/spec/index.cjs +31 -9
- package/dist/spec/index.cjs.map +2 -2
- package/dist/spec/index.js +31 -9
- package/dist/spec/index.js.map +2 -2
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/plugin/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,UAAU,EAAE,IAAI,EAMjB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AA6E7C,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB,CAAA;AACD,MAAM,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AAM3C,KAAK,gBAAgB,GAAG;IAAE,GAAG,EAAE,aAAa,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,OAAO,CAAA;CAAE,CAAA;AAC1F,KAAK,gBAAgB,GAAG;IAAE,GAAG,EAAE,aAAa,CAAC;IAAC,eAAe,EAAE,OAAO,CAAA;CAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/plugin/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,UAAU,EAAE,IAAI,EAMjB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AA6E7C,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB,CAAA;AACD,MAAM,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AAM3C,KAAK,gBAAgB,GAAG;IAAE,GAAG,EAAE,aAAa,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,OAAO,CAAA;CAAE,CAAA;AAC1F,KAAK,gBAAgB,GAAG;IAAE,GAAG,EAAE,aAAa,CAAC;IAAC,eAAe,EAAE,OAAO,CAAA;CAAE,CAAA;AAguBxE,iFAAiF;AACjF,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,KAAK,EACZ,IAAI,CAAC,EAAE,MAAM,GACZ,gBAAgB,GAAG,IAAI,CAKzB;AAED,mFAAmF;AACnF,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,KAAK,EACZ,IAAI,CAAC,EAAE,MAAM,GACZ,gBAAgB,GAAG,IAAI,CAKzB;AAED,6EAA6E;AAC7E,wBAAgB,YAAY,CAC1B,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,KAAK,EACZ,IAAI,CAAC,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,EAAE,GACtB,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAE5B;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,KAAK,EACZ,IAAI,CAAC,EAAE,MAAM,GACZ,UAAU,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAM9B;AAkED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,UAAU,EACvB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EAAE,GACrB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CA8GzC;AAED,oEAAoE;AACpE,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG;IAAE,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAAA;CAAE,CAAA;AAQlF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,KAAK,GACX,YAAY,GAAG,IAAI,CAQrB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,UAAU,EACpB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,GACX,OAAO,CAoBT;AAED,kFAAkF;AAClF,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAcnF"}
|
package/dist/plugin/index.cjs
CHANGED
|
@@ -3021,12 +3021,30 @@ function isCstChild(value) {
|
|
|
3021
3021
|
function missingInferredType() {
|
|
3022
3022
|
throw new Error('node(): inferred node type requires a rules() key; pass node("Type", parser) outside rules()');
|
|
3023
3023
|
}
|
|
3024
|
+
function normalizeProject(project) {
|
|
3025
|
+
if (project === void 0) return void 0;
|
|
3026
|
+
if (!Number.isInteger(project) || project < 0) {
|
|
3027
|
+
throw new Error("node() project child must be a non-negative integer");
|
|
3028
|
+
}
|
|
3029
|
+
return project;
|
|
3030
|
+
}
|
|
3031
|
+
function projectChild(children2, project, type) {
|
|
3032
|
+
if (!(project in children2)) {
|
|
3033
|
+
throw new Error(`node(${JSON.stringify(type)}) project child ${project} was not captured`);
|
|
3034
|
+
}
|
|
3035
|
+
return unwrapChild(children2[project]);
|
|
3036
|
+
}
|
|
3024
3037
|
function node(typeOrCombinator, combinatorOrBuild, buildOrOpts, maybeOpts) {
|
|
3025
3038
|
const hasExplicitType = typeof typeOrCombinator === "string";
|
|
3026
3039
|
const type = hasExplicitType ? typeOrCombinator : void 0;
|
|
3027
3040
|
const combinator = hasExplicitType ? combinatorOrBuild : typeOrCombinator;
|
|
3028
|
-
const
|
|
3029
|
-
const
|
|
3041
|
+
const buildArg = hasExplicitType ? buildOrOpts : combinatorOrBuild;
|
|
3042
|
+
const build = typeof buildArg === "function" ? buildArg : void 0;
|
|
3043
|
+
const opts = typeof buildArg === "function" ? maybeOpts : buildArg ?? maybeOpts;
|
|
3044
|
+
const project = normalizeProject(opts?.project);
|
|
3045
|
+
if (project !== void 0 && build !== void 0) {
|
|
3046
|
+
throw new Error("node() options cannot combine project with a build callback");
|
|
3047
|
+
}
|
|
3030
3048
|
const baseDef = { tag: "node", parser: combinator, ...type === void 0 ? {} : { type }, ...build === void 0 ? {} : { build } };
|
|
3031
3049
|
const meta = {
|
|
3032
3050
|
firstSet: combinator._meta.firstSet,
|
|
@@ -3040,11 +3058,14 @@ function node(typeOrCombinator, combinatorOrBuild, buildOrOpts, maybeOpts) {
|
|
|
3040
3058
|
if (unwrap && collapse) {
|
|
3041
3059
|
throw new Error("node() options cannot set both unwrap and collapse");
|
|
3042
3060
|
}
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3061
|
+
if (project !== void 0 && (unwrap || collapse)) {
|
|
3062
|
+
throw new Error("node() options cannot combine project with unwrap or collapse");
|
|
3063
|
+
}
|
|
3064
|
+
const def = unwrap || collapse || project !== void 0 || captureTrivia || trailingTrivia ? { ...baseDef, ...unwrap ? { unwrap: true } : {}, ...collapse ? { collapse: true } : {}, ...project !== void 0 ? { project } : {}, ...captureTrivia ? { captureTrivia: true } : {}, ...trailingTrivia ? { trailingTrivia: true } : {} } : baseDef;
|
|
3065
|
+
const capturesTrivia = captureTrivia || trailingTrivia || (build ? buildReadsTrivia(def) : project === void 0);
|
|
3066
|
+
const clonesState = build ? buildReadsState(def) : project === void 0;
|
|
3046
3067
|
const hasOwnFields = parserHasOwnFields(combinator);
|
|
3047
|
-
const capturesFields = hasOwnFields && (build ? buildReadsFields(def) :
|
|
3068
|
+
const capturesFields = hasOwnFields && (build ? buildReadsFields(def) : project === void 0);
|
|
3048
3069
|
const guardable = combinator._meta.firstSet.kind !== "any" && !matchesEmpty(combinator);
|
|
3049
3070
|
let failExpected;
|
|
3050
3071
|
return {
|
|
@@ -3059,14 +3080,15 @@ function node(typeOrCombinator, combinatorOrBuild, buildOrOpts, maybeOpts) {
|
|
|
3059
3080
|
}
|
|
3060
3081
|
return { ok: false, expected: failExpected, span: { start: pos, end: pos } };
|
|
3061
3082
|
}
|
|
3062
|
-
const
|
|
3083
|
+
const hasDirectValue = build !== void 0 || project !== void 0;
|
|
3084
|
+
const hostCst = hasDirectValue && cstOutputHost(ctx.build);
|
|
3063
3085
|
const effTrivia = capturesTrivia || hostCst;
|
|
3064
3086
|
const effFields = capturesFields || hostCst && hasOwnFields;
|
|
3065
3087
|
const saved = beginCstNodeCapture(ctx);
|
|
3066
3088
|
const savedFields = ctx._fields;
|
|
3067
3089
|
ctx._fields = effFields ? [] : void 0;
|
|
3068
3090
|
const savedMask = ctx._triviaCaptureMask;
|
|
3069
|
-
if (build === void 0 && ctx.build?._parsemanTriviaKinds !== void 0 && def.type !== void 0) {
|
|
3091
|
+
if (build === void 0 && project === void 0 && ctx.build?._parsemanTriviaKinds !== void 0 && def.type !== void 0) {
|
|
3070
3092
|
ctx._triviaCaptureMask = ctx.build._parsemanTriviaKinds(def.type);
|
|
3071
3093
|
}
|
|
3072
3094
|
if (!effTrivia) ctx.captureTrivia = false;
|
|
@@ -3084,7 +3106,7 @@ function node(typeOrCombinator, combinatorOrBuild, buildOrOpts, maybeOpts) {
|
|
|
3084
3106
|
const nodeType = def.type ?? missingInferredType();
|
|
3085
3107
|
const cstOutput = cstOutputHost(ctx.build);
|
|
3086
3108
|
const hostState = clonesState ? st : ctx.state !== void 0 ? Object.assign({}, ctx.state) : void 0;
|
|
3087
|
-
const built = unwrap && children2.length === 1 ? unwrapChild(children2[0]) : collapse && children2.length === 1 ? children2[0] : !build && ctx.build?._parsemanCstCollapse && children2.length === 1 && rawChildren.length === 1 && ctx.build._parsemanCstCollapse(nodeType, children2[0], children2, rawChildren) ? children2[0] : build ? cstOutput && ctx.build ? ctx.build(nodeType, children2, fields, r.span, rawChildren, triviaLog, hostState) : build(children2, fields, r.span, rawChildren, triviaLog, st) : ctx.build ? ctx.build(nodeType, children2, fields, r.span, rawChildren, triviaLog, st) : { _tag: "node", type: nodeType, span: { start: r.span.start, end: r.span.end }, state: st ?? null, children: children2 };
|
|
3109
|
+
const built = unwrap && children2.length === 1 ? unwrapChild(children2[0]) : collapse && children2.length === 1 ? children2[0] : !build && project === void 0 && ctx.build?._parsemanCstCollapse && children2.length === 1 && rawChildren.length === 1 && ctx.build._parsemanCstCollapse(nodeType, children2[0], children2, rawChildren) ? children2[0] : project !== void 0 ? cstOutput && ctx.build ? ctx.build(nodeType, children2, fields, r.span, rawChildren, triviaLog, hostState) : projectChild(children2, project, nodeType) : build ? cstOutput && ctx.build ? ctx.build(nodeType, children2, fields, r.span, rawChildren, triviaLog, hostState) : build(children2, fields, r.span, rawChildren, triviaLog, st) : ctx.build ? ctx.build(nodeType, children2, fields, r.span, rawChildren, triviaLog, st) : { _tag: "node", type: nodeType, span: { start: r.span.start, end: r.span.end }, state: st ?? null, children: children2 };
|
|
3088
3110
|
const rawEntry = isCstChild(built) ? built : { _tag: "leaf", value: typeof built === "string" ? built : typeof built === "object" && built !== null ? input.slice(r.span.start, r.span.end) : "", span: r.span };
|
|
3089
3111
|
if (saved.buf !== void 0 || saved.ch !== void 0) {
|
|
3090
3112
|
pushCstChild(ctx, built, rawEntry);
|
|
@@ -3335,7 +3357,7 @@ function leaf(root, fn) {
|
|
|
3335
3357
|
}
|
|
3336
3358
|
|
|
3337
3359
|
// src/version.ts
|
|
3338
|
-
var PARSEMAN_VERSION = "0.
|
|
3360
|
+
var PARSEMAN_VERSION = "0.40.0";
|
|
3339
3361
|
|
|
3340
3362
|
// src/cst/host-mode.ts
|
|
3341
3363
|
var FUSED_HOST_MODE = /* @__PURE__ */ Symbol.for("parseman.fusedHostMode");
|
|
@@ -8506,14 +8528,20 @@ function emitLeaf(def, ctx, pos) {
|
|
|
8506
8528
|
endVar: inner.endVar
|
|
8507
8529
|
};
|
|
8508
8530
|
}
|
|
8531
|
+
function emitNodeProjectExpr(type, project, chV) {
|
|
8532
|
+
const child = `${chV}[${project}]`;
|
|
8533
|
+
const missing = `(() => { throw new Error(${JSON.stringify(`node(${JSON.stringify(type)}) project child ${project} was not captured`)}) })()`;
|
|
8534
|
+
const value = `(${child} !== null && typeof ${child} === 'object' && ${child}._tag === 'leaf' ? ${child}.value : ${child})`;
|
|
8535
|
+
return `(${project} in ${chV} ? ${value} : ${missing})`;
|
|
8536
|
+
}
|
|
8509
8537
|
function emitNode(def, ctx, pos) {
|
|
8510
8538
|
if (def.type === void 0) {
|
|
8511
8539
|
throw new Error('node(): inferred node type requires a rules() key; pass node("Type", parser) outside rules()');
|
|
8512
8540
|
}
|
|
8513
|
-
const structural = def.build === void 0;
|
|
8514
|
-
const mkType = structural ? null : analyzeMkInlineBuild(def);
|
|
8541
|
+
const structural = def.build === void 0 && def.project === void 0;
|
|
8542
|
+
const mkType = structural || def.project !== void 0 ? null : analyzeMkInlineBuild(def);
|
|
8515
8543
|
let buildIdx = null;
|
|
8516
|
-
if (!mkType && !structural) {
|
|
8544
|
+
if (!mkType && !structural && def.project === void 0) {
|
|
8517
8545
|
buildIdx = ctx.buildFns.length;
|
|
8518
8546
|
ctx.buildFns.push(def.build);
|
|
8519
8547
|
ctx.buildSrcs.push(def.buildSrc ?? null);
|
|
@@ -8521,12 +8549,13 @@ function emitNode(def, ctx, pos) {
|
|
|
8521
8549
|
const i = ind(ctx);
|
|
8522
8550
|
const cstOut = ctx.hostMode === "cst" && !structural;
|
|
8523
8551
|
if (!structural && !cstOut) ctx.hostBranchElided = true;
|
|
8524
|
-
const
|
|
8525
|
-
const
|
|
8526
|
-
const
|
|
8527
|
-
const
|
|
8552
|
+
const hasProject = def.project !== void 0;
|
|
8553
|
+
const capturesTrivia = cstOut || mkType !== null || def.captureTrivia === true || def.trailingTrivia === true || !structural && !hasProject && buildReadsTrivia(def);
|
|
8554
|
+
const clonesState = !structural && (cstOut || !hasProject && buildReadsState(def));
|
|
8555
|
+
const capturesChildren = !structural && (cstOut || mkType !== null || def.unwrap || def.collapse || def.project !== void 0 || buildReadsChildren(def));
|
|
8556
|
+
const capturesRaw = !structural && (cstOut || mkType !== null || def.project === void 0 && buildReadsRaw(def));
|
|
8528
8557
|
const hasFields = parserHasOwnFields(def.parser);
|
|
8529
|
-
const capturesFields = hasFields && !structural && (cstOut || buildReadsFields(def));
|
|
8558
|
+
const capturesFields = hasFields && !structural && (cstOut || !hasProject && buildReadsFields(def));
|
|
8530
8559
|
const innerEnablesTriviaCapture = parserEnablesTriviaCapture(def.parser);
|
|
8531
8560
|
const chV = v(ctx, "_ch");
|
|
8532
8561
|
const rawV = v(ctx, "_raw");
|
|
@@ -8624,7 +8653,7 @@ ${i}const ${chV} = ${chAlloc}, ${rawV} = ${profileRecognizer} ? undefined : [],
|
|
|
8624
8653
|
);
|
|
8625
8654
|
}
|
|
8626
8655
|
const ndV = v(ctx, "_nd");
|
|
8627
|
-
const buildExpr = structural ? `{ _tag: 'node', type: ${JSON.stringify(def.type)}, span: { start: ${pos}, end: ${endVar} }, state: ${stV} ?? null, children: ${chV} }` : mkType ? emitInlineMkNodeExpr(mkType, chV, rawV, pos, endVar, tlV) : `${buildRef(ctx)}[${buildIdx}](${chV}, ${fObj}, { start: ${pos}, end: ${endVar} }, ${rawV}, ${tlV}, ${stV})`;
|
|
8656
|
+
const buildExpr = structural ? `{ _tag: 'node', type: ${JSON.stringify(def.type)}, span: { start: ${pos}, end: ${endVar} }, state: ${stV} ?? null, children: ${chV} }` : mkType ? emitInlineMkNodeExpr(mkType, chV, rawV, pos, endVar, tlV) : def.project !== void 0 ? emitNodeProjectExpr(def.type, def.project, chV) : `${buildRef(ctx)}[${buildIdx}](${chV}, ${fObj}, { start: ${pos}, end: ${endVar} }, ${rawV}, ${tlV}, ${stV})`;
|
|
8628
8657
|
const hostBuildExpr = `_ctx._pmProfile?.phase === 'host' && _ctx._pmProfile.hostCalls++, _ctx.build(${JSON.stringify(def.type)}, ${chV}, ${fObj}, { start: ${pos}, end: ${endVar} }, ${rawV}, ${tlV}, ${stV})`;
|
|
8629
8658
|
const ndExpr = structural ? `_ctx.build !== undefined ? (${hostBuildExpr}) : (${buildExpr})` : cstOut ? hostBuildExpr : buildExpr;
|
|
8630
8659
|
const hostCollapseExpr = structural ? `_ctx.build !== undefined && _ctx.build._parsemanCstCollapse !== undefined && ${chV}.length === 1 && ${rawV}.length === 1 && _ctx.build._parsemanCstCollapse(${JSON.stringify(def.type)}, ${chV}[0], ${chV}, ${rawV}) ? ${chV}[0] : (${ndExpr})` : ndExpr;
|
|
@@ -10035,6 +10064,10 @@ function repeatOpts(min, max, trailing) {
|
|
|
10035
10064
|
if (trailing !== void 0) parts.push(`trailing: ${JSON.stringify(trailing)}`);
|
|
10036
10065
|
return parts.length === 0 ? "" : `, { ${parts.join(", ")} }`;
|
|
10037
10066
|
}
|
|
10067
|
+
function projectOpt(project) {
|
|
10068
|
+
if (project === void 0) return void 0;
|
|
10069
|
+
return `project: ${project}`;
|
|
10070
|
+
}
|
|
10038
10071
|
function matcherExpr(entry) {
|
|
10039
10072
|
switch (entry.kind) {
|
|
10040
10073
|
case "startsWith":
|
|
@@ -10428,9 +10461,11 @@ ${outerDecls.map((d) => " " + d).join("\n")}
|
|
|
10428
10461
|
}
|
|
10429
10462
|
case "node": {
|
|
10430
10463
|
if (def.build !== void 0 && def.buildSrc === void 0) throw new Unserializable("node build without buildSrc");
|
|
10464
|
+
const projectEntry = projectOpt(def.project);
|
|
10431
10465
|
const optEntries = [
|
|
10432
10466
|
...def.unwrap ? ["unwrap: true"] : [],
|
|
10433
10467
|
...def.collapse ? ["collapse: true"] : [],
|
|
10468
|
+
...projectEntry === void 0 ? [] : [projectEntry],
|
|
10434
10469
|
...def.captureTrivia ? ["captureTrivia: true"] : [],
|
|
10435
10470
|
...def.trailingTrivia ? ["trailingTrivia: true"] : []
|
|
10436
10471
|
];
|
|
@@ -11035,6 +11070,18 @@ function scopeGet(scope, name, mfs) {
|
|
|
11035
11070
|
if (isCombinator(entry)) return entry;
|
|
11036
11071
|
return null;
|
|
11037
11072
|
}
|
|
11073
|
+
function staticLiteralValue(expr) {
|
|
11074
|
+
const val = expr;
|
|
11075
|
+
return val.type === "Literal" || val.type === "BooleanLiteral" || val.type === "NumericLiteral" ? val.value : void 0;
|
|
11076
|
+
}
|
|
11077
|
+
function staticNodeProject(expr) {
|
|
11078
|
+
const literalValue = staticLiteralValue(expr);
|
|
11079
|
+
if (typeof literalValue === "number" && Number.isInteger(literalValue) && literalValue >= 0) {
|
|
11080
|
+
return { ok: true, value: literalValue };
|
|
11081
|
+
}
|
|
11082
|
+
if (typeof literalValue === "number" || literalValue !== void 0) return { ok: false };
|
|
11083
|
+
return { ok: false };
|
|
11084
|
+
}
|
|
11038
11085
|
function staticNodeOptions(expr) {
|
|
11039
11086
|
if (expr.type !== "ObjectExpression") return void 0;
|
|
11040
11087
|
const opts = {};
|
|
@@ -11044,11 +11091,14 @@ function staticNodeOptions(expr) {
|
|
|
11044
11091
|
const key = p.key;
|
|
11045
11092
|
const name = key.type === "Identifier" ? key.name : key.type === "Literal" ? String(key.value) : void 0;
|
|
11046
11093
|
if (name === "unwrap" || name === "collapse" || name === "captureTrivia" || name === "trailingTrivia") {
|
|
11047
|
-
|
|
11048
|
-
|
|
11094
|
+
if (staticLiteralValue(p.value) === true) opts[name] = true;
|
|
11095
|
+
} else if (name === "project") {
|
|
11096
|
+
const project = staticNodeProject(p.value);
|
|
11097
|
+
if (project?.ok === false) return { project: -1 };
|
|
11098
|
+
if (project !== void 0) opts.project = project.value;
|
|
11049
11099
|
}
|
|
11050
11100
|
}
|
|
11051
|
-
return opts.unwrap || opts.collapse || opts.captureTrivia || opts.trailingTrivia ? opts : void 0;
|
|
11101
|
+
return opts.unwrap || opts.collapse || opts.project !== void 0 || opts.captureTrivia || opts.trailingTrivia ? opts : void 0;
|
|
11052
11102
|
}
|
|
11053
11103
|
function exprToCombi(node2, scope, code, mfs) {
|
|
11054
11104
|
if (node2.type === "Identifier") return scopeGet(scope, node2.name, mfs);
|
|
@@ -11123,9 +11173,10 @@ function exprToCombi(node2, scope, code, mfs) {
|
|
|
11123
11173
|
const inner = anyValue(parserArg, scope, code, mfs);
|
|
11124
11174
|
if (!isCombinator(inner)) return null;
|
|
11125
11175
|
const be = buildArg;
|
|
11126
|
-
const hasBuild = be !== void 0 && be.type !== "SpreadElement" && !(be.type === "Identifier" && be.name === "undefined");
|
|
11176
|
+
const hasBuild = be !== void 0 && be.type !== "SpreadElement" && be.type !== "ObjectExpression" && !(be.type === "Identifier" && be.name === "undefined");
|
|
11127
11177
|
const buildSrc = hasBuild ? stripTsFromSource(be, code) : void 0;
|
|
11128
|
-
const
|
|
11178
|
+
const optionsArg = hasBuild ? optsArg : be?.type === "ObjectExpression" ? buildArg : optsArg;
|
|
11179
|
+
const opts = optionsArg !== void 0 && optionsArg.type !== "SpreadElement" ? staticNodeOptions(optionsArg) : void 0;
|
|
11129
11180
|
try {
|
|
11130
11181
|
const combi = explicitType !== void 0 ? node(explicitType, inner, hasBuild ? () => null : void 0, opts) : node(inner, hasBuild ? () => null : void 0, opts);
|
|
11131
11182
|
if (combi._def.tag === "node" && buildSrc !== void 0) {
|