parseman 0.60.3 → 0.60.4
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/diagnostics.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/compiler/ir-serialize.d.ts +3 -1
- package/dist/compiler/ir-serialize.d.ts.map +1 -1
- package/dist/compiler/linker.d.ts +10 -0
- package/dist/compiler/linker.d.ts.map +1 -1
- package/dist/index.js +28 -15
- package/dist/index.js.map +1 -1
- package/dist/plugin/evaluator.d.ts +8 -0
- package/dist/plugin/evaluator.d.ts.map +1 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +91 -17
- package/dist/plugin/index.js.map +2 -2
- package/dist/table/index.js +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/compiler/ir-serialize.ts +14 -3
- package/src/compiler/linker.ts +28 -12
- package/src/plugin/evaluator.ts +11 -0
- package/src/plugin/index.ts +29 -11
- package/src/version.ts +1 -1
|
@@ -143,6 +143,14 @@ out?: {
|
|
|
143
143
|
* (`parser.ts:228-242`), which the macro's stamp-only copy never did.
|
|
144
144
|
*/
|
|
145
145
|
options?: RulesOptions): Map<string, Combinator<unknown>> | null;
|
|
146
|
+
/**
|
|
147
|
+
* Every EXTERNAL name an evaluated factory read through `g`, keyed by the map
|
|
148
|
+
* `evaluateParserFactory` returned. The map holds declared rules only, so a `g.X`
|
|
149
|
+
* read outside every rule body (`const unused = g.X`) leaves no trace in it; the
|
|
150
|
+
* IR serializer reads this to keep that access, so a composition refuses an `X`
|
|
151
|
+
* nobody defines exactly as runtime `compose()` does.
|
|
152
|
+
*/
|
|
153
|
+
export declare const externalAccesses: WeakMap<ReadonlyMap<string, Combinator<unknown>>, readonly string[]>;
|
|
146
154
|
/** A combinator slot created by ref() — has a callable `define`. */
|
|
147
155
|
type DefinableRef = Combinator<unknown> & {
|
|
148
156
|
define(p: Combinator<unknown>): void;
|
|
@@ -1 +1 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W,EAAE,UAAU,EACvB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EAAE,EAAG,6CAA6C;AACtE,GAAG,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAAG,8DAA8D;AAC1F;;;;;;;;;;;;GAYG;AACH,OAAO,CAAC,EAAE,YAAY,GACrB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CA+IzC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,sEAA6E,CAAA;AAE1G,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,CAiBnF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAyBA,OAAO,WAAW,MAAM,cAAc,CAAA;AActC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAyBA,OAAO,WAAW,MAAM,cAAc,CAAA;AActC,OAAO,EAAs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,WAAW,CAAC,aAAa,CAAC,CAAC,CAAA;IAC3C,kFAAkF;IAClF,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB,CAAA;AA0CD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,aAAa,cAA6B,EAC1C,kBAAkB,UAAQ,EAC1B,QAAQ,UAAQ,EAChB,eAAe,UAAQ,EACvB,eAAe,CAAC,EAAE,eAAe,EACjC,cAAc,SAA0B,EACxC,WAAW,CAAC,EAAE,WAAW,GACxB,oBAAoB,GAAG,IAAI,CAW7B"}
|
package/dist/plugin/index.js
CHANGED
|
@@ -6447,6 +6447,39 @@ function firstSetToString(fs3) {
|
|
|
6447
6447
|
if (fs3.kind === "empty") return "(empty)";
|
|
6448
6448
|
return fs3.ranges.map((r) => r.lo === r.hi ? ch(r.lo) : `${ch(r.lo)}-${ch(r.hi)}`).join(",");
|
|
6449
6449
|
}
|
|
6450
|
+
function ruleDependencies(ruleMap) {
|
|
6451
|
+
const nameOf3 = /* @__PURE__ */ new Map();
|
|
6452
|
+
for (const [name, comb] of ruleMap) nameOf3.set(comb, name);
|
|
6453
|
+
const deps = /* @__PURE__ */ new Map();
|
|
6454
|
+
for (const [name, comb] of ruleMap) {
|
|
6455
|
+
const found = /* @__PURE__ */ new Set();
|
|
6456
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6457
|
+
const walk = (p, isRoot) => {
|
|
6458
|
+
const def = p._def;
|
|
6459
|
+
const boundary = def.tag === "lazy" ? nameOf3.get(p) ?? p._ruleName : nameOf3.get(p);
|
|
6460
|
+
if (!isRoot && boundary !== void 0) {
|
|
6461
|
+
found.add(boundary);
|
|
6462
|
+
return;
|
|
6463
|
+
}
|
|
6464
|
+
if (seen.has(p)) return;
|
|
6465
|
+
seen.add(p);
|
|
6466
|
+
if (def.tag === "lazy") {
|
|
6467
|
+
let resolved;
|
|
6468
|
+
try {
|
|
6469
|
+
resolved = def.thunk();
|
|
6470
|
+
} catch {
|
|
6471
|
+
return;
|
|
6472
|
+
}
|
|
6473
|
+
walk(resolved, false);
|
|
6474
|
+
return;
|
|
6475
|
+
}
|
|
6476
|
+
for (const child of childrenOf2(def)) walk(child, false);
|
|
6477
|
+
};
|
|
6478
|
+
walk(comb, true);
|
|
6479
|
+
deps.set(name, [...found]);
|
|
6480
|
+
}
|
|
6481
|
+
return deps;
|
|
6482
|
+
}
|
|
6450
6483
|
|
|
6451
6484
|
// src/analysis/commitment.ts
|
|
6452
6485
|
function mayFail(p, seen = /* @__PURE__ */ new Set()) {
|
|
@@ -13465,7 +13498,7 @@ function clearOf(ranges, input, from, to) {
|
|
|
13465
13498
|
}
|
|
13466
13499
|
|
|
13467
13500
|
// src/version.ts
|
|
13468
|
-
var PARSEMAN_VERSION = "0.60.
|
|
13501
|
+
var PARSEMAN_VERSION = "0.60.4";
|
|
13469
13502
|
|
|
13470
13503
|
// src/table/assemble.ts
|
|
13471
13504
|
import { PlainBuf as PlainBuf2, PlainField, PlainLeaf as PlainLeaf9, PlainNode as PlainNode2, PlainSpan as PlainSpan10 } from "../cst/plain.js";
|
|
@@ -19472,9 +19505,9 @@ function matcherExpr(entry) {
|
|
|
19472
19505
|
return `matches(${new RegExp(entry.value, entry.flags ?? "").toString()})`;
|
|
19473
19506
|
}
|
|
19474
19507
|
}
|
|
19475
|
-
function serializeRuleMap(ruleMap, scanSkip) {
|
|
19508
|
+
function serializeRuleMap(ruleMap, scanSkip, accessed) {
|
|
19476
19509
|
try {
|
|
19477
|
-
return new Serializer(ruleMap, scanSkip ?? []).run();
|
|
19510
|
+
return new Serializer(ruleMap, scanSkip ?? [], accessed ?? []).run();
|
|
19478
19511
|
} catch (e) {
|
|
19479
19512
|
if (e instanceof Unserializable) {
|
|
19480
19513
|
if (typeof process !== "undefined" && process.env?.PARSEMAN_IR_DEBUG) console.error(`[ir] fallback: ${e.message}`);
|
|
@@ -19499,9 +19532,12 @@ var Serializer = class {
|
|
|
19499
19532
|
localRuleNames = /* @__PURE__ */ new Map();
|
|
19500
19533
|
ruleMap;
|
|
19501
19534
|
scanSkip;
|
|
19502
|
-
|
|
19535
|
+
accessed;
|
|
19536
|
+
referenced = /* @__PURE__ */ new Set();
|
|
19537
|
+
constructor(ruleMap, scanSkip = [], accessed = []) {
|
|
19503
19538
|
this.ruleMap = ruleMap;
|
|
19504
19539
|
this.scanSkip = scanSkip;
|
|
19540
|
+
this.accessed = accessed;
|
|
19505
19541
|
for (const [name, c] of ruleMap) {
|
|
19506
19542
|
this.localRuleNames.set(c, name);
|
|
19507
19543
|
this.ruleValues.add(this.body(c));
|
|
@@ -19577,6 +19613,9 @@ var Serializer = class {
|
|
|
19577
19613
|
}
|
|
19578
19614
|
this.decls = innerDecls;
|
|
19579
19615
|
const body = this.ruleMap.map(([name, c]) => ` ${JSON.stringify(name)}: ${this.wrap(this.body(c), [])}`).join(",\n");
|
|
19616
|
+
for (const name of this.accessed) {
|
|
19617
|
+
if (!this.referenced.has(name)) innerDecls.push(`void g[${JSON.stringify(name)}]`);
|
|
19618
|
+
}
|
|
19580
19619
|
const factory = innerDecls.length === 0 ? `(g) => ({
|
|
19581
19620
|
${body}
|
|
19582
19621
|
})` : `(g) => {
|
|
@@ -19675,7 +19714,10 @@ ${outerDecls.map((d) => " " + d).join("\n")}
|
|
|
19675
19714
|
switch (def.tag) {
|
|
19676
19715
|
case "lazy": {
|
|
19677
19716
|
const name = this.localRuleNames.get(c) ?? ruleNameOf3(c);
|
|
19678
|
-
if (name !== void 0)
|
|
19717
|
+
if (name !== void 0) {
|
|
19718
|
+
this.referenced.add(name);
|
|
19719
|
+
return `g[${JSON.stringify(name)}]`;
|
|
19720
|
+
}
|
|
19679
19721
|
const target = lazyTarget(c);
|
|
19680
19722
|
for (let i = frames.length - 1; i >= 0; i--) {
|
|
19681
19723
|
const f = frames[i];
|
|
@@ -19916,6 +19958,24 @@ function cstBuildHost(typeOrOptions, children3, _fields, span, rawChildren, triv
|
|
|
19916
19958
|
}
|
|
19917
19959
|
cstBuildHost._parsemanCstOutput = true;
|
|
19918
19960
|
var COMPOSED_PIECES = /* @__PURE__ */ Symbol.for("parseman.composedPieces");
|
|
19961
|
+
function danglingReference(map, accessed = []) {
|
|
19962
|
+
const holes = /* @__PURE__ */ new Set();
|
|
19963
|
+
for (const [name, rule] of Object.entries(map)) {
|
|
19964
|
+
if (rule._def.tag !== "lazy") continue;
|
|
19965
|
+
try {
|
|
19966
|
+
rule._def.thunk();
|
|
19967
|
+
} catch {
|
|
19968
|
+
holes.add(name);
|
|
19969
|
+
}
|
|
19970
|
+
}
|
|
19971
|
+
for (const name of accessed) if (!Object.hasOwn(map, name)) holes.add(name);
|
|
19972
|
+
if (holes.size === 0) return void 0;
|
|
19973
|
+
const missing = [...holes];
|
|
19974
|
+
for (const [name, deps] of ruleDependencies(Object.entries(map).filter(([n]) => !holes.has(n)))) {
|
|
19975
|
+
for (const dep of deps) if (holes.has(dep)) return `rule "${name}" references missing rule "${dep}"`;
|
|
19976
|
+
}
|
|
19977
|
+
return `rule(s) ${missing.map((n) => `"${n}"`).join(", ")} are referenced but defined by no composed grammar`;
|
|
19978
|
+
}
|
|
19919
19979
|
|
|
19920
19980
|
// src/cst/trivia-entries.ts
|
|
19921
19981
|
var EMPTY_INDICES = Object.freeze([]);
|
|
@@ -21528,8 +21588,11 @@ function evaluateParserFactory(factoryNode, scope, code, mapFnSources, out, opti
|
|
|
21528
21588
|
}
|
|
21529
21589
|
const map = /* @__PURE__ */ new Map();
|
|
21530
21590
|
for (const key of keys) map.set(key, built[key]);
|
|
21591
|
+
const declared = new Set(keys);
|
|
21592
|
+
externalAccesses.set(map, Object.keys(built).filter((name) => !declared.has(name)));
|
|
21531
21593
|
return map;
|
|
21532
21594
|
}
|
|
21595
|
+
var externalAccesses = /* @__PURE__ */ new WeakMap();
|
|
21533
21596
|
function isDefinableRef2(v) {
|
|
21534
21597
|
return isCombinator3(v) && typeof v.define === "function" && v._def.tag === "lazy";
|
|
21535
21598
|
}
|
|
@@ -22870,6 +22933,17 @@ function corpusTexts(profile) {
|
|
|
22870
22933
|
}
|
|
22871
22934
|
var PARSEMAN_MODULE = "parseman";
|
|
22872
22935
|
var DEFAULT_ASSEMBLY_BUDGET = 0.25;
|
|
22936
|
+
var LinkRefusal = class extends Error {
|
|
22937
|
+
};
|
|
22938
|
+
function isResolved(rule) {
|
|
22939
|
+
if (rule._def.tag !== "lazy") return true;
|
|
22940
|
+
try {
|
|
22941
|
+
rule._def.thunk();
|
|
22942
|
+
return true;
|
|
22943
|
+
} catch {
|
|
22944
|
+
return false;
|
|
22945
|
+
}
|
|
22946
|
+
}
|
|
22873
22947
|
function reasonSuffix(runtimeOnly) {
|
|
22874
22948
|
return runtimeOnly === void 0 || runtimeOnly.length === 0 ? "" : ` \u2014 ${runtimeOnly.join("; ")}`;
|
|
22875
22949
|
}
|
|
@@ -24022,16 +24096,8 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
|
|
|
24022
24096
|
const carriedMaps = carriedRuleMaps(items);
|
|
24023
24097
|
if (carriedMaps === null) return null;
|
|
24024
24098
|
const linked = linkRules(carriedMaps.pieces.flatMap((p) => p.recipes), link);
|
|
24025
|
-
const
|
|
24026
|
-
|
|
24027
|
-
try {
|
|
24028
|
-
rule._def.thunk();
|
|
24029
|
-
return true;
|
|
24030
|
-
} catch {
|
|
24031
|
-
return false;
|
|
24032
|
-
}
|
|
24033
|
-
});
|
|
24034
|
-
return { rules: rules2, trackLines: carriedMaps.trackLines };
|
|
24099
|
+
const dangling = danglingReference(linked);
|
|
24100
|
+
return { rules: Object.entries(linked), trackLines: carriedMaps.trackLines, dangling };
|
|
24035
24101
|
};
|
|
24036
24102
|
const applyComposingTrivia = (ruleMap, composing) => {
|
|
24037
24103
|
for (const [, rule] of ruleMap) {
|
|
@@ -24043,7 +24109,7 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
|
|
|
24043
24109
|
const entries = [...rm];
|
|
24044
24110
|
const ns = nsFor(label2);
|
|
24045
24111
|
const trackLines = entries.some(([, rule]) => rule?._meta?.grammarTrackLines === true);
|
|
24046
|
-
const ir = serializeRuleMap(entries, scanSkip);
|
|
24112
|
+
const ir = serializeRuleMap(entries, scanSkip, rm instanceof Map ? externalAccesses.get(rm) : void 0);
|
|
24047
24113
|
if (ir) return { carried: [{ ns, ir, ...trackLines ? { trackLines: true } : {} }] };
|
|
24048
24114
|
warn(0, `${label2}: rule map could not be serialized to IR, so it cannot be carried for composition. Re-run with PARSEMAN_IR_DEBUG=1 to print the exact combinator that blocked serialization.`);
|
|
24049
24115
|
return null;
|
|
@@ -24130,6 +24196,7 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
|
|
|
24130
24196
|
trivia: composing,
|
|
24131
24197
|
...cHostMode ? { hostMode: cHostMode } : {}
|
|
24132
24198
|
});
|
|
24199
|
+
if (merged?.dangling !== void 0) throw new Error(`${id}:${lineOf(init.start)} \u2014 compose: ${merged.dangling}`);
|
|
24133
24200
|
if (merged !== null) {
|
|
24134
24201
|
collectBuilderImports(merged.rules);
|
|
24135
24202
|
const refusals = [];
|
|
@@ -24266,6 +24333,12 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
|
|
|
24266
24333
|
}
|
|
24267
24334
|
}
|
|
24268
24335
|
const leafMerged = mergeRuleMaps([...carriedMaps.pieces.map((p) => p.rules), localEntries]);
|
|
24336
|
+
const accessed = [
|
|
24337
|
+
...carriedMaps.pieces.flatMap((p) => p.rules).filter(([, rule]) => !isResolved(rule)).map(([name]) => name),
|
|
24338
|
+
...localRules instanceof Map ? externalAccesses.get(localRules) ?? [] : []
|
|
24339
|
+
];
|
|
24340
|
+
const dangling = danglingReference(Object.fromEntries(leafMerged), accessed);
|
|
24341
|
+
if (dangling !== void 0) throw new LinkRefusal(`${id}:${lineOf(init.start)} \u2014 composeLeaf: ${dangling}`);
|
|
24269
24342
|
if (composing) applyComposingTrivia(carriedMaps.pieces.flatMap((p) => p.rules), composing);
|
|
24270
24343
|
const refusals = [];
|
|
24271
24344
|
const compiled = compileRuleMap(
|
|
@@ -24295,6 +24368,7 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
|
|
|
24295
24368
|
warn(init.start, "composeLeaf(): a recognition piece has no re-lowerable IR");
|
|
24296
24369
|
return null;
|
|
24297
24370
|
} catch (e) {
|
|
24371
|
+
if (e instanceof LinkRefusal) throw e;
|
|
24298
24372
|
warn(init.start, `composeLeaf(): ${e.message}`);
|
|
24299
24373
|
return null;
|
|
24300
24374
|
}
|
|
@@ -24400,7 +24474,7 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
|
|
|
24400
24474
|
const source = compiledRules.replacement ?? code.slice(init.start, init.end);
|
|
24401
24475
|
let carriedMetadata;
|
|
24402
24476
|
if (exportPrefix && pieces) {
|
|
24403
|
-
const ir = serializeRuleMap([...compiledRules.ruleMap], compiledRules.scanSkip);
|
|
24477
|
+
const ir = serializeRuleMap([...compiledRules.ruleMap], compiledRules.scanSkip, externalAccesses.get(compiledRules.ruleMap));
|
|
24404
24478
|
if (ir) carriedMetadata = [{ ns, ir, ...compiledRules.trackLines ? { trackLines: true } : {} }];
|
|
24405
24479
|
else warn(init.start, `${varName}: exported grammar could not be serialized to IR, so it carries no composable pieces \u2014 a downstream compose() of this grammar will fall back to runtime. Re-run with PARSEMAN_IR_DEBUG=1 to print the combinator that blocked serialization.`);
|
|
24406
24480
|
if (carriedMetadata !== void 0 && sinkCarried(varName, carriedMetadata)) carriedMetadata = void 0;
|