parseman 0.32.0 → 0.33.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/ir-serialize.d.ts +1 -1
- package/dist/compiler/ir-serialize.d.ts.map +1 -1
- package/dist/compiler/linker.d.ts.map +1 -1
- package/dist/index.cjs +46 -10
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +46 -10
- package/dist/index.js.map +2 -2
- package/dist/language-service/index.cjs.map +1 -1
- package/dist/language-service/index.js.map +1 -1
- package/dist/plugin/index.cjs +63 -22
- package/dist/plugin/index.cjs.map +2 -2
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +63 -22
- package/dist/plugin/index.js.map +2 -2
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import type { Combinator } from '../types.ts';
|
|
21
21
|
type Comb = Combinator<unknown>;
|
|
22
|
-
export declare function serializeRuleMap(ruleMap: ReadonlyArray<readonly [string, Comb]
|
|
22
|
+
export declare function serializeRuleMap(ruleMap: ReadonlyArray<readonly [string, Comb]>, scanSkip?: readonly Comb[] | null): string | null;
|
|
23
23
|
/** Reconstruct a rule map from serialized IR (the inverse of `serializeRuleMap`) —
|
|
24
24
|
* evaluate the combinator-construction expression with every constructor in scope.
|
|
25
25
|
* Used at fuse time (runtime linker + build-time plugin) to re-lower carried IR. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ir-serialize.d.ts","sourceRoot":"","sources":["../../src/compiler/ir-serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,aAAa,CAAA;AAmBxD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;AA8C/B,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"ir-serialize.d.ts","sourceRoot":"","sources":["../../src/compiler/ir-serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,aAAa,CAAA;AAmBxD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;AA8C/B,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,EAC/C,QAAQ,CAAC,EAAE,SAAS,IAAI,EAAE,GAAG,IAAI,GAChC,MAAM,GAAG,IAAI,CAUf;AAED;;oFAEoF;AACpF,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAqG/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linker.d.ts","sourceRoot":"","sources":["../../src/compiler/linker.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,cAAc,CAAA;AAGlE,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,oBAAoB,EAAY,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAanH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,EAC7C,EAAE,CAAC,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAC3B,cAAc,CAIhB;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,GAAG,oBAAoB,CAAA;CAC9D,CAAA;AAyBD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,mB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MAAM,OAAO,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AAyBhD;;gFAEgF;AAChF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,SAAS,CAEvH;AAED;qEACqE;AACrE,wBAAgB,gBAAgB,CAC9B,CAAC,EAAE,cAAc,GAAG,OAAO,EAC3B,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAC5B,gBAAgB,UAAQ,GACvB,cAAc,CAQhB;AAgFD,wBAAgB,OAAO,CACrB,KAAK,EAAE,KAAK,CAAC,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACrD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAoB3B;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,KAAK,CAAC,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACtD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAE3B"}
|
package/dist/index.cjs
CHANGED
|
@@ -2924,7 +2924,7 @@ function leaf(root, fn) {
|
|
|
2924
2924
|
}
|
|
2925
2925
|
|
|
2926
2926
|
// src/version.ts
|
|
2927
|
-
var PARSEMAN_VERSION = "0.
|
|
2927
|
+
var PARSEMAN_VERSION = "0.33.0";
|
|
2928
2928
|
|
|
2929
2929
|
// src/analysis/gating.ts
|
|
2930
2930
|
var isAny = (fs) => fs.kind === "any";
|
|
@@ -7558,9 +7558,9 @@ function lazyTarget(c) {
|
|
|
7558
7558
|
}
|
|
7559
7559
|
var Unserializable = class extends Error {
|
|
7560
7560
|
};
|
|
7561
|
-
function serializeRuleMap(ruleMap) {
|
|
7561
|
+
function serializeRuleMap(ruleMap, scanSkip) {
|
|
7562
7562
|
try {
|
|
7563
|
-
return new Serializer(ruleMap).run();
|
|
7563
|
+
return new Serializer(ruleMap, scanSkip ?? []).run();
|
|
7564
7564
|
} catch (e) {
|
|
7565
7565
|
if (e instanceof Unserializable) {
|
|
7566
7566
|
if (process.env.PARSEMAN_IR_DEBUG) console.error(`[ir] fallback: ${e.message}`);
|
|
@@ -7721,10 +7721,28 @@ var Serializer = class {
|
|
|
7721
7721
|
decls = [];
|
|
7722
7722
|
ruleValues = /* @__PURE__ */ new Set();
|
|
7723
7723
|
ruleMap;
|
|
7724
|
-
|
|
7724
|
+
scanSkip;
|
|
7725
|
+
constructor(ruleMap, scanSkip = []) {
|
|
7725
7726
|
this.ruleMap = ruleMap;
|
|
7727
|
+
this.scanSkip = scanSkip;
|
|
7726
7728
|
for (const [, c] of ruleMap) this.ruleValues.add(this.body(c));
|
|
7727
7729
|
}
|
|
7730
|
+
/** A grammar-level `scanSkip` unit is an opaque TERMINAL (a string, a balanced
|
|
7731
|
+
* bracket) — it must not reach a grammar-rule ref (`g[name]`), because the
|
|
7732
|
+
* serialized `scanSkip` array sits in the `rules({ scanSkip })` OPTIONS position,
|
|
7733
|
+
* outside the `(g) => …` factory where `g` is bound. A unit that does reference a
|
|
7734
|
+
* rule can't be carried in options; bail to the full-pieces fallback. */
|
|
7735
|
+
assertNoRuleRef(c, seen) {
|
|
7736
|
+
if (seen.has(c)) return;
|
|
7737
|
+
seen.add(c);
|
|
7738
|
+
if (c._def.tag === "lazy") {
|
|
7739
|
+
if (ruleNameOf2(c) !== void 0) throw new Unserializable("scanSkip unit references a grammar rule");
|
|
7740
|
+
const target = lazyTarget(c);
|
|
7741
|
+
if (target) this.assertNoRuleRef(target, seen);
|
|
7742
|
+
return;
|
|
7743
|
+
}
|
|
7744
|
+
for (const child of childrenOf2(c._def)) this.assertNoRuleRef(child, seen);
|
|
7745
|
+
}
|
|
7728
7746
|
/** A `rules()` map wraps each rule value in a named `lazy` proxy; the real body is
|
|
7729
7747
|
* its target (compileLinkable unwraps the same way). A ref INSIDE a body stays a
|
|
7730
7748
|
* `g[name]` ref — only the top-level entry is unwrapped. */
|
|
@@ -7733,21 +7751,38 @@ var Serializer = class {
|
|
|
7733
7751
|
}
|
|
7734
7752
|
run() {
|
|
7735
7753
|
for (const [, c] of this.ruleMap) this.analyze(this.body(c), /* @__PURE__ */ new Set());
|
|
7754
|
+
for (const c of this.scanSkip) {
|
|
7755
|
+
this.assertNoRuleRef(c, /* @__PURE__ */ new Set());
|
|
7756
|
+
this.analyze(c, /* @__PURE__ */ new Set());
|
|
7757
|
+
}
|
|
7736
7758
|
let n = 0;
|
|
7737
7759
|
for (const [c, count] of this.counts) {
|
|
7738
7760
|
if (this.ruleValues.has(c)) continue;
|
|
7739
7761
|
if (count >= 2 || this.selfRef.has(c)) this.constName.set(c, `_s${n++}`);
|
|
7740
7762
|
}
|
|
7763
|
+
const outerDecls = [];
|
|
7764
|
+
const innerDecls = [];
|
|
7765
|
+
let optionsArg = "";
|
|
7766
|
+
if (this.scanSkip.length > 0) {
|
|
7767
|
+
this.decls = outerDecls;
|
|
7768
|
+
const units = this.scanSkip.map((c) => this.ref(c, null));
|
|
7769
|
+
optionsArg = `{ scanSkip: [${units.join(", ")}] }, `;
|
|
7770
|
+
}
|
|
7771
|
+
this.decls = innerDecls;
|
|
7741
7772
|
const body = this.ruleMap.map(([name, c]) => ` ${JSON.stringify(name)}: ${this.wrap(this.body(c))}`).join(",\n");
|
|
7742
|
-
|
|
7773
|
+
const factory = innerDecls.length === 0 ? `(g) => ({
|
|
7743
7774
|
${body}
|
|
7744
|
-
}))
|
|
7745
|
-
|
|
7746
|
-
${this.decls.map((d) => " " + d).join("\n")}
|
|
7775
|
+
})` : `(g) => {
|
|
7776
|
+
${innerDecls.map((d) => " " + d).join("\n")}
|
|
7747
7777
|
return ({
|
|
7748
7778
|
${body}
|
|
7749
7779
|
})
|
|
7750
|
-
}
|
|
7780
|
+
}`;
|
|
7781
|
+
const call = `rules(${optionsArg}${factory})`;
|
|
7782
|
+
return outerDecls.length === 0 ? call : `(() => {
|
|
7783
|
+
${outerDecls.map((d) => " " + d).join("\n")}
|
|
7784
|
+
return ${call}
|
|
7785
|
+
})()`;
|
|
7751
7786
|
}
|
|
7752
7787
|
/** Count identity references and flag self-referential subtrees. `active` is the
|
|
7753
7788
|
* set of combinators on the current DFS path (to detect a lazy pointing back). */
|
|
@@ -8097,7 +8132,8 @@ function itemCarried(item, used, trivia2) {
|
|
|
8097
8132
|
return false;
|
|
8098
8133
|
}
|
|
8099
8134
|
});
|
|
8100
|
-
const
|
|
8135
|
+
const scanSkip = entries.map(([, val]) => val._meta.grammarScanSkip).find(Boolean);
|
|
8136
|
+
const ir = serializeRuleMap(entries, scanSkip);
|
|
8101
8137
|
return ir ? [{ ns, ir }] : [linkable(map, ns, trivia2)];
|
|
8102
8138
|
}
|
|
8103
8139
|
function composingTriviaOf(items) {
|