parseman 0.60.2 → 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.
Files changed (40) hide show
  1. package/dist/analysis/commitment.d.ts +1 -1
  2. package/dist/analysis/commitment.d.ts.map +1 -1
  3. package/dist/analysis/diagnostics.js +128 -43
  4. package/dist/analysis/diagnostics.js.map +2 -2
  5. package/dist/cli/index.js +128 -43
  6. package/dist/cli/index.js.map +2 -2
  7. package/dist/compiler/ir-serialize.d.ts +3 -1
  8. package/dist/compiler/ir-serialize.d.ts.map +1 -1
  9. package/dist/compiler/linker.d.ts +10 -0
  10. package/dist/compiler/linker.d.ts.map +1 -1
  11. package/dist/index.js +155 -57
  12. package/dist/index.js.map +2 -2
  13. package/dist/plugin/evaluator.d.ts +8 -0
  14. package/dist/plugin/evaluator.d.ts.map +1 -1
  15. package/dist/plugin/index.d.ts.map +1 -1
  16. package/dist/plugin/index.js +218 -59
  17. package/dist/plugin/index.js.map +2 -2
  18. package/dist/table/assemble.d.ts +11 -0
  19. package/dist/table/assemble.d.ts.map +1 -1
  20. package/dist/table/emit-assembly.d.ts +1 -0
  21. package/dist/table/emit-assembly.d.ts.map +1 -1
  22. package/dist/table/encode.d.ts.map +1 -1
  23. package/dist/table/exec.d.ts.map +1 -1
  24. package/dist/table/index.js +128 -43
  25. package/dist/table/index.js.map +2 -2
  26. package/dist/table/program.d.ts +9 -0
  27. package/dist/table/program.d.ts.map +1 -1
  28. package/dist/version.d.ts +1 -1
  29. package/package.json +1 -1
  30. package/src/analysis/commitment.ts +29 -15
  31. package/src/compiler/ir-serialize.ts +14 -3
  32. package/src/compiler/linker.ts +28 -12
  33. package/src/plugin/evaluator.ts +11 -0
  34. package/src/plugin/index.ts +29 -11
  35. package/src/table/assemble.ts +35 -10
  36. package/src/table/emit-assembly.ts +41 -11
  37. package/src/table/encode.ts +57 -9
  38. package/src/table/exec.ts +5 -2
  39. package/src/table/program.ts +19 -0
  40. package/src/version.ts +1 -1
@@ -448,6 +448,8 @@ export declare function ownTableProgram(prog: TableProgram, resolved?: ResolvedT
448
448
  readonly choiceRollbackMasks?: ReadonlyMap<number, number>;
449
449
  readonly failureRollbackCleanSites?: ReadonlySet<number>;
450
450
  readonly nonCommittingChoiceSites?: ReadonlySet<number>;
451
+ readonly choiceLogRollbackMasks?: ReadonlyMap<number, number>;
452
+ readonly failureLogRollbackSites?: ReadonlySet<number>;
451
453
  }): TableProgram;
452
454
  /** Compiler-only choice rollback authority, consumed while printing a static
453
455
  * assembly and never serialized into the shipped table. */
@@ -459,6 +461,13 @@ export declare function choiceCannotCommit(prog: TableProgram, ip: number): bool
459
461
  * capture, trivia, field, or error sink. Static assembly consumes it to omit the
460
462
  * enclosing mark and rollback; it is never serialized into the shipped table. */
461
463
  export declare function failureRollbackClean(prog: TableProgram, ip: number): boolean;
464
+ /** The arms of the choice at `ip` the census counts as clean whose failure can
465
+ * still leave trivia-log rows: a node they reach fails after recording trivia
466
+ * (`encode.ts` `choiceLogRollbackMasks`). Zero without that authority. */
467
+ export declare function choiceLogRollbackMask(prog: TableProgram, ip: number): number;
468
+ /** An `optional()` or `attempt()` row `failureRollbackClean` admits whose failed
469
+ * child can still leave trivia-log rows, for the same reason. */
470
+ export declare function failureLogRollback(prog: TableProgram, ip: number): boolean;
462
471
  /** A compiled entry, shaped exactly like a codegen rule function. */
463
472
  export type TableRule = (input: string, pos: number, ctx: ParseContext) => ParseResult<unknown>;
464
473
  /** Encode consecutive `[lo, hi]` code-point pairs without truncating astral endpoints. */
@@ -1 +1 @@
1
- {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../src/table/program.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAExE,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAKzF,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAA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AG,KAAK,CAAA;KAAE,CAAC,CAAC,CAAA;CACrH,CAAA;AAED;;;;GAIG;AACH,QAAA,MAAM,aAAa,iLAYiC,CAAA;AAEpD;;;;;;;;;;GAUG;AACH;;;;;;;;GAQG;AACH,KAAK,WAAW,GAAG,KAAK,CAAA;AACxB,KAAK,cAAc,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAA;AAC1G,KAAK,WAAW,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC,CAAA;AACrC,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,OAAO,CAAC,MAAM,YAAY,EAAE,cAAc,CAAC,CAAC,CAAA;AAErF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,EAChD,QAAQ,EAAE,MAAM,GACf,aAAa,CAwEf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CA6B/E;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,aAAa,GAAG,aAAa,CAWnE"}
package/dist/version.d.ts CHANGED
@@ -13,5 +13,5 @@
13
13
  * Kept in sync with `package.json` by `test/unit/version-sync.test.ts`, which fails
14
14
  * the build if this constant drifts from the published version.
15
15
  */
16
- export declare const PARSEMAN_VERSION = "0.60.2";
16
+ export declare const PARSEMAN_VERSION = "0.60.4";
17
17
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "parseman",
3
- "version": "0.60.2",
3
+ "version": "0.60.4",
4
4
  "packageManager": "pnpm@10.15.1",
5
5
  "engines": {
6
6
  "node": "^20.19.0 || >=22.13.0"
@@ -186,7 +186,10 @@ export function alwaysConsumes(p: Combinator<unknown>, seen: Set<Combinator<unkn
186
186
  * internally. optional/many never "fail" with partial output. Delegating
187
187
  * wrappers (transform/label/grammar/withCtx/expect) pass through to inner.
188
188
  */
189
- export function mayLeavePartialCapture(p: Combinator<unknown>, seen: Set<Combinator<unknown>> = new Set(), triviaActive = true): boolean {
189
+ export function mayLeavePartialCapture(
190
+ p: Combinator<unknown>, seen: Set<Combinator<unknown>> = new Set(), triviaActive = true,
191
+ throughNodes: boolean | ((choice: Combinator<unknown>) => boolean) = false,
192
+ ): boolean {
190
193
  if (seen.has(p)) return false
191
194
  seen.add(p)
192
195
  const d = p._def
@@ -211,15 +214,26 @@ export function mayLeavePartialCapture(p: Combinator<unknown>, seen: Set<Combina
211
214
  return false
212
215
  // A run's prefixes are probed detached; only its body can capture.
213
216
  case 'lines':
214
- return mayLeavePartialCapture(d.body, seen, triviaActive)
215
- // node() captures into its own private buffers and rolls them back on
216
- // failure (emitNode restores _ctx.* and never pushes on the !ok path).
217
+ return mayLeavePartialCapture(d.body, seen, triviaActive, throughNodes)
218
+ // node() captures its children into a frame of its own and drops it on
219
+ // failure. The trivia logs (`_triviaLog`, `_rootTriviaLog`) are not part of
220
+ // that frame: trivia its body scanned before failing stays recorded. With
221
+ // `throughNodes` (a program that installs trivia somewhere) a node leaves
222
+ // what its body leaves; without, it leaves nothing.
217
223
  case 'node':
218
- return false
219
- // choice/firstMatch already roll back each failed arm; on overall failure
220
- // nothing committed remains.
224
+ return throughNodes && mayLeavePartialCapture(d.parser, seen, triviaActive, throughNodes)
225
+ // choice/firstMatch already roll back each failed arm's captures; on overall
226
+ // failure nothing committed remains. The trivia logs are the exception: a
227
+ // choice the table lowers as an exclusive dispatch runs its one selected arm
228
+ // with no mark of its own (`emit-assembly.ts`, `table.exclusive`), so the
229
+ // rows that arm's trivia scans recorded stay when it fails. With
230
+ // `throughNodes` a choice leaves what one of its arms leaves, unless
231
+ // `throughNodes` is the encoder's answer that this choice marks and restores
232
+ // each arm it enters.
221
233
  case 'choice':
222
- return false
234
+ return throughNodes !== false
235
+ && !(typeof throughNodes === 'function' && throughNodes(p))
236
+ && d.parsers.some(arm => mayLeavePartialCapture(arm, new Set(seen), triviaActive, throughNodes))
223
237
  case 'dispatch':
224
238
  // These are independent graph predicates. Sharing one mutable `seen` set
225
239
  // between them made the first walk hide the arm from the second: an atomic
@@ -228,9 +242,9 @@ export function mayLeavePartialCapture(p: Combinator<unknown>, seen: Set<Combina
228
242
  // Fork the ancestor set for each proof so cycle protection remains, while
229
243
  // one proof cannot erase evidence needed by another.
230
244
  return capturesLeaf(d.selector, new Set(seen)) ||
231
- d.cases.some(x => mayLeavePartialCapture(x.parser, new Set(seen), triviaActive) || capturesLeaf(x.parser, new Set(seen))) ||
232
- (d.matchers ? d.matchers.some(x => mayLeavePartialCapture(x.parser, new Set(seen), triviaActive) || capturesLeaf(x.parser, new Set(seen))) : false) ||
233
- (d.otherwise ? mayLeavePartialCapture(d.otherwise, new Set(seen), triviaActive) || capturesLeaf(d.otherwise, new Set(seen)) : false)
245
+ d.cases.some(x => mayLeavePartialCapture(x.parser, new Set(seen), triviaActive, throughNodes) || capturesLeaf(x.parser, new Set(seen))) ||
246
+ (d.matchers ? d.matchers.some(x => mayLeavePartialCapture(x.parser, new Set(seen), triviaActive, throughNodes) || capturesLeaf(x.parser, new Set(seen))) : false) ||
247
+ (d.otherwise ? mayLeavePartialCapture(d.otherwise, new Set(seen), triviaActive, throughNodes) || capturesLeaf(d.otherwise, new Set(seen)) : false)
234
248
  case 'attempt':
235
249
  return false
236
250
  // optional never fails; many/oneOrMore only "fail" with zero captured items.
@@ -272,7 +286,7 @@ export function mayLeavePartialCapture(p: Combinator<unknown>, seen: Set<Combina
272
286
  const part = parts[i]!
273
287
  if (i > 0 && triviaActive) captured = true
274
288
  if (captured && mayFail(part)) return true
275
- if (mayLeavePartialCapture(part, seen, triviaActive)) return true
289
+ if (mayLeavePartialCapture(part, seen, triviaActive, throughNodes)) return true
276
290
  if (capturesLeaf(part) || hasNodeDef(part)) captured = true
277
291
  }
278
292
  return false
@@ -284,11 +298,11 @@ export function mayLeavePartialCapture(p: Combinator<unknown>, seen: Set<Combina
284
298
  case 'expect':
285
299
  case 'withCtx':
286
300
  case 'grammar':
287
- return mayLeavePartialCapture(d.parser, seen, triviaActive)
301
+ return mayLeavePartialCapture(d.parser, seen, triviaActive, throughNodes)
288
302
  case 'recover':
289
- return mayLeavePartialCapture(d.parser, seen, triviaActive)
303
+ return mayLeavePartialCapture(d.parser, seen, triviaActive, throughNodes)
290
304
  case 'lazy': {
291
- try { return mayLeavePartialCapture(d.thunk(), seen, triviaActive) } catch { return true }
305
+ try { return mayLeavePartialCapture(d.thunk(), seen, triviaActive, throughNodes) } catch { return true }
292
306
  }
293
307
  // Unknown shapes: be safe and keep the rollback.
294
308
  default:
@@ -147,9 +147,11 @@ function matcherExpr(entry: DispatchMatcherCase): string {
147
147
  export function serializeRuleMap(
148
148
  ruleMap: ReadonlyArray<readonly [string, Comb]>,
149
149
  scanSkip?: readonly Comb[] | null,
150
+ /** External names the factory read through `g`; any no rule body reaches is kept as `void g[name]`. */
151
+ accessed?: readonly string[],
150
152
  ): string | null {
151
153
  try {
152
- return new Serializer(ruleMap, scanSkip ?? []).run()
154
+ return new Serializer(ruleMap, scanSkip ?? [], accessed ?? []).run()
153
155
  } catch (e) {
154
156
  if (e instanceof Unserializable) {
155
157
  // `compileLinkableTable()` reaches this at run time, so it runs in browsers too.
@@ -190,9 +192,13 @@ class Serializer {
190
192
  private ruleMap: ReadonlyArray<readonly [string, Comb]>
191
193
  private scanSkip: readonly Comb[]
192
194
 
193
- constructor(ruleMap: ReadonlyArray<readonly [string, Comb]>, scanSkip: readonly Comb[] = []) {
195
+ private accessed: readonly string[]
196
+ private referenced = new Set<string>()
197
+
198
+ constructor(ruleMap: ReadonlyArray<readonly [string, Comb]>, scanSkip: readonly Comb[] = [], accessed: readonly string[] = []) {
194
199
  this.ruleMap = ruleMap
195
200
  this.scanSkip = scanSkip
201
+ this.accessed = accessed
196
202
  for (const [name, c] of ruleMap) {
197
203
  this.localRuleNames.set(c, name)
198
204
  this.ruleValues.add(this.body(c))
@@ -294,6 +300,11 @@ class Serializer {
294
300
  const body = this.ruleMap
295
301
  .map(([name, c]) => ` ${JSON.stringify(name)}: ${this.wrap(this.body(c), [])}`)
296
302
  .join(',\n')
303
+ // A name the factory read through `g` that no rule body reaches still creates
304
+ // its slot, so a composition that defines it nowhere refuses it.
305
+ for (const name of this.accessed) {
306
+ if (!this.referenced.has(name)) innerDecls.push(`void g[${JSON.stringify(name)}]`)
307
+ }
297
308
  // Shared consts go INSIDE the factory: they can reference `g[name]` rule refs,
298
309
  // and `g` only exists in the factory scope.
299
310
  const factory = innerDecls.length === 0
@@ -412,7 +423,7 @@ class Serializer {
412
423
  switch (def.tag) {
413
424
  case 'lazy': {
414
425
  const name = this.localRuleNames.get(c) ?? ruleNameOf(c)
415
- if (name !== undefined) return `g[${JSON.stringify(name)}]`
426
+ if (name !== undefined) { this.referenced.add(name); return `g[${JSON.stringify(name)}]` }
416
427
  const target = lazyTarget(c)!
417
428
  // Innermost matching frame wins.
418
429
  for (let i = frames.length - 1; i >= 0; i--) {
@@ -372,24 +372,40 @@ function declaredNamesOf(items: Array<LinkableTable | Record<string, unknown>>):
372
372
  return [...names]
373
373
  }
374
374
 
375
+ /**
376
+ * The reason a linked map is incomplete, or `undefined` when every `g.X` some piece
377
+ * reads is defined by some piece. A linked namespace holds every name a factory
378
+ * merely ACCESSED, so a name nobody defines is a slot that stays undefined. Runtime
379
+ * `compose()` and the macro's build-time fuse both refuse it with these words, naming
380
+ * the rule that reaches the hole when one does.
381
+ */
382
+ export function danglingReference(
383
+ map: Record<string, Combinator<unknown>>,
384
+ /** Names read through `g` that `map` itself does not hold (a merge-by-name fuse drops them). */
385
+ accessed: Iterable<string> = [],
386
+ ): string | undefined {
387
+ const holes = new Set<string>()
388
+ for (const [name, rule] of Object.entries(map)) {
389
+ if (rule._def.tag !== 'lazy') continue
390
+ try { rule._def.thunk() } catch { holes.add(name) }
391
+ }
392
+ for (const name of accessed) if (!Object.hasOwn(map, name)) holes.add(name)
393
+ if (holes.size === 0) return undefined
394
+ const missing = [...holes]
395
+ for (const [name, deps] of ruleDependencies(Object.entries(map).filter(([n]) => !holes.has(n)))) {
396
+ for (const dep of deps) if (holes.has(dep)) return `rule "${name}" references missing rule "${dep}"`
397
+ }
398
+ return `rule(s) ${missing.map(n => `"${n}"`).join(', ')} are referenced but defined by no composed grammar`
399
+ }
400
+
375
401
  /** Link recipes into one interpreter map, refusing a name nobody defines. */
376
402
  function linkComposition(
377
403
  recipes: readonly RulesRecipe[],
378
404
  link: LinkOptions,
379
405
  ): Record<string, Combinator<unknown>> {
380
406
  const map = linkRules(recipes, link)
381
- const missing: string[] = []
382
- for (const [name, rule] of Object.entries(map)) {
383
- if (rule._def.tag !== 'lazy') continue
384
- try { rule._def.thunk() } catch { missing.push(name) }
385
- }
386
- if (missing.length > 0) {
387
- const holes = new Set(missing)
388
- for (const [name, deps] of ruleDependencies(Object.entries(map).filter(([n]) => !holes.has(n)))) {
389
- for (const dep of deps) if (holes.has(dep)) throw new Error(`compose: rule "${name}" references missing rule "${dep}"`)
390
- }
391
- throw new Error(`compose: rule(s) ${missing.map(n => `"${n}"`).join(', ')} are referenced but defined by no composed grammar`)
392
- }
407
+ const dangling = danglingReference(map)
408
+ if (dangling !== undefined) throw new Error(`compose: ${dangling}`)
393
409
  // A borrowed rule object keeps its own grammar's bindings here but would be rebound
394
410
  // by name in `compile()` of this composition: refuse it rather than let the two
395
411
  // engines accept different input.
@@ -1613,9 +1613,20 @@ export function evaluateParserFactory(
1613
1613
  */
1614
1614
  const map = new Map<string, Combinator<unknown>>()
1615
1615
  for (const key of keys) map.set(key, built[key]!)
1616
+ const declared = new Set(keys)
1617
+ externalAccesses.set(map, Object.keys(built).filter(name => !declared.has(name)))
1616
1618
  return map
1617
1619
  }
1618
1620
 
1621
+ /**
1622
+ * Every EXTERNAL name an evaluated factory read through `g`, keyed by the map
1623
+ * `evaluateParserFactory` returned. The map holds declared rules only, so a `g.X`
1624
+ * read outside every rule body (`const unused = g.X`) leaves no trace in it; the
1625
+ * IR serializer reads this to keep that access, so a composition refuses an `X`
1626
+ * nobody defines exactly as runtime `compose()` does.
1627
+ */
1628
+ export const externalAccesses = new WeakMap<ReadonlyMap<string, Combinator<unknown>>, readonly string[]>()
1629
+
1619
1630
  /** A combinator slot created by ref() — has a callable `define`. */
1620
1631
  type DefinableRef = Combinator<unknown> & { define(p: Combinator<unknown>): void }
1621
1632
 
@@ -24,7 +24,7 @@ import { createUnplugin } from 'unplugin'
24
24
  import { parseSync } from 'oxc-parser'
25
25
  import { ResolverFactory } from 'oxc-resolver'
26
26
  import MagicString from 'magic-string'
27
- import { evaluateExpr, evaluateCombinatorArray, evaluateParserFactory, evaluateStaticValue, evaluateWordFactory, evaluateWhenFactory, evaluateRefDeclaration, applyDefineStatement, referencesAny, setReducerResolver, setBuilderImportResolver, propName, ModuleScope, type FreeNameResolution, type Scope, type ScopeEntry } from './evaluator.ts'
27
+ import { evaluateExpr, evaluateCombinatorArray, evaluateParserFactory, externalAccesses, evaluateStaticValue, evaluateWordFactory, evaluateWhenFactory, evaluateRefDeclaration, applyDefineStatement, referencesAny, setReducerResolver, setBuilderImportResolver, propName, ModuleScope, type FreeNameResolution, type Scope, type ScopeEntry } from './evaluator.ts'
28
28
  import { classifyRuleMap } from '../analysis/commitment.ts'
29
29
  import { compile } from '../table/compile.ts'
30
30
  import { compileRuleMap, type CompiledRuleMapTable } from '../table/compile-rule-map.ts'
@@ -37,7 +37,7 @@ import {
37
37
  resolveDegradationLevel, recordDegradation, degradationCaptureDepth, unwindDegradationCapture,
38
38
  } from '../compiler/degradation.ts'
39
39
  import type { HostMode } from '../cst/host-mode.ts'
40
- import { COMPOSED_PIECES, type IRPiece } from '../compiler/linker.ts'
40
+ import { COMPOSED_PIECES, danglingReference, type IRPiece } from '../compiler/linker.ts'
41
41
  import { serializeCombinator, serializeRuleMap } from '../compiler/ir-serialize.ts'
42
42
  import { evalCombinatorIR, evalRulesIR, INERT_BUILDER } from './ir-eval.ts'
43
43
  import { countSiteVisits } from '../table/assemble.ts'
@@ -220,6 +220,15 @@ const DEFAULT_ASSEMBLY_BUDGET = 0.25
220
220
  * ~79 ms against ~14 ms on `benchmark.less`. "Couldn't be inlined" alone does not
221
221
  * tell an author which construct to change; the compiler knows, so it says.
222
222
  */
223
+ /** A build failure the lowering must not soften into a warning and a fallback. */
224
+ class LinkRefusal extends Error {}
225
+
226
+ /** Whether a rule-map entry has a definition (a `g.X` merely read does not). */
227
+ function isResolved(rule: Combinator<unknown>): boolean {
228
+ if (rule._def.tag !== 'lazy') return true
229
+ try { rule._def.thunk(); return true } catch { return false }
230
+ }
231
+
223
232
  function reasonSuffix(runtimeOnly: readonly string[] | undefined): string {
224
233
  return runtimeOnly === undefined || runtimeOnly.length === 0
225
234
  ? ''
@@ -2136,17 +2145,15 @@ function transformMacroImpl(
2136
2145
  const mergedCarriedRules = (
2137
2146
  items: CarriedItem[],
2138
2147
  link: LinkOptions,
2139
- ): { rules: Array<[string, Combinator<unknown>]>; trackLines: boolean } | null => {
2148
+ ): { rules: Array<[string, Combinator<unknown>]>; trackLines: boolean; dangling: string | undefined } | null => {
2140
2149
  const carriedMaps = carriedRuleMaps(items)
2141
2150
  if (carriedMaps === null) return null
2142
2151
  const linked = linkRules(carriedMaps.pieces.flatMap(p => p.recipes), link)
2143
2152
  // A name some piece only REFERENCES and none defines stays an undefined slot in
2144
- // the namespace. It is not a rule, so it is not handed to the encoder as one.
2145
- const rules = Object.entries(linked).filter(([, rule]) => {
2146
- if (rule._def.tag !== 'lazy') return true
2147
- try { rule._def.thunk(); return true } catch { return false }
2148
- })
2149
- return { rules, trackLines: carriedMaps.trackLines }
2153
+ // the namespace. Runtime `compose()` refuses that grammar at link, so the build
2154
+ // refuses it too (the caller throws `dangling`) rather than encode around the hole.
2155
+ const dangling = danglingReference(linked)
2156
+ return { rules: Object.entries(linked), trackLines: carriedMaps.trackLines, dangling }
2150
2157
  }
2151
2158
 
2152
2159
  /**
@@ -2183,7 +2190,7 @@ function transformMacroImpl(
2183
2190
  // `rules({ scanSkip }, …)` options, which stamps `_meta.grammarScanSkip` when the IR
2184
2191
  // is re-lowered (materializePiece → compileLinkable picks it up), and survives to a
2185
2192
  // downstream re-compose. The full-pieces fallback bakes it via the compile option.
2186
- const ir = serializeRuleMap(entries as never, scanSkip)
2193
+ const ir = serializeRuleMap(entries as never, scanSkip, rm instanceof Map ? externalAccesses.get(rm) : undefined)
2187
2194
  if (ir) return { carried: [{ ns, ir, ...(trackLines ? { trackLines: true as const } : {}) }] }
2188
2195
  // NO FULL-PIECES FALLBACK. It used to bake the grammar to lowered source when the IR
2189
2196
  // would not serialize; with one lowering there is nothing to bake to, and IR is not
@@ -2337,6 +2344,7 @@ function transformMacroImpl(
2337
2344
  trivia: composing,
2338
2345
  ...(cHostMode ? { hostMode: cHostMode as HostMode } : {}),
2339
2346
  })
2347
+ if (merged?.dangling !== undefined) throw new Error(`${id}:${lineOf(init.start)} — compose: ${merged.dangling}`)
2340
2348
  if (merged !== null) {
2341
2349
  // Harvest the direct-builder import provenance carried on the merged graph so
2342
2350
  // the re-lower pass at the end of this transform re-emits those imports.
@@ -2559,6 +2567,15 @@ function transformMacroImpl(
2559
2567
  }
2560
2568
  }
2561
2569
  const leafMerged = mergeRuleMaps([...carriedMaps.pieces.map(p => p.rules), localEntries])
2570
+ // The same refusal as `compose()`, over a merge by name: a name some piece only
2571
+ // reads (an unresolved entry of a carried map, or a local factory's external
2572
+ // access) that no piece defines.
2573
+ const accessed = [
2574
+ ...carriedMaps.pieces.flatMap(p => p.rules).filter(([, rule]) => !isResolved(rule)).map(([name]) => name),
2575
+ ...(localRules instanceof Map ? externalAccesses.get(localRules) ?? [] : []),
2576
+ ]
2577
+ const dangling = danglingReference(Object.fromEntries(leafMerged), accessed)
2578
+ if (dangling !== undefined) throw new LinkRefusal(`${id}:${lineOf(init.start)} — composeLeaf: ${dangling}`)
2562
2579
  // Composing-wins governs the leaf fuse too. The local entries are NOT freshly
2563
2580
  // evaluated (they come from this module's own `rules()` factory), so they are
2564
2581
  // excluded from the override — their declared trivia IS the composing candidate,
@@ -2595,6 +2612,7 @@ function transformMacroImpl(
2595
2612
  warn(init.start, 'composeLeaf(): a recognition piece has no re-lowerable IR')
2596
2613
  return null
2597
2614
  } catch (e) {
2615
+ if (e instanceof LinkRefusal) throw e
2598
2616
  warn(init.start, `composeLeaf(): ${(e as Error).message}`)
2599
2617
  return null
2600
2618
  }
@@ -2796,7 +2814,7 @@ function transformMacroImpl(
2796
2814
  // lowering there is no such artifact, and a grammar that cannot serialize
2797
2815
  // simply is not carried: an absent carried list makes the downstream compose
2798
2816
  // say so, where a frozen one did not.
2799
- const ir = serializeRuleMap([...compiledRules.ruleMap] as never, compiledRules.scanSkip)
2817
+ const ir = serializeRuleMap([...compiledRules.ruleMap] as never, compiledRules.scanSkip, externalAccesses.get(compiledRules.ruleMap))
2800
2818
  if (ir) carriedMetadata = [{ ns, ir, ...(compiledRules.trackLines ? { trackLines: true as const } : {}) }]
2801
2819
  // NOT SILENT. An export with no carried IR cannot be composed downstream at
2802
2820
  // all — the consumer's `compose()` will fall back to runtime and say so, but
@@ -355,26 +355,38 @@ export type RunCfg = {
355
355
  * literal bodies to buy nothing measurable.
356
356
  */
357
357
  readonly probe: boolean
358
+ /**
359
+ * A caller supplied `ctx.trivia` to a program with no trivia of its own. Such
360
+ * a program records trivia rows only then, so only this assembly restores the
361
+ * trivia logs a failed alternative recorded (`choiceLogRollbackMask`,
362
+ * `failureLogRollback`); every other parse of it takes none of those marks. A
363
+ * program with trivia of its own always restores them and never sets this.
364
+ * Fixed for the parse: a program with no trivia never installs any.
365
+ */
366
+ readonly inheritedTrivia?: boolean
358
367
  }
359
368
 
360
- /** THE bit packing for an assembly cache key. Six bits, so at most sixty-four
369
+ /** THE bit packing for an assembly cache key. Seven bits, so at most 128
361
370
  * ordinary assemblies per table. Host trivia predicates use a host-identity
362
371
  * cache in addition to this key because their per-type answer is not one bit.
363
372
  *
364
- * Taken as six booleans rather than as a `RunCfg` because `AssemblyCache.forCtx`
373
+ * Taken as seven booleans rather than as a `RunCfg` because `AssemblyCache.forCtx`
365
374
  * runs once per entry invocation and must allocate nothing — it derives these bits
366
375
  * from the `ctx` and builds a `RunCfg` only on the miss. That constraint is why the
367
376
  * packing was written twice, 2500 lines apart in this file, and a bit added to one
368
377
  * copy but not the other is a cache COLLISION: a parse served the wrong assembly.
369
378
  * Splitting the packing from the object read satisfies both callers from one place. */
370
- function cfgKeyOf(hostCst: boolean, trackLines: boolean, tolerant: boolean, coverage: boolean, probe: boolean, hostReadsChildren = true): number {
379
+ function cfgKeyOf(
380
+ hostCst: boolean, trackLines: boolean, tolerant: boolean, coverage: boolean, probe: boolean,
381
+ hostReadsChildren = true, inheritedTrivia = false,
382
+ ): number {
371
383
  return (hostCst ? 1 : 0) | (trackLines ? 2 : 0) | (tolerant ? 4 : 0)
372
- | (coverage ? 8 : 0) | (probe ? 16 : 0) | (hostReadsChildren ? 0 : 32)
384
+ | (coverage ? 8 : 0) | (probe ? 16 : 0) | (hostReadsChildren ? 0 : 32) | (inheritedTrivia ? 64 : 0)
373
385
  }
374
386
 
375
387
  /** The cfg key an assembly is cached under. */
376
388
  export function cfgKey(c: RunCfg): number {
377
- return cfgKeyOf(c.hostCst, c.trackLines, c.tolerant, c.coverage, c.probe, c.hostReadsChildren)
389
+ return cfgKeyOf(c.hostCst, c.trackLines, c.tolerant, c.coverage, c.probe, c.hostReadsChildren, c.inheritedTrivia)
378
390
  }
379
391
 
380
392
  export type Assembly = {
@@ -2240,6 +2252,10 @@ export function assemble(t: ResolvedTable, prog: TableProgram, cfg: RunCfg): Ass
2240
2252
  const probeBest = PROBE ? ctx._probe?.best : undefined
2241
2253
  const v = child(input, pos, ctx)
2242
2254
  if (need) rollbackTriviaAt(ctx, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot)
2255
+ // A lookahead contains its child's commitment: `not.ts` and `peek.ts`
2256
+ // return a fresh result, so a committed failure inside the probe never
2257
+ // reaches the grammar around it.
2258
+ ctx._fc = false
2243
2259
  if (PROBE && ctx._probe !== undefined) ctx._probe.best = probeBest ?? null
2244
2260
  if (v === FAIL) { EC.e = pos; return null }
2245
2261
  // `not.ts:50` — the ASSERTION's own set, at the assertion's position.
@@ -2282,6 +2298,10 @@ export function assemble(t: ResolvedTable, prog: TableProgram, cfg: RunCfg): Ass
2282
2298
  const probeBest = PROBE ? ctx._probe?.best : undefined
2283
2299
  const v = child(input, pos, ctx)
2284
2300
  if (need) rollbackTriviaAt(ctx, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot)
2301
+ // A lookahead contains its child's commitment: `not.ts` and `peek.ts`
2302
+ // return a fresh result, so a committed failure inside the probe never
2303
+ // reaches the grammar around it.
2304
+ ctx._fc = false
2285
2305
  if (PROBE && ctx._probe !== undefined) ctx._probe.best = probeBest ?? null
2286
2306
  // `peek.ts:60` — the ASSERTION's own set, at the assertion's position.
2287
2307
  if (v === FAIL) { ctx._fe = pos; ctx._fx = xf; return FAIL }
@@ -4289,7 +4309,8 @@ export function assemble(t: ResolvedTable, prog: TableProgram, cfg: RunCfg): Ass
4289
4309
  if (prog.asm !== undefined) {
4290
4310
  throw new Unemittable(
4291
4311
  `option set ${cfgKey(cfg)} (hostCst=${cfg.hostCst} trackLines=${cfg.trackLines} `
4292
- + `tolerant=${cfg.tolerant} coverage=${cfg.coverage} probe=${cfg.probe}), which this build `
4312
+ + `tolerant=${cfg.tolerant} coverage=${cfg.coverage} probe=${cfg.probe} `
4313
+ + `inheritedTrivia=${cfg.inheritedTrivia === true}), which this build `
4293
4314
  + 'did not pre-compile. The Function constructor is NOT used for an artifact that carries '
4294
4315
  + 'assemblies — see `EmitOptions.assemblies` to add this option set to the build',
4295
4316
  )
@@ -4518,7 +4539,9 @@ export function countSiteVisits(
4518
4539
  export class AssemblyCache {
4519
4540
  private readonly t: ResolvedTable
4520
4541
  private readonly prog: TableProgram
4521
- private readonly byCfg: Array<Assembly | undefined> = Array.from({ length: 64 })
4542
+ private readonly byCfg: Array<Assembly | undefined> = Array.from({ length: 128 })
4543
+ /** Whether this program installs no trivia of its own (`RunCfg.inheritedTrivia`). */
4544
+ private readonly noOwnTrivia: boolean
4522
4545
  /**
4523
4546
  * Monomorphic predicate inline cache. An assembly depends on the predicate
4524
4547
  * FUNCTION and the scalar cfg key, not on the host object that carries it, so
@@ -4532,6 +4555,7 @@ export class AssemblyCache {
4532
4555
  constructor(prog: TableProgram, resolved: ResolvedTable = resolveTable(prog)) {
4533
4556
  this.prog = prog
4534
4557
  this.t = resolved
4558
+ this.noOwnTrivia = prog.triviaSpecs === undefined || prog.triviaSpecs.length === 0
4535
4559
  }
4536
4560
 
4537
4561
  for(cfg: RunCfg): Assembly {
@@ -4599,7 +4623,8 @@ export class AssemblyCache {
4599
4623
  const tolerant = ctx._tolerant === true
4600
4624
  const coverage = ctx._grammarCoverage !== undefined
4601
4625
  const probe = ctx._probe !== undefined
4602
- const key = cfgKeyOf(hostCst, trackLines, tolerant, coverage, probe, hostReadsChildren)
4626
+ const inheritedTrivia = this.noOwnTrivia && ctx.trivia !== undefined
4627
+ const key = cfgKeyOf(hostCst, trackLines, tolerant, coverage, probe, hostReadsChildren, inheritedTrivia)
4603
4628
  let cache = this.byCfg
4604
4629
  if (hostCaptureTrivia !== undefined) {
4605
4630
  // The predicate is host configuration, not parse state. Specialising each
@@ -4610,7 +4635,7 @@ export class AssemblyCache {
4610
4635
  cache = this.hostAssemblies!
4611
4636
  }
4612
4637
  else {
4613
- cache = Array.from({ length: 64 })
4638
+ cache = Array.from({ length: 128 })
4614
4639
  this.hostPredicate = hostCaptureTrivia
4615
4640
  this.hostAssemblies = cache
4616
4641
  }
@@ -4619,7 +4644,7 @@ export class AssemblyCache {
4619
4644
  if (hit !== undefined) return hit
4620
4645
  const made = assemble(this.t, this.prog, {
4621
4646
  hostCst, hostReadsChildren, hostCaptureTrivia,
4622
- trackLines, tolerant, coverage, probe,
4647
+ trackLines, tolerant, coverage, probe, inheritedTrivia,
4623
4648
  })
4624
4649
  cache[key] = made
4625
4650
  return made