parseman 0.50.4 → 0.50.6
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/index.js +31 -3
- package/dist/index.js.map +1 -1
- package/dist/plugin/evaluator.d.ts.map +1 -1
- package/dist/plugin/index.js +34 -3
- package/dist/plugin/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/compiler/ir-serialize.ts +41 -2
- package/src/plugin/evaluator.ts +13 -0
- package/src/version.ts +1 -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;AAG7C,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAInE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAmG5D,qFAAqF;AACrF,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,eAAe,GAAG,IAAI,EAAE,WAAW,GAAE,MAAM,GAAG,IAAW,GAAG,IAAI,CAGrG;AAED;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAA;AAEjG,uGAAuG;AACvG,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,qBAAqB,GAAG,IAAI,GAAG,IAAI,CAE9E;AAWD,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB,CAAA;AACD,MAAM,MAAM,KAA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569
|
body(c) {
|
|
16570
16570
|
return c._def.tag === "lazy" && ruleNameOf3(c) !== void 0 ? lazyTarget(c) ?? c : c;
|
|
16571
16571
|
}
|
|
16572
|
+
/**
|
|
16573
|
+
* The child a rule-entry grammar scope should serialize as its body, when that
|
|
16574
|
+
* scope merely WRAPS the rule's own named `lazy` proxy.
|
|
16575
|
+
*
|
|
16576
|
+
* `rules({ trackLines: true }, …)` wraps every rule VALUE — which is that rule's
|
|
16577
|
+
* own named lazy proxy — in a `grammarParser({ trackLines: true })` scope
|
|
16578
|
+
* (`parser.ts:229-242`). `body()` unwraps a BARE lazy entry to its defined target;
|
|
16579
|
+
* a lazy wrapped one level deep by that scope must be unwrapped INSIDE the scope
|
|
16580
|
+
* too. Left wrapped, the inner proxy serializes as a `g[name]` SELF-reference and
|
|
16581
|
+
* the rule's real body is dropped, so it re-lowers to `Name: parser(opts, g.Name)`
|
|
16582
|
+
* — a bodyless self-cycle the table encoder rejects with `alias cycle — lazy (rule
|
|
16583
|
+
* 'Name') encodes to its own recursion trampoline`. This is why the four
|
|
16584
|
+
* `*PositionsGrammar` exports fell back to a runtime `compose()` under trackLines.
|
|
16585
|
+
*
|
|
16586
|
+
* STRICT: only a scope that IS a rule entry (in `localRuleNames`) AND wraps ITS
|
|
16587
|
+
* OWN name unwraps. A scope wrapping another rule's ref (a genuine cross-rule
|
|
16588
|
+
* alias, `Name: parser(opts, g.Other)`) or a real body is untouched, so the
|
|
16589
|
+
* non-trackLines and non-self-wrap output stays byte-identical.
|
|
16590
|
+
*/
|
|
16591
|
+
scopeSelfBody(c) {
|
|
16592
|
+
const name = this.localRuleNames.get(c);
|
|
16593
|
+
if (name === void 0 || c._def.tag !== "grammar") return void 0;
|
|
16594
|
+
const inner = c._def.parser;
|
|
16595
|
+
if (inner._def.tag !== "lazy" || ruleNameOf3(inner) !== name) return void 0;
|
|
16596
|
+
return lazyTarget(inner) ?? void 0;
|
|
16597
|
+
}
|
|
16572
16598
|
run() {
|
|
16573
16599
|
for (const [, c] of this.ruleMap) this.analyze(this.body(c), /* @__PURE__ */ new Set());
|
|
16574
16600
|
for (const c of this.scanSkip) {
|
|
@@ -16638,7 +16664,9 @@ ${outerDecls.map((d) => " " + d).join("\n")}
|
|
|
16638
16664
|
return;
|
|
16639
16665
|
}
|
|
16640
16666
|
active.add(c);
|
|
16641
|
-
|
|
16667
|
+
const selfBody = def.tag === "grammar" ? this.scopeSelfBody(c) : void 0;
|
|
16668
|
+
const kids = selfBody === void 0 ? childrenOf3(def) : def.tag === "grammar" && def.triviaParser ? [selfBody, def.triviaParser] : [selfBody];
|
|
16669
|
+
for (const child of kids) this.analyze(child, active);
|
|
16642
16670
|
active.delete(c);
|
|
16643
16671
|
}
|
|
16644
16672
|
/** Reference `c`: a const var if it has one (emitting its decl first), else inline.
|
|
@@ -16804,7 +16832,7 @@ ${outerDecls.map((d) => " " + d).join("\n")}
|
|
|
16804
16832
|
const spec = classified && def.triviaParser ? analyzeLabeledTrivia(def.triviaParser) : null;
|
|
16805
16833
|
if (classified && !spec) throw new Unserializable("classified trivia without labeled arms");
|
|
16806
16834
|
const trivia2 = def.clearTrivia ? "null" : spec ? `classifiedTrivia({ ${spec.arms.map((arm) => `${JSON.stringify(arm.label)}: ${kid(arm.parser)}`).join(", ")} })` : def.triviaParser ? kid(def.triviaParser) : "undefined";
|
|
16807
|
-
return `parser({ trivia: ${trivia2}${def.captureTrivia ? ", captureTrivia: true" : ""}${def.rootCapture ? `, rootCapture: ${JSON.stringify(def.rootCapture)}` : ""}${def.trackLines ? ", trackLines: true" : ""} }, ${kid(def.parser)})`;
|
|
16835
|
+
return `parser({ trivia: ${trivia2}${def.captureTrivia ? ", captureTrivia: true" : ""}${def.rootCapture ? `, rootCapture: ${JSON.stringify(def.rootCapture)}` : ""}${def.trackLines ? ", trackLines: true" : ""} }, ${kid(this.scopeSelfBody(c) ?? def.parser)})`;
|
|
16808
16836
|
}
|
|
16809
16837
|
case "withCtx": {
|
|
16810
16838
|
if (def.extraSrc === void 0) throw new Unserializable("withCtx without extraSrc");
|
|
@@ -16940,7 +16968,7 @@ function compileRuleMap(ruleMap, opts = {}) {
|
|
|
16940
16968
|
}
|
|
16941
16969
|
|
|
16942
16970
|
// src/version.ts
|
|
16943
|
-
var PARSEMAN_VERSION = "0.50.
|
|
16971
|
+
var PARSEMAN_VERSION = "0.50.6";
|
|
16944
16972
|
|
|
16945
16973
|
// src/compiler/compile-linkable-table.ts
|
|
16946
16974
|
function isLocal(rule) {
|
|
@@ -17738,6 +17766,9 @@ function exprToCombi(node2, scope, code, mfs) {
|
|
|
17738
17766
|
if (prov) carriedImports.push({ local: name, source: prov.source, imported: prov.imported });
|
|
17739
17767
|
else unresolved.push(name);
|
|
17740
17768
|
}
|
|
17769
|
+
} else if (be.type === "Identifier" && typeof be.name === "string" && combi._def.buildSrc === be.name) {
|
|
17770
|
+
const prov = _builderImports?.(be.name) ?? null;
|
|
17771
|
+
if (prov) carriedImports.push({ local: be.name, source: prov.source, imported: prov.imported });
|
|
17741
17772
|
}
|
|
17742
17773
|
const staticError = [...report.structural, ...unresolved];
|
|
17743
17774
|
if (staticError.length > 0) combi._def.buildStaticError = staticError;
|