parseman 0.30.0 → 0.31.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/compiler/codegen.d.ts.map +1 -1
- package/dist/compiler/linker.d.ts.map +1 -1
- package/dist/index.cjs +6 -4
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +6 -4
- package/dist/index.js.map +2 -2
- package/dist/language-service/index.cjs +1 -1
- package/dist/language-service/index.cjs.map +2 -2
- package/dist/language-service/index.js +1 -1
- package/dist/language-service/index.js.map +2 -2
- package/dist/plugin/index.cjs +6 -4
- package/dist/plugin/index.cjs.map +2 -2
- package/dist/plugin/index.js +6 -4
- package/dist/plugin/index.js.map +2 -2
- package/dist/types.d.ts +14 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4401,9 +4401,9 @@ function emitLeafCapture(ctx, valExpr, startExpr, endExpr) {
|
|
|
4401
4401
|
const i = ind(ctx);
|
|
4402
4402
|
const lf = v(ctx, "_lf");
|
|
4403
4403
|
return [
|
|
4404
|
-
`${i}if (_ctx._cstLeaves) {`,
|
|
4404
|
+
`${i}if (_ctx._cstLeaves || _ctx._cstRawChildren) {`,
|
|
4405
4405
|
`${i} const ${lf} = { _tag: 'leaf', value: ${valExpr}, span: { start: ${startExpr}, end: ${endExpr} } }`,
|
|
4406
|
-
`${i} _ctx._cstLeaves.push(${lf})`,
|
|
4406
|
+
`${i} if (_ctx._cstLeaves) _ctx._cstLeaves.push(${lf})`,
|
|
4407
4407
|
`${i} if (_ctx._cstRawChildren) _ctx._cstRawChildren.push(${lf})`,
|
|
4408
4408
|
`${i}}`
|
|
4409
4409
|
];
|
|
@@ -5807,8 +5807,10 @@ function emitNode(def, ctx, pos) {
|
|
|
5807
5807
|
const directCstV = !structural && (!capturesChildren || !capturesRaw) ? v(ctx, "_dcst") : null;
|
|
5808
5808
|
const directCstGate = directCstV === null ? "false" : `${profileCapture} || _ctx.build?._parsemanCstOutput === true`;
|
|
5809
5809
|
const structuralCapturesTrivia = structural && (def.captureTrivia === true || def.trailingTrivia === true);
|
|
5810
|
+
const chNeededExpr = def.unwrap || def.collapse ? "true" : `(_ctx._pmReadsCh ??= (_ctx.build === undefined || _ctx.build._parsemanReadsChildren !== false || _ctx.build._parsemanCstCollapse !== undefined))`;
|
|
5811
|
+
const chAlloc = def.unwrap || def.collapse ? `${profileRecognizer} ? undefined : []` : `${profileRecognizer} ? undefined : ((${profileCapture} || ${chNeededExpr}) ? [] : undefined)`;
|
|
5810
5812
|
const allocStmt = structural ? `${i}const ${capTLv} = !(${profileRecognizer}) && (${profileCapture} || ${structuralCapturesTrivia ? "true" : hostTriviaGate}), ${capSTv} = !(${profileRecognizer} || ${profileCapture}) && (_ctx._pmCapST ??= (_ctx.build === undefined || _hostReads(_ctx.build, 6)))${capFv ? `, ${capFv} = !(${profileRecognizer}) && (${profileCapture} || (_ctx.build !== undefined && _hostReads(_ctx.build, 2)))` : ""}
|
|
5811
|
-
${i}const ${chV} = ${
|
|
5813
|
+
${i}const ${chV} = ${chAlloc}, ${rawV} = ${profileRecognizer} ? undefined : [], ${tlV} = ${profileRecognizer} ? undefined : ${innerEnablesTriviaCapture ? "[]" : `${capTLv} ? [] : _EMPTY_TL`}` : capturesTrivia ? `${directCstV ? `${i}const ${directCstV} = ${directCstGate}
|
|
5812
5814
|
` : ""}${i}const ${capTLv} = !(${profileRecognizer}), ${chV} = ${profileRecognizer} ? undefined : ${capturesChildren ? "[]" : `${directCstV} ? [] : undefined`}, ${rawV} = ${profileRecognizer} ? undefined : ${capturesRaw ? "[]" : `${directCstV} ? [] : undefined`}, ${tlV} = ${profileRecognizer} ? undefined : []` : `${directCstV ? `${i}const ${directCstV} = ${directCstGate}
|
|
5813
5815
|
` : ""}${i}const ${chV} = ${profileRecognizer} ? undefined : ${capturesChildren ? "[]" : `${directCstV} ? [] : undefined`}, ${rawV} = ${profileRecognizer} ? undefined : ${capturesRaw ? "[]" : `${directCstV} ? [] : undefined`}`;
|
|
5814
5816
|
const innerTl = structural || capturesTrivia ? structural && !innerEnablesTriviaCapture ? `${capTLv} ? ${tlV} : undefined` : tlV : "undefined";
|
|
@@ -7376,7 +7378,7 @@ function cstBuildHost(typeOrOptions, children2, _fields, span, rawChildren, triv
|
|
|
7376
7378
|
return buildCstNode(typeOrOptions, children2 ?? [], _fields, span ?? { start: 0, end: 0 }, rawChildren, triviaLog, state);
|
|
7377
7379
|
}
|
|
7378
7380
|
const collapse = normalizeCstCollapse(typeOrOptions?.collapse);
|
|
7379
|
-
const host = (type, children3, fields, span2, rawChildren2, triviaLog2, state2) => buildCstNode(type, children3, fields, span2, rawChildren2, triviaLog2, state2);
|
|
7381
|
+
const host = (type, children3, fields, span2, rawChildren2, triviaLog2, state2) => buildCstNode(type, children3 ?? [], fields, span2, rawChildren2, triviaLog2, state2);
|
|
7380
7382
|
host._parsemanCstOutput = true;
|
|
7381
7383
|
if (collapse) host._parsemanCstCollapse = collapse;
|
|
7382
7384
|
return host;
|