parseman 0.45.0 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (333) hide show
  1. package/README.md +8 -3
  2. package/dist/analysis/choice-cost-gate.d.ts +158 -0
  3. package/dist/analysis/choice-cost-gate.d.ts.map +1 -0
  4. package/dist/analysis/choice-cost-render.d.ts +96 -0
  5. package/dist/analysis/choice-cost-render.d.ts.map +1 -0
  6. package/dist/analysis/choice-cost.d.ts +383 -0
  7. package/dist/analysis/choice-cost.d.ts.map +1 -0
  8. package/dist/analysis/commitment.d.ts +131 -0
  9. package/dist/analysis/commitment.d.ts.map +1 -0
  10. package/dist/analysis/corpus.d.ts +73 -0
  11. package/dist/analysis/corpus.d.ts.map +1 -0
  12. package/dist/analysis/diagnose-render.d.ts +65 -0
  13. package/dist/analysis/diagnose-render.d.ts.map +1 -0
  14. package/dist/analysis/diagnose.d.ts +15 -0
  15. package/dist/analysis/diagnose.d.ts.map +1 -1
  16. package/dist/analysis/diagnostics.cjs +13736 -0
  17. package/dist/analysis/diagnostics.cjs.map +6 -0
  18. package/dist/analysis/diagnostics.d.ts +27 -0
  19. package/dist/analysis/diagnostics.d.ts.map +1 -0
  20. package/dist/analysis/diagnostics.js +13713 -0
  21. package/dist/analysis/diagnostics.js.map +6 -0
  22. package/dist/analysis/duplication.d.ts.map +1 -1
  23. package/dist/analysis/fix-render.d.ts +43 -0
  24. package/dist/analysis/fix-render.d.ts.map +1 -0
  25. package/dist/analysis/fix.d.ts +172 -0
  26. package/dist/analysis/fix.d.ts.map +1 -0
  27. package/dist/analysis/format-number.d.ts +23 -0
  28. package/dist/analysis/format-number.d.ts.map +1 -0
  29. package/dist/analysis/gating.d.ts +47 -2
  30. package/dist/analysis/gating.d.ts.map +1 -1
  31. package/dist/analysis/rebuild.d.ts +61 -0
  32. package/dist/analysis/rebuild.d.ts.map +1 -0
  33. package/dist/analysis/terminal.d.ts +145 -0
  34. package/dist/analysis/terminal.d.ts.map +1 -0
  35. package/dist/cli/index.cjs +14837 -0
  36. package/dist/cli/index.cjs.map +6 -0
  37. package/dist/cli/index.d.ts +3 -0
  38. package/dist/cli/index.d.ts.map +1 -0
  39. package/dist/cli/index.js +14814 -0
  40. package/dist/cli/index.js.map +6 -0
  41. package/dist/combinators/adjacency.d.ts +100 -0
  42. package/dist/combinators/adjacency.d.ts.map +1 -0
  43. package/dist/combinators/choice.d.ts.map +1 -1
  44. package/dist/combinators/completions.d.ts.map +1 -1
  45. package/dist/combinators/dispatch.d.ts +8 -1
  46. package/dist/combinators/dispatch.d.ts.map +1 -1
  47. package/dist/combinators/expect.d.ts.map +1 -1
  48. package/dist/combinators/first-set.d.ts.map +1 -1
  49. package/dist/combinators/gate.d.ts.map +1 -1
  50. package/dist/combinators/grammar.d.ts +22 -0
  51. package/dist/combinators/grammar.d.ts.map +1 -1
  52. package/dist/combinators/literal.d.ts +8 -0
  53. package/dist/combinators/literal.d.ts.map +1 -1
  54. package/dist/combinators/map.d.ts +0 -1
  55. package/dist/combinators/map.d.ts.map +1 -1
  56. package/dist/combinators/node.d.ts +13 -3
  57. package/dist/combinators/node.d.ts.map +1 -1
  58. package/dist/combinators/parser.d.ts +1 -1
  59. package/dist/combinators/parser.d.ts.map +1 -1
  60. package/dist/combinators/ref.d.ts.map +1 -1
  61. package/dist/combinators/regex.d.ts +1 -16
  62. package/dist/combinators/regex.d.ts.map +1 -1
  63. package/dist/combinators/repeat.d.ts +30 -2
  64. package/dist/combinators/repeat.d.ts.map +1 -1
  65. package/dist/combinators/scanTo.d.ts +71 -1
  66. package/dist/combinators/scanTo.d.ts.map +1 -1
  67. package/dist/combinators/sequence.d.ts.map +1 -1
  68. package/dist/combinators/token.d.ts.map +1 -1
  69. package/dist/combinators/trivia-boundary.d.ts +26 -0
  70. package/dist/combinators/trivia-boundary.d.ts.map +1 -0
  71. package/dist/combinators/trivia-skip.d.ts +40 -1
  72. package/dist/combinators/trivia-skip.d.ts.map +1 -1
  73. package/dist/combinators/withCtx.d.ts.map +1 -1
  74. package/dist/compiler/build-arity.d.ts.map +1 -1
  75. package/dist/compiler/compile-linkable-table.d.ts +104 -0
  76. package/dist/compiler/compile-linkable-table.d.ts.map +1 -0
  77. package/dist/compiler/degradation.d.ts +0 -2
  78. package/dist/compiler/degradation.d.ts.map +1 -1
  79. package/dist/compiler/fields.d.ts +13 -0
  80. package/dist/compiler/fields.d.ts.map +1 -1
  81. package/dist/compiler/grammar-coverage-ids.d.ts +5 -5
  82. package/dist/compiler/grammar-coverage-ids.d.ts.map +1 -1
  83. package/dist/compiler/ir-serialize.d.ts.map +1 -1
  84. package/dist/compiler/linker.d.ts +79 -47
  85. package/dist/compiler/linker.d.ts.map +1 -1
  86. package/dist/compiler/token-alphabet.d.ts +81 -0
  87. package/dist/compiler/token-alphabet.d.ts.map +1 -0
  88. package/dist/compiler/token-dispatch.d.ts +95 -0
  89. package/dist/compiler/token-dispatch.d.ts.map +1 -0
  90. package/dist/compiler/token-scanner.d.ts +53 -0
  91. package/dist/compiler/token-scanner.d.ts.map +1 -0
  92. package/dist/compiler/value-usage.d.ts.map +1 -1
  93. package/dist/coverage.d.ts +1 -1
  94. package/dist/coverage.d.ts.map +1 -1
  95. package/dist/cst/capture-buffer.d.ts +35 -0
  96. package/dist/cst/capture-buffer.d.ts.map +1 -1
  97. package/dist/cst/reflection-attach.d.ts +8 -0
  98. package/dist/cst/reflection-attach.d.ts.map +1 -0
  99. package/dist/cst/reflection-symbols.d.ts +10 -0
  100. package/dist/cst/reflection-symbols.d.ts.map +1 -0
  101. package/dist/cst/reflection.d.ts +2 -4
  102. package/dist/cst/reflection.d.ts.map +1 -1
  103. package/dist/cst/root-trivia-scope.d.ts +26 -0
  104. package/dist/cst/root-trivia-scope.d.ts.map +1 -0
  105. package/dist/cst/trivia-charscan.d.ts +18 -0
  106. package/dist/cst/trivia-charscan.d.ts.map +1 -0
  107. package/dist/cst/trivia-kinds.d.ts +19 -0
  108. package/dist/cst/trivia-kinds.d.ts.map +1 -1
  109. package/dist/functional/doc.d.ts.map +1 -1
  110. package/dist/functional/run-tabled.d.ts +12 -0
  111. package/dist/functional/run-tabled.d.ts.map +1 -0
  112. package/dist/functional/run.d.ts +25 -42
  113. package/dist/functional/run.d.ts.map +1 -1
  114. package/dist/grammar-metadata.d.ts +3 -0
  115. package/dist/grammar-metadata.d.ts.map +1 -0
  116. package/dist/index.cjs +10499 -7478
  117. package/dist/index.cjs.map +3 -4
  118. package/dist/index.d.ts +24 -9
  119. package/dist/index.d.ts.map +1 -1
  120. package/dist/index.js +10499 -7478
  121. package/dist/index.js.map +3 -4
  122. package/dist/language-service/index.cjs +311 -121
  123. package/dist/language-service/index.cjs.map +3 -4
  124. package/dist/language-service/index.js +311 -121
  125. package/dist/language-service/index.js.map +3 -4
  126. package/dist/oracle/index.cjs.map +0 -1
  127. package/dist/oracle/index.js.map +0 -1
  128. package/dist/parse-context.d.ts +49 -0
  129. package/dist/parse-context.d.ts.map +1 -0
  130. package/dist/plugin/evaluator.d.ts +41 -2
  131. package/dist/plugin/evaluator.d.ts.map +1 -1
  132. package/dist/plugin/free-identifiers.d.ts +23 -0
  133. package/dist/plugin/free-identifiers.d.ts.map +1 -0
  134. package/dist/plugin/index.cjs +11381 -9442
  135. package/dist/plugin/index.cjs.map +3 -4
  136. package/dist/plugin/index.d.ts.map +1 -1
  137. package/dist/plugin/index.js +11381 -9442
  138. package/dist/plugin/index.js.map +3 -4
  139. package/dist/plugin/reducer-resolver.d.ts +17 -1
  140. package/dist/plugin/reducer-resolver.d.ts.map +1 -1
  141. package/dist/regex/classes.d.ts +28 -0
  142. package/dist/regex/classes.d.ts.map +1 -1
  143. package/dist/regex/first-set.d.ts +14 -0
  144. package/dist/regex/first-set.d.ts.map +1 -1
  145. package/dist/run/index.cjs +136 -51
  146. package/dist/run/index.cjs.map +2 -3
  147. package/dist/run/index.js +136 -51
  148. package/dist/run/index.js.map +2 -3
  149. package/dist/spec/index.cjs +2898 -1622
  150. package/dist/spec/index.cjs.map +3 -4
  151. package/dist/spec/index.js +2898 -1622
  152. package/dist/spec/index.js.map +3 -4
  153. package/dist/spec/model.d.ts +8 -0
  154. package/dist/spec/model.d.ts.map +1 -1
  155. package/dist/table/assemble.d.ts +307 -0
  156. package/dist/table/assemble.d.ts.map +1 -0
  157. package/dist/table/cell.d.ts +42 -0
  158. package/dist/table/cell.d.ts.map +1 -0
  159. package/dist/table/child-slots.d.ts +30 -0
  160. package/dist/table/child-slots.d.ts.map +1 -0
  161. package/dist/table/compile-rule-map.d.ts +136 -0
  162. package/dist/table/compile-rule-map.d.ts.map +1 -0
  163. package/dist/table/compile.d.ts +56 -0
  164. package/dist/table/compile.d.ts.map +1 -0
  165. package/dist/table/duplication-hook.d.ts +32 -0
  166. package/dist/table/duplication-hook.d.ts.map +1 -0
  167. package/dist/table/emit-assembly.d.ts +139 -0
  168. package/dist/table/emit-assembly.d.ts.map +1 -0
  169. package/dist/table/emit.d.ts +113 -0
  170. package/dist/table/emit.d.ts.map +1 -0
  171. package/dist/table/encode-baseline.d.ts +16 -0
  172. package/dist/table/encode-baseline.d.ts.map +1 -0
  173. package/dist/table/encode.d.ts +71 -0
  174. package/dist/table/encode.d.ts.map +1 -0
  175. package/dist/table/exec-baseline.d.ts +9 -0
  176. package/dist/table/exec-baseline.d.ts.map +1 -0
  177. package/dist/table/exec.d.ts +72 -0
  178. package/dist/table/exec.d.ts.map +1 -0
  179. package/dist/table/fold.d.ts +25 -0
  180. package/dist/table/fold.d.ts.map +1 -0
  181. package/dist/table/index.cjs +11375 -0
  182. package/dist/table/index.cjs.map +6 -0
  183. package/dist/table/index.d.ts +100 -0
  184. package/dist/table/index.d.ts.map +1 -0
  185. package/dist/table/index.js +11352 -0
  186. package/dist/table/index.js.map +6 -0
  187. package/dist/table/inspect.d.ts +17 -0
  188. package/dist/table/inspect.d.ts.map +1 -0
  189. package/dist/table/ops.d.ts +446 -0
  190. package/dist/table/ops.d.ts.map +1 -0
  191. package/dist/table/program.d.ts +493 -0
  192. package/dist/table/program.d.ts.map +1 -0
  193. package/dist/table/run-support.d.ts +38 -0
  194. package/dist/table/run-support.d.ts.map +1 -0
  195. package/dist/{compiler/scannable-run.d.ts → table/scan-shapes.d.ts} +14 -13
  196. package/dist/table/scan-shapes.d.ts.map +1 -0
  197. package/dist/table/site-labels.d.ts +58 -0
  198. package/dist/table/site-labels.d.ts.map +1 -0
  199. package/dist/table/stamp.d.ts +70 -0
  200. package/dist/table/stamp.d.ts.map +1 -0
  201. package/dist/types.d.ts +80 -24
  202. package/dist/types.d.ts.map +1 -1
  203. package/dist/version.d.ts +1 -1
  204. package/package.json +41 -3
  205. package/src/analysis/choice-cost-gate.ts +359 -0
  206. package/src/analysis/choice-cost-render.ts +293 -0
  207. package/src/analysis/choice-cost.ts +1008 -0
  208. package/src/analysis/commitment.ts +557 -0
  209. package/src/analysis/corpus.ts +130 -0
  210. package/src/analysis/diagnose-render.ts +625 -0
  211. package/src/analysis/diagnose.ts +317 -0
  212. package/src/analysis/diagnostics.ts +33 -0
  213. package/src/analysis/duplication.ts +1955 -0
  214. package/src/analysis/fix-render.ts +217 -0
  215. package/src/analysis/fix.ts +669 -0
  216. package/src/analysis/format-number.ts +31 -0
  217. package/src/analysis/gating.ts +792 -0
  218. package/src/analysis/grammar.ts +72 -0
  219. package/src/analysis/rebuild.ts +287 -0
  220. package/src/analysis/terminal.ts +336 -0
  221. package/src/cli/index.ts +413 -0
  222. package/src/combinators/adjacency.ts +171 -0
  223. package/src/combinators/attempt.ts +41 -0
  224. package/src/combinators/case-fold.ts +90 -0
  225. package/src/combinators/choice.ts +466 -0
  226. package/src/combinators/completions.ts +64 -0
  227. package/src/combinators/dispatch.ts +358 -0
  228. package/src/combinators/expect.ts +159 -0
  229. package/src/combinators/first-set.ts +322 -0
  230. package/src/combinators/gate.ts +50 -0
  231. package/src/combinators/grammar.ts +272 -0
  232. package/src/combinators/keywords.ts +145 -0
  233. package/src/combinators/literal.ts +102 -0
  234. package/src/combinators/map.ts +106 -0
  235. package/src/combinators/node.ts +345 -0
  236. package/src/combinators/not.ts +55 -0
  237. package/src/combinators/parser.ts +266 -0
  238. package/src/combinators/peek.ts +63 -0
  239. package/src/combinators/probe.ts +25 -0
  240. package/src/combinators/ref.ts +109 -0
  241. package/src/combinators/regex.ts +170 -0
  242. package/src/combinators/repeat.ts +561 -0
  243. package/src/combinators/scanTo.ts +393 -0
  244. package/src/combinators/sequence.ts +221 -0
  245. package/src/combinators/token.ts +120 -0
  246. package/src/combinators/trivia-boundary.ts +48 -0
  247. package/src/combinators/trivia-skip.ts +821 -0
  248. package/src/combinators/withCtx.ts +45 -0
  249. package/src/compiler/build-arity.ts +330 -0
  250. package/src/compiler/compile-linkable-table.ts +209 -0
  251. package/src/compiler/degradation.ts +266 -0
  252. package/src/compiler/fields.ts +191 -0
  253. package/src/compiler/grammar-coverage-ids.ts +129 -0
  254. package/src/compiler/ir-serialize.ts +615 -0
  255. package/src/compiler/linker.ts +954 -0
  256. package/src/compiler/token-alphabet.ts +209 -0
  257. package/src/compiler/token-dispatch.ts +353 -0
  258. package/src/compiler/token-scanner.ts +318 -0
  259. package/src/compiler/value-usage.ts +147 -0
  260. package/src/coverage.ts +383 -0
  261. package/src/cst/capture-buffer.ts +297 -0
  262. package/src/cst/host-mode.ts +69 -0
  263. package/src/cst/reflection-attach.ts +11 -0
  264. package/src/cst/reflection-symbols.ts +9 -0
  265. package/src/cst/reflection.ts +149 -0
  266. package/src/cst/relative-spans.ts +207 -0
  267. package/src/cst/root-trivia-scope.ts +30 -0
  268. package/src/cst/trivia-charscan.ts +312 -0
  269. package/src/cst/trivia-entries.ts +285 -0
  270. package/src/cst/trivia-index.ts +131 -0
  271. package/src/cst/trivia-kinds.ts +358 -0
  272. package/src/cst/types.ts +76 -0
  273. package/src/cst/walk.ts +101 -0
  274. package/src/functional/doc.ts +959 -0
  275. package/src/functional/run-tabled.ts +153 -0
  276. package/src/functional/run.ts +558 -0
  277. package/src/grammar-metadata.ts +2 -0
  278. package/src/index.ts +189 -0
  279. package/src/language-service/index.ts +221 -0
  280. package/src/line-index.ts +131 -0
  281. package/src/oracle/digest.ts +620 -0
  282. package/src/oracle/index.ts +55 -0
  283. package/src/parse-context.ts +91 -0
  284. package/src/plugin/direct-builder-static.ts +102 -0
  285. package/src/plugin/evaluator.ts +1505 -0
  286. package/src/plugin/free-identifiers.ts +338 -0
  287. package/src/plugin/index.ts +2281 -0
  288. package/src/plugin/reducer-resolver.ts +606 -0
  289. package/src/recovery/scan.ts +155 -0
  290. package/src/regex/classes.ts +183 -0
  291. package/src/regex/first-set.ts +316 -0
  292. package/src/run/index.ts +31 -0
  293. package/src/spec/ebnf.ts +128 -0
  294. package/src/spec/index.ts +54 -0
  295. package/src/spec/model.ts +636 -0
  296. package/src/spec/railroad-lib.ts +559 -0
  297. package/src/spec/railroad.ts +256 -0
  298. package/src/table/assemble.ts +2994 -0
  299. package/src/table/cell.ts +42 -0
  300. package/src/table/child-slots.ts +113 -0
  301. package/src/table/compile-rule-map.ts +336 -0
  302. package/src/table/compile.ts +244 -0
  303. package/src/table/duplication-hook.ts +89 -0
  304. package/src/table/emit-assembly.ts +1766 -0
  305. package/src/table/emit.ts +418 -0
  306. package/src/table/encode-baseline.ts +340 -0
  307. package/src/table/encode.ts +1569 -0
  308. package/src/table/exec-baseline.ts +537 -0
  309. package/src/table/exec.ts +1672 -0
  310. package/src/table/fold.ts +38 -0
  311. package/src/table/index.ts +108 -0
  312. package/src/table/inspect.ts +52 -0
  313. package/src/table/ops.ts +459 -0
  314. package/src/table/program.ts +855 -0
  315. package/src/table/run-support.ts +66 -0
  316. package/src/table/scan-shapes.ts +1578 -0
  317. package/src/table/site-labels.ts +228 -0
  318. package/src/table/stamp.ts +229 -0
  319. package/src/types.ts +563 -0
  320. package/src/version.ts +16 -0
  321. package/dist/compiler/codegen.d.ts +0 -334
  322. package/dist/compiler/codegen.d.ts.map +0 -1
  323. package/dist/compiler/inline-build.d.ts +0 -11
  324. package/dist/compiler/inline-build.d.ts.map +0 -1
  325. package/dist/compiler/inline-callback.d.ts +0 -21
  326. package/dist/compiler/inline-callback.d.ts.map +0 -1
  327. package/dist/compiler/line-index.d.ts +0 -2
  328. package/dist/compiler/line-index.d.ts.map +0 -1
  329. package/dist/compiler/scannable-run.d.ts.map +0 -1
  330. package/dist/compiler/scannable-terminal.d.ts +0 -23
  331. package/dist/compiler/scannable-terminal.d.ts.map +0 -1
  332. package/dist/compiler/trivia-fast-path.d.ts +0 -38
  333. package/dist/compiler/trivia-fast-path.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- import type { ParseContext, ParseFail } from '../types.ts';
1
+ import type { Combinator, ParseContext, ParseFail } from '../types.ts';
2
2
  /**
3
3
  * Result of scanning trivia: the position after it, plus a `commit()` that
4
4
  * records the matched trivia tokens into the active rawChildren collector.
@@ -20,9 +20,17 @@ export type TriviaRollbackMark = {
20
20
  log: number;
21
21
  rootLog: number;
22
22
  };
23
+ export type FastTriviaScanner = (input: string, cur: number) => number;
23
24
  /** True when trivia recording must be deferred until the following term commits. */
24
25
  export declare function needsDeferredTriviaCommit(ctx: ParseContext): boolean;
25
26
  export declare function saveTriviaMark(ctx: ParseContext): TriviaRollbackMark;
27
+ /**
28
+ * Trivia rollback from SCALAR marks — the allocation-free twin of
29
+ * `rollbackTrivia`. See `rollbackCstCaptureAt`; `saveTriviaMark` allocates twice
30
+ * (this wrapper plus the CST mark it delegates to) and the table driver took one
31
+ * per sequence term and per repetition item.
32
+ */
33
+ export declare function rollbackTriviaAt(ctx: ParseContext, raw: number, tlog: number, leaves: number, fields: number, errors: number, log: number, rootLog: number): void;
26
34
  export declare function rollbackTrivia(ctx: ParseContext, mark: TriviaRollbackMark): void;
27
35
  /**
28
36
  * A ZERO-WIDTH LOOKAHEAD's mark: everything `saveTriviaMark` covers, plus the
@@ -56,9 +64,40 @@ export declare function advanceTrivia(input: string, cur: number, ctx: ParseCont
56
64
  * position after the trivia (or `cur` if none) and a `commit()` to record it.
57
65
  */
58
66
  export declare function scanTrivia(input: string, cur: number, ctx: ParseContext): TriviaScan;
67
+ /**
68
+ * Skip trivia at `cur` through an INSTALLED scanner, recording it immediately.
69
+ *
70
+ * The table drivers install a scanner only for UNLABELLED trivia with
71
+ * `trackLines` off, and that is exactly the case where the deferred path's whole
72
+ * commit is the single row `(cur, end)` — so there is nothing to defer, and the
73
+ * `{ end, commit }` pair plus its closure that `scanTrivia(…).commit()` allocated
74
+ * on EVERY sequence term of EVERY capturing grammar buy nothing. This is that
75
+ * branch with the allocations removed, kept here so recording has one home.
76
+ */
77
+ export declare function skipTriviaScanned(s: FastTriviaScanner, input: string, cur: number, ctx: ParseContext): number;
59
78
  /**
60
79
  * Consume trivia at `cur`, recording it immediately. For callers that always
61
80
  * accept the trivia between two committed terms (e.g. sequence/sepBy).
62
81
  */
63
82
  export declare function consumeTrivia(input: string, cur: number, ctx: ParseContext): number;
83
+ /**
84
+ * End of the trivia run at `cur`, WITHOUT recording any of it.
85
+ *
86
+ * The read-only twin of `consumeTrivia`, for a zero-width ASSERTION that wants the
87
+ * adjacency fact and must leave no trace: the deferred path returns a scan whose
88
+ * `commit()` is simply never called, so nothing lands in any buffer and there is
89
+ * nothing to roll back. The following term re-scans the same gap and owns the
90
+ * commit/rewind decision exactly as if the assertion were not there.
91
+ */
92
+ export declare function probeTriviaEnd(input: string, cur: number, ctx: ParseContext): number;
93
+ /**
94
+ * The specialised scanner for a trivia combinator, or null when its shape has no
95
+ * lowering. Memoized on the combinator.
96
+ *
97
+ * EXPORTED because G5's leaf swap needs it at TABLE-BUILD time: the table driver
98
+ * resolves the scanner once, per trivia entry, and installs the closure at scope
99
+ * entry — where the generic path called this (a WeakMap lookup) plus a chain of
100
+ * option branches on EVERY sequence term.
101
+ */
102
+ export declare function fastTriviaScanner(trivia: Combinator<unknown>): FastTriviaScanner | null;
64
103
  //# sourceMappingURL=trivia-skip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trivia-skip.d.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.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAyC,MAAM,aAAa,CAAA;AAEpF;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAchF"}
1
+ {"version":3,"file":"withCtx.d.ts","sourceRoot":"","sources":["../../src/combinators/withCtx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAyC,MAAM,aAAa,CAAA;AAEpF;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAgChF"}
@@ -1 +1 @@
1
- {"version":3,"file":"build-arity.d.ts","sourceRoot":"","sources":["../../src/compiler/build-arity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAG5C;;;;;;;;;;GAUG;AAEH,KAAK,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAElD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAErD;AAgCD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgC9D;AAoHD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAErD;AAmCD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAkBhE;AAED,uFAAuF;AACvF,wBAAgB,kBAAkB,CAAC,GA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
1
+ import type { Combinator } from '../types.ts';
2
+ import type { HostMode } from '../cst/host-mode.ts';
3
+ import { type GrammarReflection } from '../cst/reflection.ts';
4
+ import { type TableRuleMapOptions } from '../table/compile-rule-map.ts';
5
+ import type { TableProgram, TableRule } from '../table/program.ts';
6
+ /**
7
+ * `compileLinkable()` FOR THE TABLE LOWERING — `linkable()` produces TABLES too.
8
+ *
9
+ * ── WHAT `compileLinkable` ACTUALLY RETURNS, AND WHY NONE OF IT TRANSFERS ─────
10
+ * `LinkablePieces` is `prelude` / `ruleFns` / `wrappers` / `firstSets` /
11
+ * `firstSetRecipes` / `nullable` / `deps` / `needsEmptyTl` — every field of it is
12
+ * SOURCE TEXT or an input to resolving source text. It exists because
13
+ * source-lowering composition is a TEXTUAL splice: `fusedBody()` concatenates
14
+ * namespaced preludes, picks a winning `_r_<Name>` per name, and substitutes
15
+ * `@FS:` dispatch placeholders with the winner's first-set condition. A table has
16
+ * no text to splice and no placeholders to resolve, so porting those fields would
17
+ * be porting the mechanism rather than the capability.
18
+ *
19
+ * The capability is: a piece must be RUNNABLE on its own, and COMPOSABLE with
20
+ * other pieces. This artifact carries exactly those two things.
21
+ *
22
+ * `prog` / `rules` — the piece AS A TABLE. Present whenever the piece is
23
+ * self-contained. This is the ruling: a `linkable()`
24
+ * artifact is a table, not a bag of compiled functions.
25
+ * `ir` — the piece's combinator graph, serialized. This is the
26
+ * composable half, and it is NOT new machinery: the plugin
27
+ * already carries pieces as IR (`plugin/index.ts:1772`) and
28
+ * the linker already re-lowers them (`linker.ts:640`,
29
+ * `compileLinkable(evalRuleMapIR(p.ir), …)`).
30
+ *
31
+ * ── WHY THAT MAKES COMPOSITION THE EASY KIND ─────────────────────────────────
32
+ * The open question was whether table-to-table composition has to merge two
33
+ * ALREADY-ENCODED programs — relocating code offsets and merging const, fn,
34
+ * class, expected and dispatch pools. It does not, as long as every piece
35
+ * carries its IR: the composer evaluates each piece's IR back to a rule map,
36
+ * merges the maps (later pieces overriding earlier names, which is what
37
+ * `compose()` means), and calls `encodeTable` ONCE over the merged map. One
38
+ * encode, no relocation, and the result is byte-for-byte the table the merged
39
+ * grammar would have produced if it had been written as one `rules()` call.
40
+ *
41
+ * The relocation route is only forced for a piece with NO IR, which is why `ir`
42
+ * being null is reported here as a first-class fact rather than folded into a
43
+ * bare `null` return.
44
+ *
45
+ * ── THE HOLE CASE IS NOT REFUSED ─────────────────────────────────────────────
46
+ * A piece that references a rule it does not define (`g.Value` with no
47
+ * `.define()` — `hasExternalRuleRef`'s SHARED-SHAPE signature) cannot be encoded
48
+ * standalone: `encodeTable` resolves a `lazy` by calling its thunk, and that
49
+ * thunk throws. Such a piece gets `prog: null` and `rules: null` and keeps its
50
+ * `ir`, which is the correct answer rather than a refusal: a shape with a hole
51
+ * is not a parser in ANY lowering, and it composes through the merge above,
52
+ * where the hole is filled by whichever piece supplies the name.
53
+ */
54
+ export type LinkableTableOptions = Omit<TableRuleMapOptions, 'runtimeRef'>;
55
+ export type LinkableTable = {
56
+ /**
57
+ * The parseman version that produced this artifact — the same ARTIFACT VERSION
58
+ * LOCK `LinkablePieces.v` carries, for the same reason: artifacts are
59
+ * version-locked and the format has no back-compat read path.
60
+ */
61
+ v: string;
62
+ ns: string;
63
+ /** Local rule names, external (undefined) entries already dropped. */
64
+ keys: string[];
65
+ /** Rule names this piece REFERENCES but does not define. */
66
+ external: string[];
67
+ /** The piece as a table — null when it has holes (see `external`). */
68
+ prog: TableProgram | null;
69
+ /** The runnable form of `prog` — null for the same reason. */
70
+ rules: Record<string, TableRule> | null;
71
+ /** The emitted expression for `prog`, or null when there is no `prog`. */
72
+ replacement: string | null;
73
+ /**
74
+ * The piece's combinator graph, serialized — the COMPOSABLE half. Null when
75
+ * the map cannot be faithfully serialized (a callback with no captured
76
+ * source); a null here is what would force composition to merge encoded
77
+ * programs instead of merging rule maps.
78
+ */
79
+ ir: string | null;
80
+ /**
81
+ * The piece's rule map as LIVE COMBINATORS — present only for an in-process
82
+ * artifact, never serialized.
83
+ *
84
+ * `ir` is the portable composable half, and a grammar BUILT AT RUNTIME often has no
85
+ * `ir` at all (a live callback has no recoverable source). Such a piece still has to
86
+ * compose, and in-process it can: the combinators themselves are right there. Without
87
+ * this the runtime `compose([linkable(g)])` refused a grammar the source lowering
88
+ * composed happily.
89
+ */
90
+ ruleMap: ReadonlyArray<readonly [string, Combinator<unknown>]>;
91
+ hostMode: HostMode;
92
+ hostBranchElided: boolean;
93
+ /**
94
+ * Whether any rule carries a DIRECT builder, and whether the piece is free of
95
+ * semantic reduction. `composeLeaf` gates on both, and they are predicates over the
96
+ * combinator graph rather than products of lowering it — so they belong on the
97
+ * artifact regardless of which lowering produced it.
98
+ */
99
+ hasDirectBuilders: boolean;
100
+ isRecognitionOnly: boolean;
101
+ reflection: GrammarReflection;
102
+ };
103
+ export declare function compileLinkableTable(ruleMapArg: ReadonlyArray<readonly [string, Combinator<unknown>]>, ns: string, opts?: LinkableTableOptions): LinkableTable | null;
104
+ //# sourceMappingURL=compile-linkable-table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-linkable-table.d.ts","sourceRoot":"","sources":["../../src/compiler/compile-linkable-table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO,EAA4B,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAGvF,OAAO,EAA0C,KAAK,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAC/G,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAGlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAA;AAE1E,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;OAIG;IACH,CAAC,EAAE,MAAM,CAAA;IACT,EAAE,EAAE,MAAM,CAAA;IACV,sEAAsE;IACtE,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,sEAAsE;IACtE,IAAI,EAAE,YAAY,GAAG,IAAI,CAAA;IACzB,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI,CAAA;IACvC,0EAA0E;IAC1E,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B;;;;;OAKG;IACH,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;IACjB;;;;;;;;;OASG;IACH,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAC9D,QAAQ,EAAE,QAAQ,CAAA;IAClB,gBAAgB,EAAE,OAAO,CAAA;IACzB;;;;;OAKG;IACH,iBAAiB,EAAE,OAAO,CAAA;IAC1B,iBAAiB,EAAE,OAAO,CAAA;IAC1B,UAAU,EAAE,iBAAiB,CAAA;CAC9B,CAAA;AAyCD,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EACjE,EAAE,EAAE,MAAM,EACV,IAAI,GAAE,oBAAyB,GAC9B,aAAa,GAAG,IAAI,CAwDtB"}
@@ -27,8 +27,6 @@ export type DegradationLevel = 'off' | 'warn' | 'error';
27
27
  export type DegradationCode =
28
28
  /** A node build's formal parameter list could not be read → all capture tiers kept. */
29
29
  'build-arity-unconfirmed'
30
- /** A node build looks like an `mk(...)` wrapper but did not match → no inline-mk. */
31
- | 'mk-inline-missed'
32
30
  /** A composed/carried piece is an opaque artifact → its rules were not analysed. */
33
31
  | 'opaque-artifact'
34
32
  /** A coverage-definition request could not read the grammar → empty is NOT a zero.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D,8DAA8D;AAC9D,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C;AAED,4EAA4E;AAC5E,wBAAgB,qBAAqB,IAAI,WAAW,EAAE,CAGrD;AAED,6EAA6E;AAC7E,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAOrE;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,CAKrF;AA2BD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI,CAatD;AAKD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,4BAA4B,IAAI,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAsBxE;AAED,kDAAkD;AAClD,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED,qFAAqF;AACrF,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD"}
@@ -17,6 +17,19 @@ export declare function parserHasOwnFields(p: Combinator<unknown>, seen?: Set<Co
17
17
  * shape returns `true` (keep the frame) — we only elide when provably safe.
18
18
  */
19
19
  export declare function parserHasTriviaSite(p: Combinator<unknown>, seen?: Set<Combinator<unknown>>): boolean;
20
+ /**
21
+ * The same question asked of the ROOT trivia log (`_ctx._rootTriviaLog`) instead
22
+ * of the current node's frame.
23
+ *
24
+ * The two differ in exactly one case, and it is the case that matters: a nested
25
+ * `node()` manages its own FRAME, so nothing inside it reaches the enclosing
26
+ * frame's log — but the root log is not a frame, and every trivia run inside that
27
+ * node still lands in it. Reusing `parserHasTriviaSite` for the root sink
28
+ * therefore under-reports: it dropped the mark on `node()` arms whose trivia does
29
+ * accumulate, and a parse-tree diff caught it as trivia entries that were no
30
+ * longer rewound on a failed choice arm (`length: 3` becoming `length: 6`).
31
+ */
32
+ export declare function parserHasRootTriviaSite(p: Combinator<unknown>, seen?: Set<Combinator<unknown>>): boolean;
20
33
  /**
21
34
  * Can this node's inner grammar explicitly enable trivia capture? A surrounding
22
35
  * node owns the collector, so a nested `parser({ captureTrivia: true })` must
@@ -1 +1 @@
1
- {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/compiler/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAGlE,KAAK,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAElD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAKtD;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,IAAI,GAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAa,GAAG,OAAO,CAmC9G;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,IAAI,GAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAa,GAAG,OAAO,CA4C/G;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,IAAI,GAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAa,GAAG,OAAO,CAmCtH;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAW/J"}
1
+ {"version":3,"file":"fields.d.ts","sourceRoot":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
  export type GrammarCoveragePlan = {
7
7
  definitions: readonly GrammarCoverageDefinition[];
8
- choices: WeakMap<Combinator<unknown>, readonly string[]>;
9
- dispatches: WeakMap<Combinator<unknown>, readonly string[]>;
8
+ choices: Map<Combinator<unknown>, readonly string[]>;
9
+ dispatches: Map<Combinator<unknown>, readonly string[]>;
10
10
  /** Trace-only transaction identity. Attempts are not coverage definitions: a
11
11
  * rejected transaction must not create a semantic winner or denominator. */
12
- attempts: WeakMap<Combinator<unknown>, string>;
13
- labels: WeakMap<Combinator<unknown>, readonly string[]>;
14
- rules: WeakMap<Combinator<unknown>, string>;
12
+ attempts: Map<Combinator<unknown>, string>;
13
+ labels: Map<Combinator<unknown>, readonly string[]>;
14
+ rules: Map<Combinator<unknown>, string>;
15
15
  };
16
16
  /** Canonical deterministic IDs for one explicit entry closure, or every public
17
17
  * entry in a `rules()` map. Multiple roots share identity maps so a shared
@@ -1 +1 @@
1
- {"version":3,"file":"grammar-coverage-ids.d.ts","sourceRoot":"","sources":["../../src/compiler/grammar-coverage-ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,aAAa,CAAA;AAGxD,MAAM,MAAM,yBAAyB,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,cAAc,GAAG,OAAO,CAAA;CAAE,CAAA;AAC9G,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,SAAS,yBAAyB,EAAE,CAAA;IACjD,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC,CAAA;IACxD,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC,CAAA;IAC3D;gFAC4E;IAC5E,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAA;IAC9C,MAAM,EAA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C;AACzC,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,SAAS,UAAU,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,mBAAmB,CA8DhK"}
@@ -1 +1 @@
1
- {"version":3,"file":"ir-serialize.d.ts","sourceRoot":"","sources":["../../src/compiler/ir-serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAkC,MAAM,aAAa,CAAA;AAsB7E,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;AA+E/B,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,EAC/C,QAAQ,CAAC,EAAE,SAAS,IAAI,EAAE,GAAG,IAAI,GAChC,MAAM,GAAG,IAAI,CAUf;AAED;;oFAEoF;AACpF,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAyG/D"}
1
+ {"version":3,"file":"ir-serialize.d.ts","sourceRoot":"","sources":["../../src/compiler/ir-serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAkC,MAAM,aAAa,CAAA;AAuB7E,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;AAiG/B,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,EAC/C,QAAQ,CAAC,EAAE,SAAS,IAAI,EAAE,GAAG,IAAI,GAChC,MAAM,GAAG,IAAI,CAUf;AAED;;oFAEoF;AACpF,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAyG/D"}
@@ -1,6 +1,8 @@
1
- import type { LinkablePieces, HostMode } from './codegen.ts';
1
+ import { type HostMode } from '../cst/host-mode.ts';
2
+ import { type LinkableTable } from './compile-linkable-table.ts';
2
3
  import type { BuildHost, Combinator, CstCollapsePredicate, ParseContext, ParseResult } from '../types.ts';
3
- export declare function linkable(rulesMap: Record<string, Combinator<unknown>>, ns?: string, trivia?: Combinator<unknown>, hostMode?: HostMode): LinkablePieces;
4
+ import type { Runnable } from '../functional/run.ts';
5
+ export declare function linkable(rulesMap: Record<string, Combinator<unknown>>, ns?: string, trivia?: Combinator<unknown>, hostMode?: HostMode): LinkableTable;
4
6
  export type CstBuildHostOptions = {
5
7
  /**
6
8
  * Collapse transparent one-child CST wrapper nodes at build time.
@@ -41,51 +43,33 @@ export declare function cstBuildHost(type: string, children: ReadonlyArray<unkno
41
43
  export type FusedRule = (input: string, pos: number, ctx: ParseContext | Record<string, unknown>) => ParseResult<unknown> & {
42
44
  readonly value?: unknown;
43
45
  };
44
- /**
45
- * Restrict a grammar/artifact to `names` plus their transitive rule-dependency
46
- * closure (à la carte selection) — e.g. Jess taking parts of Less and parts of
47
- * Sass: `compose([pick(less, ['MixinCall']), pick(sass, ['EachFor']), css])`. A
48
- * picked rule pulls in every rule name it references, so the result is always
49
- * self-consistent within the artifact. Accepts a grammar (`rules()` result) or a
50
- * compiled artifact; returns an artifact for `compose()`.
51
- */
52
- export declare function pick(grammar: LinkablePieces | Record<string, Combinator<unknown>>, names: string[]): LinkablePieces;
53
- /** Restrict a set of linkable pieces to `names` + their transitive dep closure,
54
- * keeping each surviving rule in the piece that WINS it (later piece wins, matching
55
- * compose override order). Shared by `pick()` (runtime) and the macro's build-time
56
- * `pick(...)` handling, so à-la-carte selection is identical on both paths. */
57
- export declare function pickPieces(pieces: LinkablePieces[], names: string[]): LinkablePieces[];
58
- /**
59
- * Build the fused-closure body (shared by the runtime `fuseRules` and the
60
- * build-time `emitFusedSource`). Returns the closure body (which reads `_env`
61
- * for any non-inlined callbacks) and the `_env` to bind. In macro mode callbacks
62
- * are inlined from source, so `_env` is empty and the body is fully static.
63
- */
64
- export declare function fusedBody(pieces: LinkablePieces[]): {
65
- body: string;
66
- env: Record<string, unknown>;
67
- };
68
- /** Fuse at RUNTIME (via `new Function`) — used by `compose()` when not compiled
69
- * by the macro (like `compile()`). The macro path uses `emitFusedSource` instead.
70
- * Both stamp the host mode from inside `fusedBody`; see `hostModeOfPieces`. */
71
- export declare function fuseRules(pieces: LinkablePieces[]): Record<string, FusedRule>;
72
46
  export { FUSED_HOST_MODE, FUSED_HOST_ELIDED } from '../cst/host-mode.ts';
73
47
  /** The host mode a fused/composed rule map was built for. Defaults to 'ast'. */
74
48
  export declare function fusedHostModeOf(registry: object): HostMode;
75
49
  /** Whether a fused/composed rule map dropped any direct builder's CST branch. */
76
50
  export declare function fusedHostElidedOf(registry: object): boolean;
77
51
  /**
78
- * Fuse at BUILD time — emit the fused closure as a self-contained SOURCE
79
- * expression (`(() => { … })()`), with **no `new Function`**. This is what the
80
- * macro splices in for a `compose([...])` call, so macro output stays eval-free.
81
- * Requires every callback to be inlined from source (macro mode); throws if any
82
- * artifact carries runtime-only callback functions.
52
+ * Compose grammars/artifacts into a runnable parser map — the ONLY public
53
+ * composition entry point. `compose([base, ext, …])`: later entries override
54
+ * earlier ones by rule name, and because fusion re-binds every reference in one
55
+ * shared scope, an override reroutes the base's OWN calls too (open recursion).
56
+ *
57
+ * Each entry may be a **grammar** (a `rules()` result — a map of combinators,
58
+ * linkable-ified here) OR an already-compiled **linkable artifact** (what the
59
+ * macro emits and a package ships). So a package needs no opt-in wrapper to be
60
+ * composable — `compose([importedGrammar, myRules])` just works.
61
+ *
62
+ * The macro compiles `compose([...])` to STATIC fused source (no `new Function`).
63
+ * Called at runtime (no macro, like `compile()`) it fuses via `new Function`.
83
64
  */
84
- export declare function emitFusedSource(pieces: LinkablePieces[]): string;
65
+ /** A composed parser carries its flattened source pieces (non-enumerable) so it
66
+ * can be composed AGAIN — `compose([lessGrammar, delta])` where `lessGrammar` is
67
+ * itself a `compose([...])` result. */
68
+ export declare const COMPOSED_PIECES: unique symbol;
85
69
  /** The carried pieces a `compose()`/`composeLeaf()` result holds, or `undefined` when
86
70
  * the value is not a composed grammar. This is what makes a fused grammar analysable:
87
71
  * the pieces are re-lowerable IR even though the fused map itself is only functions. */
88
- export declare function composedPiecesOf(grammar: Record<string, unknown>): ReadonlyArray<LinkablePieces | IRPiece> | undefined;
72
+ export declare function composedPiecesOf(grammar: Record<string, unknown>): ReadonlyArray<LinkableTable | IRPiece> | undefined;
89
73
  /** The compact IR form a grammar carries instead of its lowered rule source: the
90
74
  * combinator-construction expression, re-lowered here at fuse time. */
91
75
  export type IRPiece = {
@@ -105,10 +89,10 @@ export declare function once<T>(fn: () => T): () => T;
105
89
  * Skipping is not the same as having nothing to say. Use `carriedRuleMapsDetailed`
106
90
  * where the skip must be REPORTED — a diagnostic that drops part of the grammar and
107
91
  * then returns a clean result is indistinguishable from one that verified it. */
108
- export declare function carriedRuleMaps(carried: ReadonlyArray<LinkablePieces | IRPiece>): Array<Array<[string, Combinator<unknown>]>>;
92
+ export declare function carriedRuleMaps(carried: ReadonlyArray<LinkableTable | IRPiece>): Array<Array<[string, Combinator<unknown>]>>;
109
93
  /** `carriedRuleMaps` plus the pieces it could NOT re-lower, named by namespace and
110
94
  * rule count, so a caller can report exactly how much of the grammar went unseen. */
111
- export declare function carriedRuleMapsDetailed(carried: ReadonlyArray<LinkablePieces | IRPiece>): {
95
+ export declare function carriedRuleMapsDetailed(carried: ReadonlyArray<LinkableTable | IRPiece>): {
112
96
  maps: Array<Array<[string, Combinator<unknown>]>>;
113
97
  opaque: Array<{
114
98
  ns: string;
@@ -138,10 +122,7 @@ export declare function recoverComposedRules(grammar: Record<string, unknown>):
138
122
  * `compose()`, or `undefined` when a precompiled opaque artifact participated.
139
123
  * This is intentionally internal: callers must not treat it as a parser API. */
140
124
  export declare function composedCoverageRules(grammar: Record<string, unknown>): Record<string, Combinator<unknown>> | undefined;
141
- /** Materialize a carried item to full `LinkablePieces`: an IR piece is evaluated
142
- * back to a rule map and re-lowered; a full piece passes through. */
143
- export declare function materializePiece(p: LinkablePieces | IRPiece, trivia?: Combinator<unknown>, captureTerminals?: boolean, hostMode?: HostMode): LinkablePieces;
144
- export declare function compose(items: Array<LinkablePieces | Record<string, unknown>>,
125
+ export declare function compose(items: Array<LinkableTable | Record<string, unknown>>,
145
126
  /**
146
127
  * Compile-time host mode for the fused artifact, same meaning as
147
128
  * `compile(g, { hostMode })`. Omit (or `'ast'`) for the eval driver — the fused rules
@@ -155,9 +136,60 @@ opts?: {
155
136
  }): Record<string, FusedRule>;
156
137
  /**
157
138
  * Compose a terminal grammar. This is for a leaf parser that overlays local
158
- * semantic reductions on reusable recognition rules. It is macro-only: without
159
- * macro lowering there is no safe way to keep lexical builders out of carried
160
- * IR, so it fails rather than falling back to runtime composition.
139
+ * semantic reductions on reusable recognition rules.
140
+ *
141
+ * Under the macro this lowers to STATIC fused source (functions), exactly like
142
+ * `compose()`. It is still macro-only as a *compiled* artifact: without macro
143
+ * lowering there is no safe way to keep lexical builders out of carried IR, so it
144
+ * never falls back to runtime CODEGEN composition.
145
+ *
146
+ * Called at runtime (no macro) it returns the INTERPRETED fuse of the same items —
147
+ * a combinator map, not a map of compiled functions (`fuseInterpreted`), fused lazily
148
+ * per rule name.
149
+ *
150
+ * THE RETURN TYPE IS `Runnable`, NOT `FusedRule`, BECAUSE BOTH PATHS ARE REAL. A macro
151
+ * build yields fused functions; an un-macro'd call yields combinators. `Runnable` is
152
+ * already the library's name for "either of those" — it is what `run()` and
153
+ * `parseDoc()` take — so the declared type is TRUE on both paths and a caller needs no
154
+ * narrowing to use the result. This used to declare `Record<string, FusedRule>` and
155
+ * launder the runtime path through an `as unknown as`, which let a caller hold a
156
+ * combinator map while the type promised compiled functions.
157
+ *
158
+ * Do NOT "fix" this by deleting the runtime path. It is load-bearing: the `bench/jess`
159
+ * harness family and two differential-gate legs (`emit-identity-one`,
160
+ * `scan-shape-oracle-one`) import un-macro'd grammar modules and depend on this lazy
161
+ * interpreted fuse, one dialect per process. Whether an un-macro'd `composeLeaf()`
162
+ * should exist at all is a separate, open owner question — but while the gates depend
163
+ * on it, it exists, and the type says so.
164
+ */
165
+ export declare function composeLeaf(items: Array<LinkableTable | Record<string, unknown>>): Record<string, Runnable>;
166
+ /** Whether `map` is an interpreted fuse (a combinator map) rather than a compiled
167
+ * `compose()` result (a map of fused functions). INTERNAL — not re-exported from
168
+ * `src/index.ts`. A consumer never has to ask this question: what it holds is
169
+ * whatever the macro built. Diagnostics that fuse interpreted on purpose do. */
170
+ export declare function isInterpretedFuse(map: object): boolean;
171
+ /**
172
+ * Materialize a composition as a RUNNABLE INTERPRETED rule map — the interpreted
173
+ * counterpart of `compose()`, with identical fuse semantics (later piece wins,
174
+ * override reroutes the base's own calls, composing trivia governs every rule).
175
+ * No codegen, no `new Function`, no macro build step: the result is a plain map of
176
+ * combinators that `run()` / `parseDoc()` accept exactly like a fused map.
177
+ *
178
+ * This is what diagnostics and profiling run against — they must stay in
179
+ * interpreted mode, and before this they could not see a composed grammar at all.
180
+ *
181
+ * Items are the SAME items `compose()`/`composeLeaf()` take: `rules()` maps
182
+ * (the intended input), a prior `fuseInterpreted()` result, or a runtime
183
+ * `compose()` result (re-lowered from its carried IR — note that carried IR cannot
184
+ * materialize direct `node()` builders, so prefer the source maps). A precompiled
185
+ * `linkable()` artifact is rejected: it has no combinator graph.
186
+ *
187
+ * MUTATION: binding a cross-piece hole rewrites the shared placeholder object every
188
+ * call site already holds — that IS how an override reaches a base piece's own
189
+ * calls. A second, DIFFERENT fusion over the same piece objects therefore throws
190
+ * rather than silently rewriting the first one's parser.
161
191
  */
162
- export declare function composeLeaf(_items: Array<LinkablePieces | Record<string, unknown>>): Record<string, FusedRule>;
192
+ export declare function fuseInterpreted(items: Array<LinkableTable | Record<string, unknown>>, opts?: {
193
+ hostMode?: HostMode;
194
+ }): Record<string, Combinator<unknown>>;
163
195
  //# sourceMappingURL=linker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"linker.d.ts","sourceRoot":"","sources":["../../src/compiler/linker.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,cAAc,EAAkB,QAAQ,EAAE,MAAM,cAAc,CAAA;AAG5E,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,oBAAoB,EAAY,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAcnH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,EAC7C,EAAE,CAAC,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAK5B,QAAQ,CAAC,EAAE,QAAQ,GAClB,cAAc,CAQhB;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,GAAG,oBAAoB,CAAA;IAC7D;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AA4BD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAA;AACtE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,EAChC,MAAM,EAAE,OAAO,EACf,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EACpC,WAAW,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,EACpC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,EAC7B,KAAK,CAAC,EAAE,OAAO,EACf,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,GA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— every
5
+ * `literal`, `keywords`, and `regex`. This module walks the combinator graph
6
+ * and assigns each distinct terminal a small integer TOKEN ID.
7
+ *
8
+ * Two things are deliberately separated, because conflating them is what makes
9
+ * a naive derived scanner useless:
10
+ *
11
+ * - The token ID SPACE is GLOBAL. One id per distinct terminal across the whole
12
+ * grammar, so an id can be compared, switched on, and indexed with.
13
+ * - The CANDIDATE SET is LOCAL, per decision point. Global maximal munch over
14
+ * the whole alphabet is wrong: a css alphabet contains construct-local
15
+ * long-run terminals (`[^()]+`, `[^{}/]+`, the `scanTo` raw-prelude runs)
16
+ * that swallow the document. Measured: global munch yields SEVEN tokens for a
17
+ * 123 KB stylesheet. A decision point consults only the terminals that can
18
+ * actually start one of its arms.
19
+ *
20
+ * Nothing here decides HOW a token is recognized (see `token-scanner.ts`); this
21
+ * module only decides WHAT the tokens are and WHICH ones each site may see.
22
+ */
23
+ import type { Combinator } from '../types.ts';
24
+ /** A terminal in the derived alphabet, with its globally assigned id. */
25
+ export type TokenTerminal = {
26
+ kind: 'literal';
27
+ id: number;
28
+ value: string;
29
+ caseInsensitive: boolean;
30
+ } | {
31
+ kind: 'keywords';
32
+ id: number;
33
+ words: readonly string[];
34
+ caseInsensitive: boolean;
35
+ boundary: string | undefined;
36
+ } | {
37
+ kind: 'regex';
38
+ id: number;
39
+ source: string;
40
+ flags: string;
41
+ };
42
+ /** Reserved ids. Real terminals start at `FIRST_TERMINAL_ID`. */
43
+ export declare const TOK_EOF = 0;
44
+ export declare const TOK_UNKNOWN = 1;
45
+ export declare const TOK_WS = 2;
46
+ export declare const FIRST_TERMINAL_ID = 3;
47
+ export type Alphabet = {
48
+ terminals: TokenTerminal[];
49
+ /** Dedup key → id, so the same terminal spelled twice gets ONE id. */
50
+ byKey: Map<string, number>;
51
+ /** The combinator that contributed each id (first one wins), for candidate sets. */
52
+ originOf: Map<number, Combinator<unknown>>;
53
+ };
54
+ /** Direct sub-parsers of a def, resolving a lazy through `resolve` when its own thunk is a hole. */
55
+ export declare function tokenChildren(p: Combinator<unknown>, resolve?: (name: string) => Combinator<unknown> | undefined): Combinator<unknown>[];
56
+ /**
57
+ * Collect the alphabet over `roots`. Ids are assigned in first-encounter order,
58
+ * which is stable for a given grammar and therefore safe to switch on.
59
+ */
60
+ export declare function collectAlphabet(roots: ReadonlyArray<Combinator<unknown>>, resolve?: (name: string) => Combinator<unknown> | undefined): Alphabet;
61
+ /** The id already assigned to this terminal, if it is one. */
62
+ export declare function terminalId(alphabet: Alphabet, p: Combinator<unknown>): number | undefined;
63
+ /**
64
+ * The LEADING terminal of an arm — the one a decision point would consult. Walks
65
+ * through the wrappers that do not consume input, and through a sequence's
66
+ * nullable/zero-width prefix. Returns undefined when the lead is not a single
67
+ * derived terminal, which is the signal to stay scannerless at that site.
68
+ */
69
+ export declare function leadTerminal(p: Combinator<unknown>, alphabet: Alphabet, resolve?: (name: string) => Combinator<unknown> | undefined, depth?: number): number | undefined;
70
+ /**
71
+ * The CANDIDATE SET for one decision point: the leading terminals of its arms.
72
+ * `complete` is false when any arm's lead is not a derived terminal — that site
73
+ * must stay scannerless, per-construct, exactly as `scanSkip` and first-set
74
+ * gating already apply per region rather than globally.
75
+ */
76
+ export type CandidateSet = {
77
+ ids: number[];
78
+ complete: boolean;
79
+ };
80
+ export declare function candidateSet(arms: ReadonlyArray<Combinator<unknown>>, alphabet: Alphabet, resolve?: (name: string) => Combinator<unknown> | undefined): CandidateSet;
81
+ //# sourceMappingURL=token-alphabet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-alphabet.d.ts","sourceRoot":"","sources":["../../src/compiler/token-alphabet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,aAAa,CAAA;AAExD,yEAAyE;AACzE,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,M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