parseman 0.47.1 → 0.48.1

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 (126) hide show
  1. package/README.md +27 -21
  2. package/dist/analysis/diagnostics.js +2964 -347
  3. package/dist/analysis/diagnostics.js.map +3 -3
  4. package/dist/cli/index.js +2960 -343
  5. package/dist/cli/index.js.map +3 -3
  6. package/dist/combinators/choice.d.ts.map +1 -1
  7. package/dist/combinators/expect.d.ts +1 -0
  8. package/dist/combinators/expect.d.ts.map +1 -1
  9. package/dist/combinators/expected.d.ts +8 -0
  10. package/dist/combinators/expected.d.ts.map +1 -0
  11. package/dist/combinators/first-set.d.ts +8 -0
  12. package/dist/combinators/first-set.d.ts.map +1 -1
  13. package/dist/combinators/grammar.d.ts.map +1 -1
  14. package/dist/combinators/keywords.d.ts +4 -0
  15. package/dist/combinators/keywords.d.ts.map +1 -1
  16. package/dist/combinators/literal.d.ts.map +1 -1
  17. package/dist/combinators/not.d.ts.map +1 -1
  18. package/dist/combinators/peek.d.ts.map +1 -1
  19. package/dist/combinators/regex.d.ts.map +1 -1
  20. package/dist/combinators/repeat.d.ts.map +1 -1
  21. package/dist/combinators/sequence.d.ts.map +1 -1
  22. package/dist/combinators/trivia-skip.d.ts +16 -3
  23. package/dist/combinators/trivia-skip.d.ts.map +1 -1
  24. package/dist/compiler/direct-projection.d.ts +12 -0
  25. package/dist/compiler/direct-projection.d.ts.map +1 -0
  26. package/dist/compiler/token-alphabet.d.ts +845 -5
  27. package/dist/compiler/token-alphabet.d.ts.map +1 -1
  28. package/dist/compiler/token-capability.d.ts +3 -0
  29. package/dist/compiler/token-capability.d.ts.map +1 -0
  30. package/dist/compiler/token-capability.js +3192 -0
  31. package/dist/compiler/token-capability.js.map +6 -0
  32. package/dist/cst/trivia-charscan.d.ts +3 -0
  33. package/dist/cst/trivia-charscan.d.ts.map +1 -1
  34. package/dist/cst/trivia-css-scanner.d.ts +5 -0
  35. package/dist/cst/trivia-css-scanner.d.ts.map +1 -0
  36. package/dist/cst/trivia-kinds.d.ts.map +1 -1
  37. package/dist/index.js +2973 -343
  38. package/dist/index.js.map +3 -3
  39. package/dist/language-service/index.js +5 -1
  40. package/dist/language-service/index.js.map +1 -1
  41. package/dist/plugin/index.js +2982 -352
  42. package/dist/plugin/index.js.map +3 -3
  43. package/dist/spec/index.js +325 -47
  44. package/dist/spec/index.js.map +3 -3
  45. package/dist/table/assemble.d.ts.map +1 -1
  46. package/dist/table/child-slots.d.ts.map +1 -1
  47. package/dist/table/compile-rule-map.d.ts +3 -1
  48. package/dist/table/compile-rule-map.d.ts.map +1 -1
  49. package/dist/table/emit-assembly.d.ts +12 -13
  50. package/dist/table/emit-assembly.d.ts.map +1 -1
  51. package/dist/table/emit.d.ts.map +1 -1
  52. package/dist/table/encode.d.ts.map +1 -1
  53. package/dist/table/exec-baseline.d.ts.map +1 -1
  54. package/dist/table/exec.d.ts.map +1 -1
  55. package/dist/table/index.js +2937 -311
  56. package/dist/table/index.js.map +3 -3
  57. package/dist/table/lex-body.d.ts +9 -0
  58. package/dist/table/lex-body.d.ts.map +1 -0
  59. package/dist/table/lex-program.d.ts +25 -0
  60. package/dist/table/lex-program.d.ts.map +1 -0
  61. package/dist/table/ops.d.ts +47 -11
  62. package/dist/table/ops.d.ts.map +1 -1
  63. package/dist/table/program.d.ts +50 -2
  64. package/dist/table/program.d.ts.map +1 -1
  65. package/dist/table/scalar-terminal.d.ts +13 -0
  66. package/dist/table/scalar-terminal.d.ts.map +1 -0
  67. package/dist/table/site-labels.d.ts.map +1 -1
  68. package/dist/types.d.ts +2 -0
  69. package/dist/types.d.ts.map +1 -1
  70. package/dist/version.d.ts +1 -1
  71. package/package.json +11 -11
  72. package/src/combinators/choice.ts +10 -1
  73. package/src/combinators/expect.ts +1 -0
  74. package/src/combinators/expected.ts +17 -0
  75. package/src/combinators/first-set.ts +58 -5
  76. package/src/combinators/grammar.ts +8 -3
  77. package/src/combinators/keywords.ts +22 -6
  78. package/src/combinators/literal.ts +2 -1
  79. package/src/combinators/not.ts +5 -1
  80. package/src/combinators/peek.ts +5 -1
  81. package/src/combinators/regex.ts +5 -3
  82. package/src/combinators/repeat.ts +4 -10
  83. package/src/combinators/sequence.ts +17 -14
  84. package/src/combinators/trivia-skip.ts +46 -13
  85. package/src/compiler/direct-projection.ts +43 -0
  86. package/src/compiler/token-alphabet.ts +4316 -12
  87. package/src/compiler/token-capability.ts +6 -0
  88. package/src/cst/trivia-charscan.ts +34 -0
  89. package/src/cst/trivia-css-scanner.ts +142 -0
  90. package/src/cst/trivia-kinds.ts +3 -1
  91. package/src/plugin/index.ts +4 -4
  92. package/src/table/assemble.ts +1253 -240
  93. package/src/table/child-slots.ts +2 -1
  94. package/src/table/compile-rule-map.ts +21 -3
  95. package/src/table/emit-assembly.ts +335 -87
  96. package/src/table/emit.ts +16 -2
  97. package/src/table/encode.ts +248 -60
  98. package/src/table/exec-baseline.ts +3 -7
  99. package/src/table/exec.ts +134 -25
  100. package/src/table/lex-body.ts +30 -0
  101. package/src/table/lex-program.ts +431 -0
  102. package/src/table/ops.ts +49 -11
  103. package/src/table/program.ts +46 -2
  104. package/src/table/scalar-terminal.ts +51 -0
  105. package/src/table/site-labels.ts +11 -1
  106. package/src/table/stamp.ts +1 -1
  107. package/src/types.ts +1 -1
  108. package/src/version.ts +1 -1
  109. package/dist/analysis/diagnostics.cjs +0 -13824
  110. package/dist/analysis/diagnostics.cjs.map +0 -6
  111. package/dist/cli/index.cjs +0 -14925
  112. package/dist/cli/index.cjs.map +0 -6
  113. package/dist/index.cjs +0 -16391
  114. package/dist/index.cjs.map +0 -6
  115. package/dist/language-service/index.cjs +0 -1304
  116. package/dist/language-service/index.cjs.map +0 -6
  117. package/dist/oracle/index.cjs +0 -254
  118. package/dist/oracle/index.cjs.map +0 -6
  119. package/dist/plugin/index.cjs +0 -16097
  120. package/dist/plugin/index.cjs.map +0 -6
  121. package/dist/run/index.cjs +0 -577
  122. package/dist/run/index.cjs.map +0 -6
  123. package/dist/spec/index.cjs +0 -6236
  124. package/dist/spec/index.cjs.map +0 -6
  125. package/dist/table/index.cjs +0 -11463
  126. package/dist/table/index.cjs.map +0 -6
@@ -1,9 +1,19 @@
1
1
  /**
2
- * Derived tokenization, part 1: the terminal ALPHABET.
2
+ * Derived tokenization groundwork: primitive kernels and lexical-token families.
3
3
  *
4
- * Parseman knows every terminal in the composed grammar at macro time — every
5
- * `literal`, `keywords`, and `regex`. This module walks the combinator graph
6
- * and assigns each distinct terminal a small integer TOKEN ID.
4
+ * `collectAlphabet()` is the preserved primitive-terminal scanner groundwork:
5
+ * it knows every `literal`, `keywords`, and `regex` in the composed grammar and
6
+ * assigns each one a small integer KERNEL id. Those ids are implementation
7
+ * details, not parser tokens. In particular, unwrapping
8
+ * `token(sequence(identifier, optional(literal('('))))` must never publish an
9
+ * identifier id followed by a `(` id: `token()` defines ONE contiguous source
10
+ * token and ONE CST leaf for the complete range.
11
+ *
12
+ * `collectLexicalAlphabet()` is the production-facing boundary. It assigns ids
13
+ * to authored `token()` families, normalizes effect-free bodies into canonical
14
+ * lexical IR, interns equivalent recognizers, and records the downstream
15
+ * `dispatch()` outcome classifiers over the same range. Primitive terminals
16
+ * stay private recognizer machinery.
7
17
  *
8
18
  * Two things are deliberately separated, because conflating them is what makes
9
19
  * a naive derived scanner useless:
@@ -20,7 +30,7 @@
20
30
  * Nothing here decides HOW a token is recognized (see `token-scanner.ts`); this
21
31
  * module only decides WHAT the tokens are and WHICH ones each site may see.
22
32
  */
23
- import type { Combinator } from '../types.ts';
33
+ import type { AutoNotCheck, Combinator, FirstSet, ParserDef } from '../types.ts';
24
34
  /** A terminal in the derived alphabet, with its globally assigned id. */
25
35
  export type TokenTerminal = {
26
36
  kind: 'literal';
@@ -51,6 +61,800 @@ export type Alphabet = {
51
61
  /** The combinator that contributed each id (first one wins), for candidate sets. */
52
62
  originOf: Map<number, Combinator<unknown>>;
53
63
  };
64
+ /** Effect-free recognition IR underneath one authored `token()` boundary. */
65
+ export type LexicalIr = {
66
+ readonly kind: 'literal';
67
+ readonly value: string;
68
+ readonly caseInsensitive: boolean;
69
+ } | {
70
+ readonly kind: 'keywords';
71
+ readonly words: readonly string[];
72
+ readonly caseInsensitive: boolean;
73
+ readonly boundary: string | undefined;
74
+ } | {
75
+ readonly kind: 'regex';
76
+ readonly source: string;
77
+ readonly flags: string;
78
+ } | {
79
+ readonly kind: 'sequence';
80
+ readonly parts: readonly LexicalIr[];
81
+ } | {
82
+ readonly kind: 'choice';
83
+ readonly arms: readonly LexicalIr[];
84
+ } | {
85
+ readonly kind: 'repeat';
86
+ readonly body: LexicalIr;
87
+ readonly min: number;
88
+ readonly max: number | null;
89
+ readonly greedy: boolean;
90
+ readonly mode: 'possessive' | 'backtracking';
91
+ } | {
92
+ readonly kind: 'assert';
93
+ readonly positive: boolean;
94
+ readonly body: LexicalIr;
95
+ } | {
96
+ readonly kind: 'balanced';
97
+ readonly open: string;
98
+ readonly close: string;
99
+ readonly strict: boolean;
100
+ readonly raw: boolean;
101
+ /** Ordered explicit skippers; ambient trivia/scanSkip precede them unless raw. */
102
+ readonly skip: readonly LexicalIr[];
103
+ };
104
+ /** First complete executable lexical body. It is intentionally a semantic
105
+ * shape rather than an opcode: the encoder relocates the regex into the table
106
+ * pool only after TOKEN wins the compiler-only cost comparison. */
107
+ export type OptionalSuffixLexBody = {
108
+ readonly kind: 'regex-optional-code-unit';
109
+ readonly source: string;
110
+ readonly flags: string;
111
+ readonly suffix: string;
112
+ };
113
+ export type ExecutableOptionalSuffixLexBody = OptionalSuffixLexBody & {
114
+ /** Match the two authored terminal line-publication points exactly. */
115
+ readonly baseCanMatchNewline: boolean;
116
+ readonly suffixCanMatchNewline: boolean;
117
+ /** Failure authority belongs to the resolved final regex, not the lazy
118
+ * construction thunk that originally named it. */
119
+ readonly expected: readonly string[];
120
+ };
121
+ /** A direct authored terminal under token(). The boundary shell still owns
122
+ * source slicing/CST; this body owns exactly the terminal recognizer and lines. */
123
+ export type ExecutableTerminalLexBody = {
124
+ readonly kind: 'regex-terminal';
125
+ readonly source: string;
126
+ readonly flags: string;
127
+ readonly canMatchNewline: boolean;
128
+ readonly expected: readonly string[];
129
+ };
130
+ export type ExecutableOrdered4LexBody = {
131
+ readonly kind: 'ordered4-terminals';
132
+ readonly commonFirstSet: FirstSet;
133
+ readonly commonMissExpected: readonly string[];
134
+ readonly expected: readonly string[];
135
+ readonly arms: readonly [
136
+ ExecutableTerminalLexBody,
137
+ ExecutableTerminalLexBody,
138
+ ExecutableTerminalLexBody,
139
+ ExecutableTerminalLexBody
140
+ ];
141
+ };
142
+ export type ExecutableNot2LexBody = {
143
+ readonly kind: 'not2-ordered4-terminal';
144
+ readonly guard0Expected: readonly string[];
145
+ readonly guard1Expected: readonly string[];
146
+ readonly terminalExpected: readonly string[];
147
+ readonly guard0: ExecutableOrdered4LexBody['arms'];
148
+ readonly guard1: ExecutableTerminalLexBody;
149
+ readonly terminal: ExecutableTerminalLexBody;
150
+ };
151
+ export type ExecutableLexNode = {
152
+ readonly kind: 'terminal';
153
+ readonly terminal: ExecutableTerminalLexBody;
154
+ } | {
155
+ readonly kind: 'sequence';
156
+ readonly parts: readonly ExecutableLexNode[];
157
+ } | {
158
+ readonly kind: 'choice';
159
+ readonly arms: readonly ExecutableLexNode[];
160
+ readonly firstSets: readonly FirstSet[];
161
+ readonly armExpected: readonly (readonly string[])[];
162
+ readonly expected: readonly string[];
163
+ } | {
164
+ readonly kind: 'not';
165
+ readonly body: ExecutableLexNode;
166
+ readonly expected: readonly string[];
167
+ } | {
168
+ readonly kind: 'optional';
169
+ readonly body: ExecutableLexNode;
170
+ };
171
+ export type ExecutableFixedLexBody = {
172
+ readonly kind: 'fixed-tree';
173
+ readonly root: ExecutableLexNode;
174
+ };
175
+ /** A balanced token whose recognition remains owned by the canonical scanner
176
+ * pool. The selected shell removes only the losing token/parent topology; it
177
+ * never restates ambient scanSkip, recovery, or skipper semantics. */
178
+ export type ExecutableBalancedLexBody = {
179
+ readonly kind: 'balanced-scan';
180
+ readonly open: string;
181
+ readonly close: string;
182
+ readonly raw: boolean;
183
+ readonly strict: boolean;
184
+ readonly ownSkip: readonly Combinator<unknown>[];
185
+ };
186
+ export type ExecutableLexBody = ExecutableOptionalSuffixLexBody | ExecutableTerminalLexBody | ExecutableOrdered4LexBody | ExecutableNot2LexBody | ExecutableFixedLexBody | ExecutableBalancedLexBody;
187
+ export type LexBodyCandidate = {
188
+ readonly strategy: 'character';
189
+ readonly estimatedOps: number;
190
+ } | {
191
+ readonly strategy: 'token';
192
+ readonly estimatedOps: number;
193
+ readonly body: OptionalSuffixLexBody;
194
+ };
195
+ /** Exact recognizer shape admitted by the first end-to-end Stage-C tranche. */
196
+ export declare function optionalSuffixLexBody(ir: LexicalIr): OptionalSuffixLexBody | undefined;
197
+ /** Compare two COMPLETE candidates. The CHARACTER cost is the existing
198
+ * token-boundary + sequence + regex + optional + literal body. The TOKEN cost
199
+ * is one selected body and one materialization boundary; neither candidate is
200
+ * serialized until this decision returns. */
201
+ export declare function selectOptionalSuffixLexBody(ir: LexicalIr): LexBodyCandidate;
202
+ /** Refuse wrapper/effect lookalikes even when normalization erases them to the
203
+ * same language. This first executable body owns only the authored token
204
+ * boundary around a direct sequence(regex, optional(literal-one-code-unit)). */
205
+ export declare function directOptionalSuffixTokenBody(parser: Combinator<unknown>, resolve?: (name: string) => Combinator<unknown> | undefined): ExecutableOptionalSuffixLexBody | undefined;
206
+ /** Exact direct token terminal bodies. `keywords()` is represented by the same
207
+ * canonical sticky RegExp its authored parser and OP_RX lowering use. Literal
208
+ * stays CHARACTER for now: case-insensitive literal() intentionally uses ASCII
209
+ * folding, which is not JavaScript RegExp `/i` semantics for non-ASCII text. */
210
+ export declare function directTerminalTokenBody(parser: Combinator<unknown>, resolve?: (name: string) => Combinator<unknown> | undefined): ExecutableTerminalLexBody | undefined;
211
+ /** First composite selected body: the hot Less at-keyword choice. Keep this a
212
+ * fixed template, not a recursive lexical interpreter. Equal finite first sets
213
+ * are load-bearing: at a matching lead all four arms really run in source
214
+ * order, while an excluded lead contributes only the choice's static opener
215
+ * set and no probe event. */
216
+ export declare function directOrdered4TokenBody(parser: Combinator<unknown>, resolve?: (name: string) => Combinator<unknown> | undefined): ExecutableOrdered4LexBody | undefined;
217
+ export declare function directNot2TokenBody(parser: Combinator<unknown>, resolve?: (name: string) => Combinator<unknown> | undefined): ExecutableNot2LexBody | undefined;
218
+ export declare function directFixedTokenBody(parser: Combinator<unknown>, resolve?: (name: string) => Combinator<unknown> | undefined): ExecutableFixedLexBody | undefined;
219
+ export declare function directBalancedTokenBody(parser: Combinator<unknown>, resolve?: (name: string) => Combinator<unknown> | undefined): ExecutableBalancedLexBody | undefined;
220
+ export declare function directExecutableTokenBody(parser: Combinator<unknown>, resolve?: (name: string) => Combinator<unknown> | undefined): ExecutableLexBody | undefined;
221
+ /** One canonical recognizer spec, shared by every family with equal lexical IR. */
222
+ export type LexicalRecognizer = {
223
+ readonly id: number;
224
+ readonly key: string;
225
+ readonly ir: LexicalIr;
226
+ /** Crosswalk into the compiler-wide canonical recognition-family interner. */
227
+ readonly capabilityFamilyId: number;
228
+ };
229
+ /**
230
+ * Spelling-specific failure/probe contract. Families may share recognition IR
231
+ * without sharing where a structured spelling fails or what it expects.
232
+ */
233
+ export type LexicalDiagnosticPlan = {
234
+ readonly id: number;
235
+ readonly body: Combinator<unknown>;
236
+ };
237
+ /** Pointer-free, compiler-only checkpoints inside one authored token body. */
238
+ export type LexicalDiagnosticEvent = {
239
+ readonly op: 'FAIL';
240
+ readonly state: number;
241
+ readonly expectedId: number;
242
+ } | {
243
+ readonly op: 'ASSERT';
244
+ readonly state: number;
245
+ readonly innerStart: number;
246
+ readonly innerEnd: number;
247
+ readonly positive: boolean;
248
+ readonly expectedId: number;
249
+ readonly snapshotPolicy: 'saveLookaheadMark';
250
+ readonly execution: 'deferred';
251
+ } | {
252
+ readonly op: 'REQUIRE';
253
+ readonly state: number;
254
+ readonly childStart: number;
255
+ readonly childEnd: number;
256
+ readonly expectedId: number;
257
+ readonly when: 'mandatory-iteration-2-to-min';
258
+ readonly committedChild: 'propagate';
259
+ readonly probe: 'child-only';
260
+ readonly anchor: 'repeat-position';
261
+ } | {
262
+ readonly op: 'BAL_CLOSE_STRICT';
263
+ readonly state: number;
264
+ readonly expectedId: number;
265
+ readonly probe: true;
266
+ readonly committed: false;
267
+ readonly when: 'close-miss-after-open-body-success';
268
+ } | {
269
+ readonly op: 'BAL_CLOSE_RECOVER';
270
+ readonly state: number;
271
+ readonly expectedId: number;
272
+ readonly probe: true;
273
+ readonly committed: false;
274
+ readonly when: 'close-miss-after-open-body-success';
275
+ readonly result: 'parseError';
276
+ readonly errorSpan: 'close-position';
277
+ readonly lineAnnotation: 'when-active';
278
+ readonly errorSink: 'when-active';
279
+ readonly cstErrorCapture: 'when-active';
280
+ };
281
+ /**
282
+ * Stage-B2 diagnostic metadata. It is intentionally absent from TableProgram:
283
+ * assertion execution and every token-boundary effect remain capability GAPs.
284
+ */
285
+ export type LexicalTransitionDiagnosticPlan = {
286
+ readonly id: number;
287
+ readonly stateCount: number;
288
+ readonly expected: readonly (readonly string[])[];
289
+ readonly events: readonly LexicalDiagnosticEvent[];
290
+ };
291
+ export type LexicalControlNode = {
292
+ readonly id: number;
293
+ readonly parentControlId?: number;
294
+ /** Authored parser kind, or the conditional/repeated balanced skipper role. */
295
+ readonly kind: ParserDef['tag'] | 'balanced' | 'balanced-skip';
296
+ readonly stateStart: number;
297
+ readonly stateEnd: number;
298
+ };
299
+ export type LexicalControlPlan = {
300
+ readonly id: number;
301
+ /** Pointer-free source-control index over the one normalization session. */
302
+ readonly controls: readonly LexicalControlNode[];
303
+ };
304
+ /** One globally interned lexical family/base-token id. */
305
+ export type LexicalTokenFamily = {
306
+ readonly id: number;
307
+ readonly recognizerId: number;
308
+ };
309
+ /** One authored `token()` site, with spelling-specific diagnostics/effects. */
310
+ export type LexicalTokenSite = {
311
+ readonly parser: Combinator<unknown>;
312
+ readonly body: Combinator<unknown>;
313
+ /** Absent on a refused site; refused metadata allocates no diagnostic plan. */
314
+ readonly diagnosticId?: number;
315
+ /** All three are absent when normalization declined. */
316
+ readonly familyId?: number;
317
+ readonly recognizerId?: number;
318
+ readonly refusal?: string;
319
+ };
320
+ export type LexicalCapabilityStatus = {
321
+ readonly kind: 'complete';
322
+ } | {
323
+ readonly kind: 'gap';
324
+ readonly reason: string;
325
+ } | {
326
+ readonly kind: 'impossible';
327
+ readonly proof: string;
328
+ };
329
+ export type LexicalCapabilityPhase = {
330
+ readonly representation: LexicalCapabilityStatus;
331
+ /** A complete body is constructible for every required reader/variant before selection. */
332
+ readonly executableLowering: LexicalCapabilityStatus;
333
+ };
334
+ export type LexicalCapabilityObligations = {
335
+ readonly recognition: LexicalCapabilityPhase;
336
+ readonly diagnostics: LexicalCapabilityPhase;
337
+ readonly boundaryPlan: LexicalCapabilityPhase;
338
+ readonly materializationPlan: LexicalCapabilityPhase;
339
+ readonly supportedVariants: LexicalCapabilityPhase;
340
+ readonly bindingAndReachability: LexicalCapabilityPhase;
341
+ };
342
+ /** Built-in authored token() context transaction. Compiler-only in this tranche. */
343
+ export type LexicalBoundaryPlan = {
344
+ readonly id: 0;
345
+ readonly kind: 'token-context-transaction';
346
+ };
347
+ /** Built-in authored token() source-range value/CST materialization. */
348
+ export type LexicalMaterializationPlan = {
349
+ readonly id: 0;
350
+ readonly kind: 'token-source-range';
351
+ };
352
+ /** Exact construction-time grammar wrapper policy, not merely its effective context. */
353
+ export type LexicalGrammarWrapperSpec = {
354
+ readonly id: number;
355
+ readonly sourceOperationId: number;
356
+ readonly clearTrivia: boolean;
357
+ readonly triviaBindingId?: number;
358
+ readonly trackLines: 'on' | 'off' | 'inherit';
359
+ readonly captureTrivia: boolean;
360
+ readonly captureTriviaKindsId?: number;
361
+ readonly rootCapture: 'opaque' | 'inherit';
362
+ readonly clonePolicy: 'spread-existing-or-create-canonical';
363
+ readonly postChildPolicy: 'line-propagate-then-annotate-or-return';
364
+ };
365
+ /** Well-nested overlay over the sole LexicalIr/B2 control/state authority. */
366
+ export type LexicalWrapperFrame = {
367
+ readonly id: number;
368
+ readonly parentFrameId?: number;
369
+ readonly controlId: number;
370
+ readonly stateStart: number;
371
+ readonly stateEnd: number;
372
+ readonly kind: 'token';
373
+ readonly boundaryPlanId: 0;
374
+ readonly materializationPlanId: 0;
375
+ } | {
376
+ readonly id: number;
377
+ readonly parentFrameId?: number;
378
+ readonly controlId: number;
379
+ readonly stateStart: number;
380
+ readonly stateEnd: number;
381
+ readonly kind: 'grammar';
382
+ readonly wrapperSpecId: number;
383
+ };
384
+ export type LexicalBoundaryTopology = {
385
+ readonly id: number;
386
+ /** Source-order outer-before-inner frames; recognition/control is not duplicated. */
387
+ readonly frames: readonly LexicalWrapperFrame[];
388
+ };
389
+ export type LexicalCapabilityContext = {
390
+ readonly trivia: Combinator<unknown> | undefined;
391
+ readonly scanSkip: readonly Combinator<unknown>[];
392
+ readonly trackLines: boolean;
393
+ readonly captureTrivia: boolean;
394
+ readonly opaqueRootCapture: boolean;
395
+ readonly dynamicState: boolean;
396
+ };
397
+ /** Immutable compiler occurrence context. Live scanner callbacks are policy,
398
+ * never identity-bearing lexical facts or pending-range keys. */
399
+ export type LexicalContextSnapshot = {
400
+ readonly id: number;
401
+ readonly key: string;
402
+ readonly hasTrivia: boolean;
403
+ readonly hasScanSkip: boolean;
404
+ readonly trackLines: boolean;
405
+ readonly captureTrivia: boolean;
406
+ readonly opaqueRootCapture: boolean;
407
+ readonly dynamicState: boolean;
408
+ };
409
+ export type LexicalOwnSkipEntry = {
410
+ readonly semanticKey?: string;
411
+ readonly ir?: LexicalIr;
412
+ readonly status: LexicalCapabilityStatus;
413
+ };
414
+ /** Construction-owned skipper children only. Ambient trivia/scanSkip never
415
+ * enter this pool because their object and `.parse` lookup are observable. */
416
+ export type LexicalOwnSkipPlan = {
417
+ readonly id: number;
418
+ readonly entries: readonly LexicalOwnSkipEntry[];
419
+ };
420
+ export type LexicalScanConsumerPolicy = {
421
+ readonly id: number;
422
+ readonly siteId: number;
423
+ readonly path: string;
424
+ readonly contextSnapshotId: number;
425
+ readonly kind: 'scanTo';
426
+ readonly raw: boolean;
427
+ readonly ambient: 'enumerate-trivia-then-scanSkip-per-parse-attempt' | 'none-raw';
428
+ readonly lookup: 'dynamic-parse-property-every-skip-test';
429
+ readonly context: 'detached-per-attempt-state-errors-only';
430
+ readonly ownSkipPlanId?: number;
431
+ readonly pendingReuse: 'forbidden';
432
+ readonly status: LexicalCapabilityStatus;
433
+ } | {
434
+ readonly id: number;
435
+ readonly siteId: number;
436
+ readonly path: string;
437
+ readonly contextSnapshotId: number;
438
+ readonly kind: 'balanced';
439
+ readonly raw: boolean;
440
+ readonly ambient: 'array-identity-interior-cache' | 'none-raw';
441
+ readonly cache: 'lookup-every-attempt-enumerate-on-miss';
442
+ readonly lookup: 'dynamic-parse-property-every-skip-test';
443
+ readonly context: 'token-cleared-original';
444
+ readonly ownSkipPlanId?: number;
445
+ readonly pendingReuse: 'forbidden';
446
+ readonly status: LexicalCapabilityStatus;
447
+ };
448
+ /**
449
+ * Compiler-only phase-A census record. These ids are deliberately not family
450
+ * ids: two authored sites can share one future language while remaining two
451
+ * independently auditable capability obligations.
452
+ */
453
+ export type LexicalCapabilitySite = {
454
+ readonly id: number;
455
+ /** Final-graph compiler body identity. Never serialized as a parser pointer. */
456
+ readonly bodyId: number;
457
+ /** Interned recognition-language summary; never used as a completeness id. */
458
+ readonly languageId: number;
459
+ readonly path: string;
460
+ /** Effective lexical scope at this occurrence; compiler-only, never a family id. */
461
+ readonly contextKey: string;
462
+ readonly contextSnapshotId: number;
463
+ /** Context seen by recognition after token() clears trivia/capture sinks. */
464
+ readonly recognitionContextKey: string;
465
+ readonly context: LexicalCapabilityContext;
466
+ readonly recognitionContext: LexicalCapabilityContext;
467
+ readonly semanticKey: string;
468
+ readonly atom: 'terminal' | 'token' | 'choice' | 'dispatch';
469
+ readonly parser: Combinator<unknown>;
470
+ readonly obligations: LexicalCapabilityObligations;
471
+ /** Internal body metadata only; never claims the boundary effects obligation. */
472
+ readonly diagnosticPlanId?: number;
473
+ /** Compiler-only boundary overlay; absent when exact representation declined. */
474
+ readonly boundaryTopologyId?: number;
475
+ /** Control ancestry authority used by the boundary overlay. */
476
+ readonly controlPlanId?: number;
477
+ /** Scan consumers owned by this atomic occurrence, in structural order. */
478
+ readonly scanConsumerPolicyIds: readonly number[];
479
+ /** Derived from `obligations`; callers cannot independently set it. */
480
+ readonly status: LexicalCapabilityStatus;
481
+ };
482
+ export type LexicalCapabilityLanguage = {
483
+ readonly id: number;
484
+ readonly atom: LexicalCapabilitySite['atom'];
485
+ readonly semanticKey: string;
486
+ };
487
+ /**
488
+ * One compiler-wide canonical source-range language. IDs use the lexical
489
+ * family namespace even while phase B is disabled; decision plans and the
490
+ * legacy token collector cross-reference this one IR interner.
491
+ */
492
+ export type LexicalDecisionFamily = {
493
+ readonly id: number;
494
+ readonly semanticKey: string;
495
+ readonly ir: LexicalIr;
496
+ };
497
+ /**
498
+ * A compatible view of one family range. `prefix` owns its own shorter end;
499
+ * consumers must never substitute the full family end (the `a | ab` rule).
500
+ */
501
+ export type LexicalDecisionOutcomeView = {
502
+ readonly kind: 'whole';
503
+ readonly relation: 'equal';
504
+ } | {
505
+ readonly kind: 'predicate';
506
+ readonly relation: 'equal';
507
+ readonly match: Exclude<LexicalOutcomeMatch, {
508
+ kind: 'otherwise';
509
+ }>;
510
+ } | {
511
+ readonly kind: 'language';
512
+ readonly relation: 'equal' | 'prefix';
513
+ readonly ir: LexicalIr;
514
+ };
515
+ /** Global, family-qualified atomic outcome/view identity. */
516
+ export type LexicalDecisionOutcome = {
517
+ readonly id: number;
518
+ readonly familyId: number;
519
+ readonly semanticKey: string;
520
+ readonly view: LexicalDecisionOutcomeView;
521
+ };
522
+ export type LexicalDecisionAcceptance = {
523
+ readonly kind: 'outcomes';
524
+ readonly outcomeIds: readonly number[];
525
+ } | {
526
+ readonly kind: 'otherwise';
527
+ readonly excludingOutcomeIds: readonly number[];
528
+ } | {
529
+ readonly kind: 'unrestricted';
530
+ } | {
531
+ readonly kind: 'impossible';
532
+ } | {
533
+ readonly kind: 'gap';
534
+ readonly reason: string;
535
+ };
536
+ /** One source-ordered arm/route for one candidate family at one occurrence. */
537
+ export type LexicalDecisionArm = {
538
+ readonly armId: number;
539
+ readonly acceptance: LexicalDecisionAcceptance;
540
+ readonly usesRouted: boolean;
541
+ readonly dynamicGate: boolean;
542
+ };
543
+ export type LexicalDecisionFamilyPlan = {
544
+ readonly familyId: number;
545
+ readonly arms: readonly LexicalDecisionArm[];
546
+ };
547
+ /** Source-ordered decision regions within which a recognized range may remain
548
+ * live. A dynamic scanner is its own closed epoch: callbacks and ambient skip
549
+ * policy may mutate parse state, so no lexical fact may cross that arm in
550
+ * either direction. This is compiler evidence for one complete TOKEN body,
551
+ * never a request to replay the CHARACTER body. */
552
+ export type LexicalDecisionReuseEpoch = {
553
+ readonly armIds: readonly number[];
554
+ readonly pendingReuse: 'forbidden' | 'unproved';
555
+ readonly boundary: 'none' | 'dynamic-scan';
556
+ };
557
+ /** Occurrence-local ordered decision proof; never serialized in this tranche. */
558
+ export type LexicalDecisionSite = {
559
+ readonly siteId: number;
560
+ readonly atom: 'choice' | 'dispatch';
561
+ readonly path: string;
562
+ readonly contextKey: string;
563
+ readonly contextSnapshotId: number;
564
+ readonly families: readonly LexicalDecisionFamilyPlan[];
565
+ /** Dispatch-only source-order routed policy. This remains Stage-A authority;
566
+ * the effect projection references the site rather than copying route bits. */
567
+ readonly routeUsesRouted?: readonly boolean[];
568
+ /** Families not proven at this occurrence remain admitted through this
569
+ * conservative relation. It is an explicit TOKEN-body route, never a request
570
+ * to replay the character parser. */
571
+ readonly fallback: 'unrestricted';
572
+ /** Missing inclusion/partition proofs reduce pruning precision only. Every
573
+ * authored arm still runs its own exact replacement recognizer in PEG order. */
574
+ readonly precisionNotes: readonly string[];
575
+ /** Dynamic scanner callbacks are effectful and can never publish a reusable
576
+ * cross-arm lexical fact. All other sites remain unproved in this tranche. */
577
+ readonly pendingReuse: 'forbidden' | 'unproved';
578
+ readonly reuseEpochs: readonly LexicalDecisionReuseEpoch[];
579
+ };
580
+ /** Final winner-resolved fixed choice classes, shared with table encoding. */
581
+ export type LexicalChoiceClassAuthority = {
582
+ readonly id: number;
583
+ readonly armIds: readonly number[];
584
+ readonly firstSets: readonly FirstSet[];
585
+ };
586
+ /** A non-authored execution order such as longest literal first. */
587
+ export type LexicalChoiceExecutionOrder = {
588
+ readonly id: number;
589
+ readonly armIds: readonly number[];
590
+ };
591
+ /** Exact classified spelling to authored arm identity. */
592
+ export type LexicalClassifySpellingMap = {
593
+ readonly id: number;
594
+ readonly entries: readonly {
595
+ readonly spelling: string;
596
+ readonly armId: number;
597
+ }[];
598
+ };
599
+ /** Transform callback identities applied to an already recognized spelling. */
600
+ export type LexicalClassifyProjectionPlan = {
601
+ readonly id: number;
602
+ readonly entries: readonly {
603
+ readonly armId: number;
604
+ readonly transformIds: readonly number[];
605
+ readonly transformSourceIds: readonly (number | -1)[];
606
+ readonly transformCount: number;
607
+ }[];
608
+ };
609
+ export type LexicalExpectedAuthority = {
610
+ readonly id: number;
611
+ readonly values: readonly string[];
612
+ };
613
+ /** Compiler-local callback identity; never a TableProgram or public wire value. */
614
+ export type LexicalDecisionCallbackAuthority = {
615
+ readonly id: number;
616
+ readonly callback: ((state: unknown) => boolean) | ((value: unknown, span: {
617
+ start: number;
618
+ end: number;
619
+ }) => unknown);
620
+ };
621
+ /** Named emitted projection for a callback; compiler-only until Stage C selects. */
622
+ export type LexicalDecisionSourceAuthority = {
623
+ readonly id: number;
624
+ readonly source: string;
625
+ };
626
+ /** Exact post-success rejection checks, interned without re-deriving them. */
627
+ export type LexicalAutoNotAuthority = {
628
+ readonly id: number;
629
+ readonly checks: readonly AutoNotCheck[];
630
+ };
631
+ export type LexicalFinalDecisionAuthority = {
632
+ readonly id: number;
633
+ readonly atom: 'choice';
634
+ readonly decisionSiteId: number;
635
+ readonly authoredArmIds: readonly number[];
636
+ readonly mode: {
637
+ readonly kind: 'ordered';
638
+ } | {
639
+ readonly kind: 'exclusive';
640
+ readonly classAuthorityId: number;
641
+ } | {
642
+ readonly kind: 'longest';
643
+ readonly orderAuthorityId: number;
644
+ } | {
645
+ readonly kind: 'classify';
646
+ readonly superArmId: number;
647
+ readonly spellingMapAuthorityId: number;
648
+ readonly projectionAuthorityId: number;
649
+ };
650
+ /** Static total-miss set only for strategies that never consult dynamic gates. */
651
+ readonly staticMissExpectedAuthorityId?: number;
652
+ } | {
653
+ readonly id: number;
654
+ readonly atom: 'dispatch';
655
+ readonly decisionSiteId: number;
656
+ readonly selectorBindingEdgeId: number;
657
+ readonly classifierAuthorityId: number;
658
+ readonly orderedRouteIds: readonly number[];
659
+ readonly noRouteExpectedAuthorityId: number;
660
+ };
661
+ export type LexicalDecisionChildEffect = {
662
+ readonly id: number;
663
+ readonly decisionSiteId: number;
664
+ readonly armId: number;
665
+ readonly childBindingEdgeId: number;
666
+ readonly expectedAuthorityId: number;
667
+ readonly gateCallbackId?: number;
668
+ readonly gateSourceId?: number;
669
+ readonly autoNotAuthorityId?: number;
670
+ };
671
+ export type LexicalDecisionEffectProgram = {
672
+ readonly id: number;
673
+ readonly decisionSiteId: number;
674
+ readonly finalDecisionAuthorityId: number;
675
+ readonly phase: LexicalCapabilityPhase;
676
+ readonly childEffectIds: readonly number[];
677
+ /** Exact fixed-edge projections consumed by the three existing readers. */
678
+ readonly childBindingProjectionIds: readonly number[];
679
+ readonly referenceTemplateId: number;
680
+ readonly capturedTemplateId: number;
681
+ readonly namedTemplateId: number;
682
+ readonly readerMask: number;
683
+ readonly variantMask: number;
684
+ readonly semanticDigest: number;
685
+ readonly pendingRollbackPolicyId: 0;
686
+ readonly commitPolicyId: 0;
687
+ };
688
+ /** Compiler-only C2 pools. No member is a TableProgram or runtime wire field. */
689
+ export type LexicalDecisionEffectInventory = {
690
+ readonly finalDecisionAuthorities: readonly LexicalFinalDecisionAuthority[];
691
+ readonly decisionEffects: readonly LexicalDecisionEffectProgram[];
692
+ readonly decisionChildEffects: readonly LexicalDecisionChildEffect[];
693
+ readonly choiceClassAuthorities: readonly LexicalChoiceClassAuthority[];
694
+ readonly choiceExecutionOrders: readonly LexicalChoiceExecutionOrder[];
695
+ readonly classifySpellingMaps: readonly LexicalClassifySpellingMap[];
696
+ readonly classifyProjectionPlans: readonly LexicalClassifyProjectionPlan[];
697
+ readonly decisionExpectedAuthorities: readonly LexicalExpectedAuthority[];
698
+ readonly decisionCallbackAuthorities: readonly LexicalDecisionCallbackAuthority[];
699
+ readonly decisionSourceAuthorities: readonly LexicalDecisionSourceAuthority[];
700
+ readonly decisionAutoNotAuthorities: readonly LexicalAutoNotAuthority[];
701
+ };
702
+ /** One fixed incoming/root edge whose direct linked-body candidates remain owed. */
703
+ export type LexicalBindingEdge = {
704
+ readonly id: number;
705
+ readonly path: string;
706
+ readonly contextKey: string;
707
+ /** Effective context at the child occurrence, after the parent boundary. */
708
+ readonly childContextKey: string;
709
+ readonly contextSnapshotId: number;
710
+ readonly parentTag: ParserDef['tag'] | 'root';
711
+ readonly childTag: ParserDef['tag'];
712
+ readonly projectionId?: number;
713
+ readonly status: LexicalCapabilityStatus;
714
+ };
715
+ /** Compiler-owned fixed-edge lowering. These are numeric construction facts,
716
+ * not a parse-time micro-IR: each reader consumes only its own preselected
717
+ * template and the common digest proves all three describe the same edge. */
718
+ export type LexicalBindingProjection = {
719
+ readonly id: number;
720
+ readonly edgeId: number;
721
+ readonly parentBodyId: number;
722
+ readonly childBodyId: number;
723
+ readonly childOrdinal: number;
724
+ readonly referenceOperand: number;
725
+ readonly capturedSlotId: number;
726
+ readonly capturedTemplateId: number;
727
+ readonly namedSymbolId: number;
728
+ readonly namedTemplateId: number;
729
+ /** bit 0 reference, bit 1 captured/CSP, bit 2 named/emitted. */
730
+ readonly readerMask: number;
731
+ /** Strict, recovery, tracking, CST, probe, and coverage construction modes. */
732
+ readonly variantMask: number;
733
+ readonly semanticDigest: number;
734
+ };
735
+ /** One executable primitive-terminal candidate plus every fixed incoming edge.
736
+ * This remains compiler-only until Stage C selects a complete semantic body. */
737
+ export type LexicalTerminalProjection = {
738
+ readonly id: number;
739
+ readonly siteId: number;
740
+ readonly bodyId: number;
741
+ readonly languageId: number;
742
+ readonly referenceBodyId: number;
743
+ readonly capturedTemplateId: number;
744
+ readonly namedSymbolId: number;
745
+ readonly incomingBindingProjectionIds: readonly number[];
746
+ readonly readerMask: number;
747
+ readonly variantMask: number;
748
+ readonly semanticDigest: number;
749
+ readonly status: LexicalCapabilityStatus;
750
+ };
751
+ export type LexicalOutcomeMatch = {
752
+ readonly kind: 'exact';
753
+ readonly values: readonly string[];
754
+ readonly caseInsensitive: boolean;
755
+ } | {
756
+ readonly kind: 'startsWith' | 'endsWith';
757
+ readonly value: string;
758
+ readonly caseInsensitive: boolean;
759
+ } | {
760
+ readonly kind: 'matches';
761
+ readonly value: string;
762
+ readonly flags: string;
763
+ readonly caseInsensitive: boolean;
764
+ } | {
765
+ readonly kind: 'otherwise';
766
+ readonly excluding: readonly Exclude<LexicalOutcomeMatch, {
767
+ kind: 'otherwise';
768
+ }>[];
769
+ };
770
+ /** A globally reusable classification id for one family/range predicate. */
771
+ export type LexicalOutcomeSpec = {
772
+ readonly id: number;
773
+ readonly familyId: number;
774
+ readonly match: LexicalOutcomeMatch;
775
+ };
776
+ /** One compatible view over a family range at a particular dispatch site. */
777
+ export type LexicalTokenOutcome = {
778
+ readonly id: number;
779
+ readonly match: LexicalOutcomeMatch;
780
+ };
781
+ /** One ordered dispatch arm. IDs classify; this route owns the branch/cut. */
782
+ export type LexicalTokenRoute = {
783
+ readonly index: number;
784
+ readonly kind: 'exact' | 'matcher' | 'otherwise';
785
+ readonly acceptedIds: readonly number[];
786
+ readonly matches: readonly LexicalOutcomeMatch[];
787
+ readonly parser: Combinator<unknown>;
788
+ readonly usesRouted: boolean;
789
+ };
790
+ /** Dispatch outcomes stay site-local; ordered dispatch semantics are unchanged. */
791
+ export type LexicalTokenClassifier = {
792
+ readonly dispatch: Combinator<unknown>;
793
+ readonly familyId: number;
794
+ /** True when reaching token() crossed a wrapper whose effects must still run. */
795
+ readonly selectorEffects: boolean;
796
+ /** Compatible range views, flattened and allowed to repeat an id by route. */
797
+ readonly outcomes: readonly LexicalTokenOutcome[];
798
+ /** Authoritative ordered route/cut identity. */
799
+ readonly routes: readonly LexicalTokenRoute[];
800
+ };
801
+ export type LexicalAlphabet = {
802
+ /**
803
+ * Compiler-only graph metadata. `diagnostics`, `sites`, `classifiers`, and
804
+ * `familyIdOf` contain live combinators/Maps and are NOT TableProgram data.
805
+ * A serializer must project the numeric/IR specs and relocate site references.
806
+ */
807
+ readonly recognizers: readonly LexicalRecognizer[];
808
+ readonly diagnostics: readonly LexicalDiagnosticPlan[];
809
+ readonly families: readonly LexicalTokenFamily[];
810
+ readonly sites: readonly LexicalTokenSite[];
811
+ readonly outcomes: readonly LexicalOutcomeSpec[];
812
+ readonly classifiers: readonly LexicalTokenClassifier[];
813
+ readonly familyIdOf: ReadonlyMap<Combinator<unknown>, number>;
814
+ /** Whole-final-grammar, ownership-aware phase-A capability census. */
815
+ readonly capabilities: readonly LexicalCapabilitySite[];
816
+ /** Interned language view only; completeness is always occurrence-based. */
817
+ readonly capabilityLanguages: readonly LexicalCapabilityLanguage[];
818
+ /** Every distinct fixed parent/root edge, independently GAP until linked. */
819
+ readonly bindingEdges: readonly LexicalBindingEdge[];
820
+ readonly bindingProjections: readonly LexicalBindingProjection[];
821
+ readonly terminalProjections: readonly LexicalTerminalProjection[];
822
+ /** Phase-A compatible range/arm algebra; compiler-only and occurrence-local. */
823
+ readonly decisionFamilies: readonly LexicalDecisionFamily[];
824
+ readonly decisionOutcomes: readonly LexicalDecisionOutcome[];
825
+ readonly decisions: readonly LexicalDecisionSite[];
826
+ readonly decisionEffectPlan: LexicalDecisionEffectInventory;
827
+ readonly transitionDiagnostics: readonly LexicalTransitionDiagnosticPlan[];
828
+ readonly boundaryPlans: readonly LexicalBoundaryPlan[];
829
+ readonly materializationPlans: readonly LexicalMaterializationPlan[];
830
+ readonly grammarWrapperSpecs: readonly LexicalGrammarWrapperSpec[];
831
+ readonly grammarCaptureTriviaKinds: readonly (readonly string[])[];
832
+ readonly boundaryTopologies: readonly LexicalBoundaryTopology[];
833
+ readonly controlPlans: readonly LexicalControlPlan[];
834
+ readonly contextSnapshots: readonly LexicalContextSnapshot[];
835
+ readonly ownSkipPlans: readonly LexicalOwnSkipPlan[];
836
+ readonly scanConsumerPolicies: readonly LexicalScanConsumerPolicy[];
837
+ /** False means phase B is forbidden for the entire program. */
838
+ readonly capabilityComplete: boolean;
839
+ };
840
+ export type LexicalCapabilityInventory = Pick<LexicalAlphabet, 'capabilities' | 'capabilityLanguages' | 'bindingEdges' | 'bindingProjections' | 'terminalProjections' | 'decisionFamilies' | 'decisionOutcomes' | 'decisions' | 'decisionEffectPlan' | 'transitionDiagnostics' | 'boundaryPlans' | 'materializationPlans' | 'grammarWrapperSpecs' | 'grammarCaptureTriviaKinds' | 'boundaryTopologies' | 'controlPlans' | 'contextSnapshots' | 'ownSkipPlans' | 'scanConsumerPolicies' | 'capabilityComplete'>;
841
+ /** Numeric-only artifact projection; `TableProgram` aliases this contract. */
842
+ export type NumericLexicalPlan = {
843
+ readonly recognizerOffsets: readonly number[];
844
+ readonly recognizerData: readonly number[];
845
+ readonly outcomeOffsets: readonly number[];
846
+ readonly outcomeData: readonly number[];
847
+ readonly tokenSites: readonly number[];
848
+ readonly sites: readonly number[];
849
+ readonly routes: readonly number[];
850
+ readonly accepted: readonly number[];
851
+ };
852
+ /** Lexical-family ids occupy their own published namespace. */
853
+ export declare const FIRST_LEXICAL_FAMILY_ID = 3;
854
+ /** Canonical, parser-free identity for one range predicate. */
855
+ export declare function canonicalLexicalOutcomeKey(match: LexicalOutcomeMatch): string;
856
+ /** Does a final rule-map winner bottom out at the reference being resolved? */
857
+ export declare function winnerWrapsReference(winner: Combinator<unknown>, reference: Combinator<unknown>): boolean;
54
858
  /** Direct sub-parsers of a def, resolving a lazy through `resolve` when its own thunk is a hole. */
55
859
  export declare function tokenChildren(p: Combinator<unknown>, resolve?: (name: string) => Combinator<unknown> | undefined): Combinator<unknown>[];
56
860
  /**
@@ -58,6 +862,42 @@ export declare function tokenChildren(p: Combinator<unknown>, resolve?: (name: s
58
862
  * which is stable for a given grammar and therefore safe to switch on.
59
863
  */
60
864
  export declare function collectAlphabet(roots: ReadonlyArray<Combinator<unknown>>, resolve?: (name: string) => Combinator<unknown> | undefined): Alphabet;
865
+ /** Re-enumerate the final graph so a dropped/filtered candidate fails closed. */
866
+ export declare function assertLexicalCapabilityClosure(roots: ReadonlyArray<Combinator<unknown>>, alphabet: Pick<LexicalCapabilityInventory, 'capabilities' | 'capabilityLanguages' | 'bindingEdges' | 'decisionFamilies' | 'decisionOutcomes' | 'decisions'> & Partial<Pick<LexicalCapabilityInventory, 'bindingProjections' | 'terminalProjections' | 'decisionEffectPlan' | 'transitionDiagnostics' | 'boundaryPlans' | 'materializationPlans' | 'grammarWrapperSpecs' | 'grammarCaptureTriviaKinds' | 'boundaryTopologies' | 'controlPlans' | 'contextSnapshots' | 'ownSkipPlans' | 'scanConsumerPolicies'>>, resolve?: (name: string) => Combinator<unknown> | undefined): void;
867
+ /** Phase-A only: inventory obligations without constructing unused runtime families/sites. */
868
+ export declare function collectLexicalCapabilities(roots: ReadonlyArray<Combinator<unknown>>, resolve?: (name: string) => Combinator<unknown> | undefined): LexicalCapabilityInventory;
869
+ /**
870
+ * Catalog authored lexical tokens and their dispatch views without confusing
871
+ * private child terminals for source tokens. This is metadata only: consumers
872
+ * still have to lower the canonical IR in every shipping engine before enabling
873
+ * an admission path.
874
+ */
875
+ export declare function collectLexicalAlphabet(roots: ReadonlyArray<Combinator<unknown>>, resolve?: (name: string) => Combinator<unknown> | undefined): LexicalAlphabet;
876
+ /**
877
+ * Project the compiler graph into compact numeric pools. The caller supplies
878
+ * only already-relocated table-site numbers and its existing const-pool intern;
879
+ * no combinator or identity map crosses this boundary.
880
+ */
881
+ export declare function serializeLexicalPlan(alphabet: LexicalAlphabet, constant: (value: unknown) => number, tokenSites: readonly number[], dispatchSites: ReadonlyArray<{
882
+ readonly dsp: number;
883
+ readonly classifier: LexicalTokenClassifier;
884
+ }>): NumericLexicalPlan | undefined;
885
+ /**
886
+ * Metadata/reference oracle for compatible same-range views. Exact/prefix/suffix
887
+ * checks read char codes directly; regex matcher views slice only in this cold
888
+ * oracle. Production token cursors must lower matcher plans without treating
889
+ * this helper as their allocation contract.
890
+ */
891
+ export declare function compatibleLexicalOutcomes(classifier: LexicalTokenClassifier, input: string, start: number, end: number): number[];
892
+ /**
893
+ * Cold oracle for dispatch selection precedence. Compatible views are a set;
894
+ * selected routing is still exact cases first, then matcher source order, then
895
+ * otherwise, and a selected branch failure remains committed.
896
+ */
897
+ export declare function selectedLexicalOutcome(classifier: LexicalTokenClassifier, input: string, start: number, end: number): {
898
+ route: LexicalTokenRoute;
899
+ outcomeId: number;
900
+ } | undefined;
61
901
  /** The id already assigned to this terminal, if it is one. */
62
902
  export declare function terminalId(alphabet: Alphabet, p: Combinator<unknown>): number | undefined;
63
903
  /**