parseman 0.60.3 → 0.60.5

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.
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import type { Expression, Node } from '@oxc-project/types';
9
9
  import type { Combinator } from '../types.ts';
10
- import { type RulesOptions } from '../combinators/parser.ts';
10
+ import { type RulesOptions, type RulesRecipe } from '../combinators/parser.ts';
11
11
  import type { ReducerResolver } from './reducer-resolver.ts';
12
12
  /** Install (or clear, with `null`) the resolver for the module being transformed. */
13
13
  export declare function setReducerResolver(r: ReducerResolver | null, entrySource?: string | null): void;
@@ -143,6 +143,16 @@ 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
+ /** The recipe an evaluated rule map came from, for a composition that links it. */
147
+ export declare const ruleMapRecipes: WeakMap<ReadonlyMap<string, Combinator<unknown>>, readonly RulesRecipe[]>;
148
+ /**
149
+ * Every EXTERNAL name an evaluated factory read through `g`, keyed by the map
150
+ * `evaluateParserFactory` returned. The map holds declared rules only, so a `g.X`
151
+ * read outside every rule body (`const unused = g.X`) leaves no trace in it; the
152
+ * IR serializer reads this to keep that access, so a composition refuses an `X`
153
+ * nobody defines exactly as runtime `compose()` does.
154
+ */
155
+ export declare const externalAccesses: WeakMap<ReadonlyMap<string, Combinator<unknown>>, readonly string[]>;
146
156
  /** A combinator slot created by ref() — has a callable `define`. */
147
157
  type DefinableRef = Combinator<unknown> & {
148
158
  define(p: Combinator<unknown>): void;
@@ -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,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DefinableRef(v) {
1927
1927
  return !!v && typeof v === "object" && "_def" in v && v._def.tag === "lazy" && typeof v.define === "function";
1928
1928
  }
1929
+ function priorNameOf(r) {
1930
+ return r._priorOf;
1931
+ }
1929
1932
  function ruleNameOf(r) {
1930
1933
  return r._ruleName;
1931
1934
  }
1932
1935
  function isNamedRuleRefForAnotherRule(r, key) {
1933
- const name = r._def.tag === "lazy" ? ruleNameOf(r) : void 0;
1936
+ if (r._def.tag !== "lazy") return false;
1937
+ if (priorNameOf(r) !== void 0) return true;
1938
+ const name = ruleNameOf(r);
1934
1939
  return name !== void 0 && name !== key;
1935
1940
  }
1936
1941
  var claimedRules = /* @__PURE__ */ new WeakSet();
@@ -1943,6 +1948,20 @@ function ownRule(p, copies) {
1943
1948
  }
1944
1949
  return own;
1945
1950
  }
1951
+ var priorUnfilled = (key) => new Error(`compose: prior.${key} is read, but no grammar composed before it defines "${key}"`);
1952
+ function priorHole(key) {
1953
+ const unfilled = priorUnfilled(key);
1954
+ const fail = () => {
1955
+ throw unfilled;
1956
+ };
1957
+ return {
1958
+ _tag: "lazy",
1959
+ _meta: { firstSet: any(), canMatchNewline: true, isTrivia: false },
1960
+ _def: { tag: "lazy", thunk: fail },
1961
+ parse: fail,
1962
+ _priorOf: key
1963
+ };
1964
+ }
1946
1965
  function rules(a, b) {
1947
1966
  const factory = typeof a === "function" ? a : b;
1948
1967
  const options = typeof a === "function" ? b : a;
@@ -1967,8 +1986,20 @@ function linkRules(recipes, link) {
1967
1986
  }
1968
1987
  });
1969
1988
  const winners = /* @__PURE__ */ new Map();
1989
+ const priorHoles = /* @__PURE__ */ new Map();
1990
+ const prior = new Proxy({}, {
1991
+ get(_target, key) {
1992
+ if (typeof key !== "string") return void 0;
1993
+ const earlier = winners.get(key)?.parser;
1994
+ if (earlier !== void 0) return earlier._def.tag === "node" ? earlier._def.parser : earlier;
1995
+ if (link !== void 0) throw priorUnfilled(key);
1996
+ let hole = priorHoles.get(key);
1997
+ if (hole === void 0) priorHoles.set(key, hole = priorHole(key));
1998
+ return hole;
1999
+ }
2000
+ });
1970
2001
  for (const recipe of recipes) {
1971
- const definitions = recipe.factory(proxy);
2002
+ const definitions = recipe.factory(proxy, prior);
1972
2003
  for (const key of Object.keys(definitions)) {
1973
2004
  winners.set(key, { parser: definitions[key], options: recipe.options });
1974
2005
  }
@@ -6447,6 +6478,39 @@ function firstSetToString(fs3) {
6447
6478
  if (fs3.kind === "empty") return "(empty)";
6448
6479
  return fs3.ranges.map((r) => r.lo === r.hi ? ch(r.lo) : `${ch(r.lo)}-${ch(r.hi)}`).join(",");
6449
6480
  }
6481
+ function ruleDependencies(ruleMap) {
6482
+ const nameOf3 = /* @__PURE__ */ new Map();
6483
+ for (const [name, comb] of ruleMap) nameOf3.set(comb, name);
6484
+ const deps = /* @__PURE__ */ new Map();
6485
+ for (const [name, comb] of ruleMap) {
6486
+ const found = /* @__PURE__ */ new Set();
6487
+ const seen = /* @__PURE__ */ new Set();
6488
+ const walk = (p, isRoot) => {
6489
+ const def = p._def;
6490
+ const boundary = def.tag === "lazy" ? nameOf3.get(p) ?? p._ruleName : nameOf3.get(p);
6491
+ if (!isRoot && boundary !== void 0) {
6492
+ found.add(boundary);
6493
+ return;
6494
+ }
6495
+ if (seen.has(p)) return;
6496
+ seen.add(p);
6497
+ if (def.tag === "lazy") {
6498
+ let resolved;
6499
+ try {
6500
+ resolved = def.thunk();
6501
+ } catch {
6502
+ return;
6503
+ }
6504
+ walk(resolved, false);
6505
+ return;
6506
+ }
6507
+ for (const child of childrenOf2(def)) walk(child, false);
6508
+ };
6509
+ walk(comb, true);
6510
+ deps.set(name, [...found]);
6511
+ }
6512
+ return deps;
6513
+ }
6450
6514
 
6451
6515
  // src/analysis/commitment.ts
6452
6516
  function mayFail(p, seen = /* @__PURE__ */ new Set()) {
@@ -6901,7 +6965,8 @@ function classifyRuleMap(ruleMap) {
6901
6965
  resolved = void 0;
6902
6966
  }
6903
6967
  if (resolved === void 0) {
6904
- if (p._ruleName) externalRefs.add(p);
6968
+ const hole = p;
6969
+ if (hole._ruleName !== void 0 || hole._priorOf !== void 0) externalRefs.add(p);
6905
6970
  return;
6906
6971
  }
6907
6972
  scanExternal(resolved);
@@ -13465,7 +13530,7 @@ function clearOf(ranges, input, from, to) {
13465
13530
  }
13466
13531
 
13467
13532
  // src/version.ts
13468
- var PARSEMAN_VERSION = "0.60.3";
13533
+ var PARSEMAN_VERSION = "0.60.5";
13469
13534
 
13470
13535
  // src/table/assemble.ts
13471
13536
  import { PlainBuf as PlainBuf2, PlainField, PlainLeaf as PlainLeaf9, PlainNode as PlainNode2, PlainSpan as PlainSpan10 } from "../cst/plain.js";
@@ -17629,7 +17694,7 @@ function buildGrammarPlan(entry, winners) {
17629
17694
  const dispatches = /* @__PURE__ */ new Map();
17630
17695
  const attempts = /* @__PURE__ */ new Map();
17631
17696
  const labels = /* @__PURE__ */ new Map();
17632
- const rules2 = /* @__PURE__ */ new Map();
17697
+ const rules3 = /* @__PURE__ */ new Map();
17633
17698
  const winnerNames = /* @__PURE__ */ new Map();
17634
17699
  if (winners) {
17635
17700
  for (const [name, winner] of Object.entries(winners)) {
@@ -17663,7 +17728,7 @@ function buildGrammarPlan(entry, winners) {
17663
17728
  const ownRule2 = (parser2, rule) => {
17664
17729
  const id = `rule:${rule}`;
17665
17730
  definitions.set(id, { id, kind: "rule" });
17666
- rules2.set(parser2, id);
17731
+ rules3.set(parser2, id);
17667
17732
  };
17668
17733
  const seen = /* @__PURE__ */ new Set();
17669
17734
  const visit = (parser2, path3) => {
@@ -17703,7 +17768,7 @@ function buildGrammarPlan(entry, winners) {
17703
17768
  }
17704
17769
  visit(body ?? root, name);
17705
17770
  }
17706
- return { definitions: [...definitions.values()].sort((a, b) => a.id.localeCompare(b.id)), choices, dispatches, attempts, labels, rules: rules2 };
17771
+ return { definitions: [...definitions.values()].sort((a, b) => a.id.localeCompare(b.id)), choices, dispatches, attempts, labels, rules: rules3 };
17707
17772
  }
17708
17773
 
17709
17774
  // src/analysis/duplication.ts
@@ -19472,9 +19537,9 @@ function matcherExpr(entry) {
19472
19537
  return `matches(${new RegExp(entry.value, entry.flags ?? "").toString()})`;
19473
19538
  }
19474
19539
  }
19475
- function serializeRuleMap(ruleMap, scanSkip) {
19540
+ function serializeRuleMap(ruleMap, scanSkip, accessed) {
19476
19541
  try {
19477
- return new Serializer(ruleMap, scanSkip ?? []).run();
19542
+ return new Serializer(ruleMap, scanSkip ?? [], accessed ?? []).run();
19478
19543
  } catch (e) {
19479
19544
  if (e instanceof Unserializable) {
19480
19545
  if (typeof process !== "undefined" && process.env?.PARSEMAN_IR_DEBUG) console.error(`[ir] fallback: ${e.message}`);
@@ -19499,9 +19564,14 @@ var Serializer = class {
19499
19564
  localRuleNames = /* @__PURE__ */ new Map();
19500
19565
  ruleMap;
19501
19566
  scanSkip;
19502
- constructor(ruleMap, scanSkip = []) {
19567
+ /** Whether any rule reads a `prior.X` hole, so the factory takes `(g, prior)`. */
19568
+ usesPrior = false;
19569
+ accessed;
19570
+ referenced = /* @__PURE__ */ new Set();
19571
+ constructor(ruleMap, scanSkip = [], accessed = []) {
19503
19572
  this.ruleMap = ruleMap;
19504
19573
  this.scanSkip = scanSkip;
19574
+ this.accessed = accessed;
19505
19575
  for (const [name, c] of ruleMap) {
19506
19576
  this.localRuleNames.set(c, name);
19507
19577
  this.ruleValues.add(this.body(c));
@@ -19516,7 +19586,7 @@ var Serializer = class {
19516
19586
  if (seen.has(c)) return;
19517
19587
  seen.add(c);
19518
19588
  if (c._def.tag === "lazy") {
19519
- if (ruleNameOf3(c) !== void 0) throw new Unserializable("scanSkip unit references a grammar rule");
19589
+ if (ruleNameOf3(c) !== void 0 || priorNameOf(c) !== void 0) throw new Unserializable("scanSkip unit references a grammar rule");
19520
19590
  const target = lazyTarget(c);
19521
19591
  if (target) this.assertNoRuleRef(target, seen);
19522
19592
  return;
@@ -19577,9 +19647,13 @@ var Serializer = class {
19577
19647
  }
19578
19648
  this.decls = innerDecls;
19579
19649
  const body = this.ruleMap.map(([name, c]) => ` ${JSON.stringify(name)}: ${this.wrap(this.body(c), [])}`).join(",\n");
19580
- const factory = innerDecls.length === 0 ? `(g) => ({
19650
+ for (const name of this.accessed) {
19651
+ if (!this.referenced.has(name)) innerDecls.push(`void g[${JSON.stringify(name)}]`);
19652
+ }
19653
+ const params = this.usesPrior ? "(g, prior)" : "(g)";
19654
+ const factory = innerDecls.length === 0 ? `${params} => ({
19581
19655
  ${body}
19582
- })` : `(g) => {
19656
+ })` : `${params} => {
19583
19657
  ${innerDecls.map((d) => " " + d).join("\n")}
19584
19658
  return ({
19585
19659
  ${body}
@@ -19596,6 +19670,10 @@ ${outerDecls.map((d) => " " + d).join("\n")}
19596
19670
  analyze(c, active) {
19597
19671
  const def = c._def;
19598
19672
  if (def.tag === "lazy") {
19673
+ if (priorNameOf(c) !== void 0) {
19674
+ this.usesPrior = true;
19675
+ return;
19676
+ }
19599
19677
  if (ruleNameOf3(c) !== void 0) return;
19600
19678
  const target = lazyTarget(c);
19601
19679
  if (!target) throw new Unserializable("unresolved unnamed ref");
@@ -19674,8 +19752,13 @@ ${outerDecls.map((d) => " " + d).join("\n")}
19674
19752
  }
19675
19753
  switch (def.tag) {
19676
19754
  case "lazy": {
19755
+ const prior = priorNameOf(c);
19756
+ if (prior !== void 0) return `prior[${JSON.stringify(prior)}]`;
19677
19757
  const name = this.localRuleNames.get(c) ?? ruleNameOf3(c);
19678
- if (name !== void 0) return `g[${JSON.stringify(name)}]`;
19758
+ if (name !== void 0) {
19759
+ this.referenced.add(name);
19760
+ return `g[${JSON.stringify(name)}]`;
19761
+ }
19679
19762
  const target = lazyTarget(c);
19680
19763
  for (let i = frames.length - 1; i >= 0; i--) {
19681
19764
  const f = frames[i];
@@ -19851,7 +19934,8 @@ function externalNames(ruleMap) {
19851
19934
  resolved = void 0;
19852
19935
  }
19853
19936
  if (resolved === void 0) {
19854
- const name = p._ruleName;
19937
+ const prior = priorNameOf(p);
19938
+ const name = prior === void 0 ? p._ruleName : `prior.${prior}`;
19855
19939
  if (name !== void 0 && !out.includes(name)) out.push(name);
19856
19940
  return;
19857
19941
  }
@@ -19916,6 +20000,24 @@ function cstBuildHost(typeOrOptions, children3, _fields, span, rawChildren, triv
19916
20000
  }
19917
20001
  cstBuildHost._parsemanCstOutput = true;
19918
20002
  var COMPOSED_PIECES = /* @__PURE__ */ Symbol.for("parseman.composedPieces");
20003
+ function danglingReference(map, accessed = []) {
20004
+ const holes = /* @__PURE__ */ new Set();
20005
+ for (const [name, rule] of Object.entries(map)) {
20006
+ if (rule._def.tag !== "lazy") continue;
20007
+ try {
20008
+ rule._def.thunk();
20009
+ } catch {
20010
+ holes.add(name);
20011
+ }
20012
+ }
20013
+ for (const name of accessed) if (!Object.hasOwn(map, name)) holes.add(name);
20014
+ if (holes.size === 0) return void 0;
20015
+ const missing = [...holes];
20016
+ for (const [name, deps] of ruleDependencies(Object.entries(map).filter(([n]) => !holes.has(n)))) {
20017
+ for (const dep of deps) if (holes.has(dep)) return `rule "${name}" references missing rule "${dep}"`;
20018
+ }
20019
+ return `rule(s) ${missing.map((n) => `"${n}"`).join(", ")} are referenced but defined by no composed grammar`;
20020
+ }
19919
20021
 
19920
20022
  // src/cst/trivia-entries.ts
19921
20023
  var EMPTY_INDICES = Object.freeze([]);
@@ -21472,10 +21574,15 @@ function evaluateParserFactory(factoryNode, scope, code, mapFnSources, out, opti
21472
21574
  if (factoryNode.type !== "ArrowFunctionExpression" && factoryNode.type !== "FunctionDeclaration" && factoryNode.type !== "FunctionExpression") return null;
21473
21575
  const factory = factoryNode;
21474
21576
  const params = factory.params;
21475
- if (params.length !== 1) return null;
21476
- const param = params[0];
21477
- const proxyName = param.type === "Identifier" ? param.name ?? null : null;
21577
+ if (params.length !== 1 && params.length !== 2) return null;
21578
+ const paramName = (param) => {
21579
+ const p = param;
21580
+ return p.type === "Identifier" ? p.name ?? null : null;
21581
+ };
21582
+ const proxyName = paramName(params[0]);
21478
21583
  if (!proxyName) return null;
21584
+ const priorName = params.length === 2 ? paramName(params[1]) : void 0;
21585
+ if (priorName === null) return null;
21479
21586
  const body = factory.body;
21480
21587
  if (!body) return null;
21481
21588
  const statements = [];
@@ -21505,9 +21612,10 @@ function evaluateParserFactory(factoryNode, scope, code, mapFnSources, out, opti
21505
21612
  const ABORT = /* @__PURE__ */ Symbol("parseman: factory not statically evaluable");
21506
21613
  let built;
21507
21614
  try {
21508
- built = rules(options ?? {}, (g) => {
21615
+ built = rules(options ?? {}, (g, prior) => {
21509
21616
  const localScope = scope instanceof ModuleScope ? scope.fork() : new Map(scope);
21510
21617
  localScope.set(proxyName, g);
21618
+ if (priorName !== void 0) localScope.set(priorName, prior);
21511
21619
  if (!evalBodyStatements(statements, localScope, code, out)) throw ABORT;
21512
21620
  const entries = flattenRuleEntries(retObj, localScope, code);
21513
21621
  if (!entries) throw ABORT;
@@ -21528,8 +21636,13 @@ function evaluateParserFactory(factoryNode, scope, code, mapFnSources, out, opti
21528
21636
  }
21529
21637
  const map = /* @__PURE__ */ new Map();
21530
21638
  for (const key of keys) map.set(key, built[key]);
21639
+ const declared = new Set(keys);
21640
+ externalAccesses.set(map, Object.keys(built).filter((name) => !declared.has(name)));
21641
+ ruleMapRecipes.set(map, built[RULES_RECIPE]);
21531
21642
  return map;
21532
21643
  }
21644
+ var ruleMapRecipes = /* @__PURE__ */ new WeakMap();
21645
+ var externalAccesses = /* @__PURE__ */ new WeakMap();
21533
21646
  function isDefinableRef2(v) {
21534
21647
  return isCombinator3(v) && typeof v.define === "function" && v._def.tag === "lazy";
21535
21648
  }
@@ -22870,6 +22983,8 @@ function corpusTexts(profile) {
22870
22983
  }
22871
22984
  var PARSEMAN_MODULE = "parseman";
22872
22985
  var DEFAULT_ASSEMBLY_BUDGET = 0.25;
22986
+ var LinkRefusal = class extends Error {
22987
+ };
22873
22988
  function reasonSuffix(runtimeOnly) {
22874
22989
  return runtimeOnly === void 0 || runtimeOnly.length === 0 ? "" : ` \u2014 ${runtimeOnly.join("; ")}`;
22875
22990
  }
@@ -24002,48 +24117,18 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
24002
24117
  }
24003
24118
  return { pieces, trackLines };
24004
24119
  };
24005
- const mergeRuleMaps = (maps) => {
24006
- const winners = /* @__PURE__ */ new Map();
24007
- for (const map of maps) {
24008
- for (const [name, rule] of map) {
24009
- if (rule._def.tag === "lazy") {
24010
- try {
24011
- rule._def.thunk();
24012
- } catch {
24013
- continue;
24014
- }
24015
- }
24016
- winners.set(name, rule);
24017
- }
24018
- }
24019
- return [...winners];
24020
- };
24021
24120
  const mergedCarriedRules = (items, link) => {
24022
24121
  const carriedMaps = carriedRuleMaps(items);
24023
24122
  if (carriedMaps === null) return null;
24024
24123
  const linked = linkRules(carriedMaps.pieces.flatMap((p) => p.recipes), link);
24025
- const rules2 = Object.entries(linked).filter(([, rule]) => {
24026
- if (rule._def.tag !== "lazy") return true;
24027
- try {
24028
- rule._def.thunk();
24029
- return true;
24030
- } catch {
24031
- return false;
24032
- }
24033
- });
24034
- return { rules: rules2, trackLines: carriedMaps.trackLines };
24035
- };
24036
- const applyComposingTrivia = (ruleMap, composing) => {
24037
- for (const [, rule] of ruleMap) {
24038
- if (rule._meta.isTrivia) continue;
24039
- rule._meta.grammarTrivia = composing;
24040
- }
24124
+ const dangling = danglingReference(linked);
24125
+ return { rules: Object.entries(linked), trackLines: carriedMaps.trackLines, dangling };
24041
24126
  };
24042
24127
  const localCarried = (rm, label2, composing, scanSkip) => {
24043
24128
  const entries = [...rm];
24044
24129
  const ns = nsFor(label2);
24045
24130
  const trackLines = entries.some(([, rule]) => rule?._meta?.grammarTrackLines === true);
24046
- const ir = serializeRuleMap(entries, scanSkip);
24131
+ const ir = serializeRuleMap(entries, scanSkip, rm instanceof Map ? externalAccesses.get(rm) : void 0);
24047
24132
  if (ir) return { carried: [{ ns, ir, ...trackLines ? { trackLines: true } : {} }] };
24048
24133
  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
24134
  return null;
@@ -24126,10 +24211,16 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
24126
24211
  carried.push(...r.carried);
24127
24212
  importedFactories.push(...r.importedFactories ?? []);
24128
24213
  }
24129
- const merged = mergedCarriedRules(carried, {
24130
- trivia: composing,
24131
- ...cHostMode ? { hostMode: cHostMode } : {}
24132
- });
24214
+ let merged;
24215
+ try {
24216
+ merged = mergedCarriedRules(carried, {
24217
+ trivia: composing,
24218
+ ...cHostMode ? { hostMode: cHostMode } : {}
24219
+ });
24220
+ } catch (e) {
24221
+ throw new Error(`${id}:${lineOf(init.start)} \u2014 ${e.message}`, { cause: e });
24222
+ }
24223
+ if (merged?.dangling !== void 0) throw new Error(`${id}:${lineOf(init.start)} \u2014 compose: ${merged.dangling}`);
24133
24224
  if (merged !== null) {
24134
24225
  collectBuilderImports(merged.rules);
24135
24226
  const refusals = [];
@@ -24189,8 +24280,8 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
24189
24280
  const type = fn?.[INERT_BUILDER];
24190
24281
  return type === void 0 ? fn : (children3, _fields, span) => ({ type, span, children: children3 });
24191
24282
  });
24192
- const counts = countSiteVisits(compiled.prog, (rules2) => {
24193
- const entry = rules2[assemblyProfile.entry];
24283
+ const counts = countSiteVisits(compiled.prog, (rules3) => {
24284
+ const entry = rules3[assemblyProfile.entry];
24194
24285
  for (const text of corpusTexts(assemblyProfile)) {
24195
24286
  try {
24196
24287
  if (run(entry, text).ok) parsed++;
@@ -24217,17 +24308,14 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
24217
24308
  }
24218
24309
  const localArg = elements[elements.length - 1];
24219
24310
  let localRules = null;
24220
- let localScanSkip;
24221
24311
  const importedFactories = [];
24222
24312
  if (isRulesCall(localArg)) {
24223
24313
  const evaluated = evaluateRulesFactory(localArg, `composeLeaf${init.start}`);
24224
24314
  localRules = evaluated?.ruleMap ?? null;
24225
- localScanSkip = evaluated?.scanSkip;
24226
24315
  if (evaluated?.importedFactory) importedFactories.push(evaluated.importedFactory);
24227
24316
  } else if (localArg.type === "Identifier") {
24228
24317
  const name = localArg.name;
24229
24318
  localRules = localRuleMaps.get(name) ?? null;
24230
- localScanSkip = localGrammarScanSkip.get(name);
24231
24319
  }
24232
24320
  if (!localRules) {
24233
24321
  const named = localArg.type === "Identifier" ? localArg.name : null;
@@ -24246,8 +24334,6 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
24246
24334
  importedFactories.push(...r.importedFactories ?? []);
24247
24335
  }
24248
24336
  try {
24249
- const localNs = nsFor(`composeLeaf${init.start}`);
24250
- const localEntries = [...localRules];
24251
24337
  const carriedMaps = carriedRuleMaps(carried);
24252
24338
  if (carriedMaps !== null) {
24253
24339
  const unproven = carriedMaps.pieces.find((p) => {
@@ -24258,18 +24344,20 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
24258
24344
  warn(init.start, "composeLeaf(): every pre-final grammar must explicitly prove recognition-only");
24259
24345
  return null;
24260
24346
  }
24261
- if (localScanSkip) {
24262
- for (const [, rule] of localEntries) {
24263
- if (rule._meta.isTrivia) continue;
24264
- const meta = rule._meta;
24265
- if (meta.grammarScanSkip === void 0) meta.grammarScanSkip = localScanSkip;
24266
- }
24347
+ let linked;
24348
+ try {
24349
+ linked = linkRules(
24350
+ [...carriedMaps.pieces.flatMap((p) => p.recipes), ...ruleMapRecipes.get(localRules)],
24351
+ { trivia: composing }
24352
+ );
24353
+ } catch (e) {
24354
+ throw new LinkRefusal(`${id}:${lineOf(init.start)} \u2014 composeLeaf: ${e.message.replace(/^compose: /, "")}`, { cause: e });
24267
24355
  }
24268
- const leafMerged = mergeRuleMaps([...carriedMaps.pieces.map((p) => p.rules), localEntries]);
24269
- if (composing) applyComposingTrivia(carriedMaps.pieces.flatMap((p) => p.rules), composing);
24356
+ const dangling = danglingReference(linked);
24357
+ if (dangling !== void 0) throw new LinkRefusal(`${id}:${lineOf(init.start)} \u2014 composeLeaf: ${dangling}`);
24270
24358
  const refusals = [];
24271
24359
  const compiled = compileRuleMap(
24272
- leafMerged,
24360
+ Object.entries(linked),
24273
24361
  {
24274
24362
  ...composing ? { trivia: composing } : {},
24275
24363
  ...carriedMaps.trackLines ? { trackLines: true } : {},
@@ -24295,6 +24383,7 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
24295
24383
  warn(init.start, "composeLeaf(): a recognition piece has no re-lowerable IR");
24296
24384
  return null;
24297
24385
  } catch (e) {
24386
+ if (e instanceof LinkRefusal) throw e;
24298
24387
  warn(init.start, `composeLeaf(): ${e.message}`);
24299
24388
  return null;
24300
24389
  }
@@ -24400,7 +24489,7 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
24400
24489
  const source = compiledRules.replacement ?? code.slice(init.start, init.end);
24401
24490
  let carriedMetadata;
24402
24491
  if (exportPrefix && pieces) {
24403
- const ir = serializeRuleMap([...compiledRules.ruleMap], compiledRules.scanSkip);
24492
+ const ir = serializeRuleMap([...compiledRules.ruleMap], compiledRules.scanSkip, externalAccesses.get(compiledRules.ruleMap));
24404
24493
  if (ir) carriedMetadata = [{ ns, ir, ...compiledRules.trackLines ? { trackLines: true } : {} }];
24405
24494
  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
24495
  if (carriedMetadata !== void 0 && sinkCarried(varName, carriedMetadata)) carriedMetadata = void 0;