parseman 0.46.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 (316) hide show
  1. package/README.md +8 -3
  2. package/dist/analysis/choice-cost-render.d.ts +12 -4
  3. package/dist/analysis/choice-cost-render.d.ts.map +1 -1
  4. package/dist/analysis/choice-cost.d.ts +2 -2
  5. package/dist/analysis/choice-cost.d.ts.map +1 -1
  6. package/dist/analysis/commitment.d.ts +131 -0
  7. package/dist/analysis/commitment.d.ts.map +1 -0
  8. package/dist/analysis/diagnostics.cjs +9929 -7465
  9. package/dist/analysis/diagnostics.cjs.map +3 -4
  10. package/dist/analysis/diagnostics.d.ts +2 -2
  11. package/dist/analysis/diagnostics.js +9929 -7465
  12. package/dist/analysis/diagnostics.js.map +3 -4
  13. package/dist/analysis/duplication.d.ts.map +1 -1
  14. package/dist/analysis/fix.d.ts +3 -3
  15. package/dist/analysis/fix.d.ts.map +1 -1
  16. package/dist/analysis/format-number.d.ts +23 -0
  17. package/dist/analysis/format-number.d.ts.map +1 -0
  18. package/dist/analysis/gating.d.ts +39 -2
  19. package/dist/analysis/gating.d.ts.map +1 -1
  20. package/dist/analysis/rebuild.d.ts.map +1 -1
  21. package/dist/analysis/terminal.d.ts +5 -2
  22. package/dist/analysis/terminal.d.ts.map +1 -1
  23. package/dist/cli/index.cjs +10865 -8535
  24. package/dist/cli/index.cjs.map +3 -4
  25. package/dist/cli/index.js +10865 -8535
  26. package/dist/cli/index.js.map +3 -4
  27. package/dist/combinators/adjacency.d.ts +100 -0
  28. package/dist/combinators/adjacency.d.ts.map +1 -0
  29. package/dist/combinators/choice.d.ts.map +1 -1
  30. package/dist/combinators/completions.d.ts.map +1 -1
  31. package/dist/combinators/dispatch.d.ts +8 -1
  32. package/dist/combinators/dispatch.d.ts.map +1 -1
  33. package/dist/combinators/expect.d.ts.map +1 -1
  34. package/dist/combinators/first-set.d.ts.map +1 -1
  35. package/dist/combinators/gate.d.ts.map +1 -1
  36. package/dist/combinators/grammar.d.ts +22 -0
  37. package/dist/combinators/grammar.d.ts.map +1 -1
  38. package/dist/combinators/literal.d.ts +8 -0
  39. package/dist/combinators/literal.d.ts.map +1 -1
  40. package/dist/combinators/map.d.ts +0 -1
  41. package/dist/combinators/map.d.ts.map +1 -1
  42. package/dist/combinators/node.d.ts +13 -3
  43. package/dist/combinators/node.d.ts.map +1 -1
  44. package/dist/combinators/parser.d.ts +1 -1
  45. package/dist/combinators/parser.d.ts.map +1 -1
  46. package/dist/combinators/ref.d.ts.map +1 -1
  47. package/dist/combinators/regex.d.ts +1 -16
  48. package/dist/combinators/regex.d.ts.map +1 -1
  49. package/dist/combinators/repeat.d.ts +30 -2
  50. package/dist/combinators/repeat.d.ts.map +1 -1
  51. package/dist/combinators/scanTo.d.ts +71 -1
  52. package/dist/combinators/scanTo.d.ts.map +1 -1
  53. package/dist/combinators/sequence.d.ts.map +1 -1
  54. package/dist/combinators/token.d.ts.map +1 -1
  55. package/dist/combinators/trivia-boundary.d.ts +26 -0
  56. package/dist/combinators/trivia-boundary.d.ts.map +1 -0
  57. package/dist/combinators/trivia-skip.d.ts +40 -1
  58. package/dist/combinators/trivia-skip.d.ts.map +1 -1
  59. package/dist/combinators/withCtx.d.ts.map +1 -1
  60. package/dist/compiler/compile-linkable-table.d.ts +104 -0
  61. package/dist/compiler/compile-linkable-table.d.ts.map +1 -0
  62. package/dist/compiler/degradation.d.ts +0 -2
  63. package/dist/compiler/degradation.d.ts.map +1 -1
  64. package/dist/compiler/fields.d.ts +13 -0
  65. package/dist/compiler/fields.d.ts.map +1 -1
  66. package/dist/compiler/grammar-coverage-ids.d.ts +5 -5
  67. package/dist/compiler/grammar-coverage-ids.d.ts.map +1 -1
  68. package/dist/compiler/ir-serialize.d.ts.map +1 -1
  69. package/dist/compiler/linker.d.ts +47 -53
  70. package/dist/compiler/linker.d.ts.map +1 -1
  71. package/dist/compiler/token-alphabet.d.ts +81 -0
  72. package/dist/compiler/token-alphabet.d.ts.map +1 -0
  73. package/dist/compiler/token-dispatch.d.ts +95 -0
  74. package/dist/compiler/token-dispatch.d.ts.map +1 -0
  75. package/dist/compiler/token-scanner.d.ts +53 -0
  76. package/dist/compiler/token-scanner.d.ts.map +1 -0
  77. package/dist/compiler/value-usage.d.ts.map +1 -1
  78. package/dist/coverage.d.ts +1 -1
  79. package/dist/coverage.d.ts.map +1 -1
  80. package/dist/cst/capture-buffer.d.ts +35 -0
  81. package/dist/cst/capture-buffer.d.ts.map +1 -1
  82. package/dist/cst/reflection-attach.d.ts +8 -0
  83. package/dist/cst/reflection-attach.d.ts.map +1 -0
  84. package/dist/cst/reflection-symbols.d.ts +10 -0
  85. package/dist/cst/reflection-symbols.d.ts.map +1 -0
  86. package/dist/cst/reflection.d.ts +2 -4
  87. package/dist/cst/reflection.d.ts.map +1 -1
  88. package/dist/cst/root-trivia-scope.d.ts +26 -0
  89. package/dist/cst/root-trivia-scope.d.ts.map +1 -0
  90. package/dist/cst/trivia-charscan.d.ts +18 -0
  91. package/dist/cst/trivia-charscan.d.ts.map +1 -0
  92. package/dist/cst/trivia-kinds.d.ts +19 -0
  93. package/dist/cst/trivia-kinds.d.ts.map +1 -1
  94. package/dist/functional/doc.d.ts.map +1 -1
  95. package/dist/functional/run-tabled.d.ts +12 -0
  96. package/dist/functional/run-tabled.d.ts.map +1 -0
  97. package/dist/functional/run.d.ts +25 -42
  98. package/dist/functional/run.d.ts.map +1 -1
  99. package/dist/grammar-metadata.d.ts +3 -0
  100. package/dist/grammar-metadata.d.ts.map +1 -0
  101. package/dist/index.cjs +9224 -7203
  102. package/dist/index.cjs.map +3 -4
  103. package/dist/index.d.ts +18 -9
  104. package/dist/index.d.ts.map +1 -1
  105. package/dist/index.js +9219 -7198
  106. package/dist/index.js.map +3 -4
  107. package/dist/language-service/index.cjs +311 -121
  108. package/dist/language-service/index.cjs.map +3 -4
  109. package/dist/language-service/index.js +311 -121
  110. package/dist/language-service/index.js.map +3 -4
  111. package/dist/oracle/index.cjs.map +0 -1
  112. package/dist/oracle/index.js.map +0 -1
  113. package/dist/parse-context.d.ts +49 -0
  114. package/dist/parse-context.d.ts.map +1 -0
  115. package/dist/plugin/evaluator.d.ts +40 -1
  116. package/dist/plugin/evaluator.d.ts.map +1 -1
  117. package/dist/plugin/index.cjs +11146 -9593
  118. package/dist/plugin/index.cjs.map +3 -4
  119. package/dist/plugin/index.d.ts.map +1 -1
  120. package/dist/plugin/index.js +11146 -9593
  121. package/dist/plugin/index.js.map +3 -4
  122. package/dist/regex/classes.d.ts +28 -0
  123. package/dist/regex/classes.d.ts.map +1 -1
  124. package/dist/regex/first-set.d.ts +14 -0
  125. package/dist/regex/first-set.d.ts.map +1 -1
  126. package/dist/run/index.cjs +136 -51
  127. package/dist/run/index.cjs.map +2 -3
  128. package/dist/run/index.js +136 -51
  129. package/dist/run/index.js.map +2 -3
  130. package/dist/spec/index.cjs +2898 -1623
  131. package/dist/spec/index.cjs.map +3 -4
  132. package/dist/spec/index.js +2898 -1623
  133. package/dist/spec/index.js.map +3 -4
  134. package/dist/spec/model.d.ts +8 -0
  135. package/dist/spec/model.d.ts.map +1 -1
  136. package/dist/table/assemble.d.ts +307 -0
  137. package/dist/table/assemble.d.ts.map +1 -0
  138. package/dist/table/cell.d.ts +42 -0
  139. package/dist/table/cell.d.ts.map +1 -0
  140. package/dist/table/child-slots.d.ts +30 -0
  141. package/dist/table/child-slots.d.ts.map +1 -0
  142. package/dist/table/compile-rule-map.d.ts +136 -0
  143. package/dist/table/compile-rule-map.d.ts.map +1 -0
  144. package/dist/table/compile.d.ts +56 -0
  145. package/dist/table/compile.d.ts.map +1 -0
  146. package/dist/table/duplication-hook.d.ts +32 -0
  147. package/dist/table/duplication-hook.d.ts.map +1 -0
  148. package/dist/table/emit-assembly.d.ts +139 -0
  149. package/dist/table/emit-assembly.d.ts.map +1 -0
  150. package/dist/table/emit.d.ts +113 -0
  151. package/dist/table/emit.d.ts.map +1 -0
  152. package/dist/table/encode-baseline.d.ts +16 -0
  153. package/dist/table/encode-baseline.d.ts.map +1 -0
  154. package/dist/table/encode.d.ts +71 -0
  155. package/dist/table/encode.d.ts.map +1 -0
  156. package/dist/table/exec-baseline.d.ts +9 -0
  157. package/dist/table/exec-baseline.d.ts.map +1 -0
  158. package/dist/table/exec.d.ts +72 -0
  159. package/dist/table/exec.d.ts.map +1 -0
  160. package/dist/table/fold.d.ts +25 -0
  161. package/dist/table/fold.d.ts.map +1 -0
  162. package/dist/table/index.cjs +11375 -0
  163. package/dist/table/index.cjs.map +6 -0
  164. package/dist/table/index.d.ts +100 -0
  165. package/dist/table/index.d.ts.map +1 -0
  166. package/dist/table/index.js +11352 -0
  167. package/dist/table/index.js.map +6 -0
  168. package/dist/table/inspect.d.ts +17 -0
  169. package/dist/table/inspect.d.ts.map +1 -0
  170. package/dist/table/ops.d.ts +446 -0
  171. package/dist/table/ops.d.ts.map +1 -0
  172. package/dist/table/program.d.ts +493 -0
  173. package/dist/table/program.d.ts.map +1 -0
  174. package/dist/table/run-support.d.ts +38 -0
  175. package/dist/table/run-support.d.ts.map +1 -0
  176. package/dist/{compiler/scannable-run.d.ts → table/scan-shapes.d.ts} +14 -13
  177. package/dist/table/scan-shapes.d.ts.map +1 -0
  178. package/dist/table/site-labels.d.ts +58 -0
  179. package/dist/table/site-labels.d.ts.map +1 -0
  180. package/dist/table/stamp.d.ts +70 -0
  181. package/dist/table/stamp.d.ts.map +1 -0
  182. package/dist/types.d.ts +80 -24
  183. package/dist/types.d.ts.map +1 -1
  184. package/dist/version.d.ts +1 -1
  185. package/package.json +25 -2
  186. package/src/analysis/choice-cost-gate.ts +359 -0
  187. package/src/analysis/choice-cost-render.ts +293 -0
  188. package/src/analysis/choice-cost.ts +1008 -0
  189. package/src/analysis/commitment.ts +557 -0
  190. package/src/analysis/corpus.ts +130 -0
  191. package/src/analysis/diagnose-render.ts +625 -0
  192. package/src/analysis/diagnose.ts +317 -0
  193. package/src/analysis/diagnostics.ts +33 -0
  194. package/src/analysis/duplication.ts +1955 -0
  195. package/src/analysis/fix-render.ts +217 -0
  196. package/src/analysis/fix.ts +669 -0
  197. package/src/analysis/format-number.ts +31 -0
  198. package/src/analysis/gating.ts +792 -0
  199. package/src/analysis/grammar.ts +72 -0
  200. package/src/analysis/rebuild.ts +287 -0
  201. package/src/analysis/terminal.ts +336 -0
  202. package/src/cli/index.ts +413 -0
  203. package/src/combinators/adjacency.ts +171 -0
  204. package/src/combinators/attempt.ts +41 -0
  205. package/src/combinators/case-fold.ts +90 -0
  206. package/src/combinators/choice.ts +466 -0
  207. package/src/combinators/completions.ts +64 -0
  208. package/src/combinators/dispatch.ts +358 -0
  209. package/src/combinators/expect.ts +159 -0
  210. package/src/combinators/first-set.ts +322 -0
  211. package/src/combinators/gate.ts +50 -0
  212. package/src/combinators/grammar.ts +272 -0
  213. package/src/combinators/keywords.ts +145 -0
  214. package/src/combinators/literal.ts +102 -0
  215. package/src/combinators/map.ts +106 -0
  216. package/src/combinators/node.ts +345 -0
  217. package/src/combinators/not.ts +55 -0
  218. package/src/combinators/parser.ts +266 -0
  219. package/src/combinators/peek.ts +63 -0
  220. package/src/combinators/probe.ts +25 -0
  221. package/src/combinators/ref.ts +109 -0
  222. package/src/combinators/regex.ts +170 -0
  223. package/src/combinators/repeat.ts +561 -0
  224. package/src/combinators/scanTo.ts +393 -0
  225. package/src/combinators/sequence.ts +221 -0
  226. package/src/combinators/token.ts +120 -0
  227. package/src/combinators/trivia-boundary.ts +48 -0
  228. package/src/combinators/trivia-skip.ts +821 -0
  229. package/src/combinators/withCtx.ts +45 -0
  230. package/src/compiler/build-arity.ts +330 -0
  231. package/src/compiler/compile-linkable-table.ts +209 -0
  232. package/src/compiler/degradation.ts +266 -0
  233. package/src/compiler/fields.ts +191 -0
  234. package/src/compiler/grammar-coverage-ids.ts +129 -0
  235. package/src/compiler/ir-serialize.ts +615 -0
  236. package/src/compiler/linker.ts +954 -0
  237. package/src/compiler/token-alphabet.ts +209 -0
  238. package/src/compiler/token-dispatch.ts +353 -0
  239. package/src/compiler/token-scanner.ts +318 -0
  240. package/src/compiler/value-usage.ts +147 -0
  241. package/src/coverage.ts +383 -0
  242. package/src/cst/capture-buffer.ts +297 -0
  243. package/src/cst/host-mode.ts +69 -0
  244. package/src/cst/reflection-attach.ts +11 -0
  245. package/src/cst/reflection-symbols.ts +9 -0
  246. package/src/cst/reflection.ts +149 -0
  247. package/src/cst/relative-spans.ts +207 -0
  248. package/src/cst/root-trivia-scope.ts +30 -0
  249. package/src/cst/trivia-charscan.ts +312 -0
  250. package/src/cst/trivia-entries.ts +285 -0
  251. package/src/cst/trivia-index.ts +131 -0
  252. package/src/cst/trivia-kinds.ts +358 -0
  253. package/src/cst/types.ts +76 -0
  254. package/src/cst/walk.ts +101 -0
  255. package/src/functional/doc.ts +959 -0
  256. package/src/functional/run-tabled.ts +153 -0
  257. package/src/functional/run.ts +558 -0
  258. package/src/grammar-metadata.ts +2 -0
  259. package/src/index.ts +189 -0
  260. package/src/language-service/index.ts +221 -0
  261. package/src/line-index.ts +131 -0
  262. package/src/oracle/digest.ts +620 -0
  263. package/src/oracle/index.ts +55 -0
  264. package/src/parse-context.ts +91 -0
  265. package/src/plugin/direct-builder-static.ts +102 -0
  266. package/src/plugin/evaluator.ts +1505 -0
  267. package/src/plugin/free-identifiers.ts +338 -0
  268. package/src/plugin/index.ts +2281 -0
  269. package/src/plugin/reducer-resolver.ts +606 -0
  270. package/src/recovery/scan.ts +155 -0
  271. package/src/regex/classes.ts +183 -0
  272. package/src/regex/first-set.ts +316 -0
  273. package/src/run/index.ts +31 -0
  274. package/src/spec/ebnf.ts +128 -0
  275. package/src/spec/index.ts +54 -0
  276. package/src/spec/model.ts +636 -0
  277. package/src/spec/railroad-lib.ts +559 -0
  278. package/src/spec/railroad.ts +256 -0
  279. package/src/table/assemble.ts +2994 -0
  280. package/src/table/cell.ts +42 -0
  281. package/src/table/child-slots.ts +113 -0
  282. package/src/table/compile-rule-map.ts +336 -0
  283. package/src/table/compile.ts +244 -0
  284. package/src/table/duplication-hook.ts +89 -0
  285. package/src/table/emit-assembly.ts +1766 -0
  286. package/src/table/emit.ts +418 -0
  287. package/src/table/encode-baseline.ts +340 -0
  288. package/src/table/encode.ts +1569 -0
  289. package/src/table/exec-baseline.ts +537 -0
  290. package/src/table/exec.ts +1672 -0
  291. package/src/table/fold.ts +38 -0
  292. package/src/table/index.ts +108 -0
  293. package/src/table/inspect.ts +52 -0
  294. package/src/table/ops.ts +459 -0
  295. package/src/table/program.ts +855 -0
  296. package/src/table/run-support.ts +66 -0
  297. package/src/table/scan-shapes.ts +1578 -0
  298. package/src/table/site-labels.ts +228 -0
  299. package/src/table/stamp.ts +229 -0
  300. package/src/types.ts +563 -0
  301. package/src/version.ts +16 -0
  302. package/dist/compiler/codegen.d.ts +0 -334
  303. package/dist/compiler/codegen.d.ts.map +0 -1
  304. package/dist/compiler/inline-build.d.ts +0 -11
  305. package/dist/compiler/inline-build.d.ts.map +0 -1
  306. package/dist/compiler/inline-callback.d.ts +0 -21
  307. package/dist/compiler/inline-callback.d.ts.map +0 -1
  308. package/dist/compiler/line-index.d.ts +0 -2
  309. package/dist/compiler/line-index.d.ts.map +0 -1
  310. package/dist/compiler/module-hoist.d.ts +0 -106
  311. package/dist/compiler/module-hoist.d.ts.map +0 -1
  312. package/dist/compiler/scannable-run.d.ts.map +0 -1
  313. package/dist/compiler/scannable-terminal.d.ts +0 -23
  314. package/dist/compiler/scannable-terminal.d.ts.map +0 -1
  315. package/dist/compiler/trivia-fast-path.d.ts +0 -38
  316. package/dist/compiler/trivia-fast-path.d.ts.map +0 -1
@@ -1,334 +0,0 @@
1
- /**
2
- * Compile a Combinator<T> definition tree into an optimized JavaScript function.
3
- *
4
- * Design: every sub-emitter uses early-return on failure. Fallible contexts
5
- * (optional, sepBy loops, many loops) use labeled blocks so early-exit is a
6
- * `break <label>` rather than an IIFE return — no function call, no result
7
- * object allocation per node.
8
- */
9
- import type { Combinator, FirstSet, ParseResult, ParseContext, ParseError } from '../types.ts';
10
- import { type HostMode } from '../cst/host-mode.ts';
11
- import { type DuplicationWarnLevel } from '../analysis/duplication.ts';
12
- /**
13
- * A rule's LEADING first-set as a fuse-resolvable recipe.
14
- *
15
- * A recipe is a UNION of ORDERED CHAINS (`alts`). Each chain is the leading-term
16
- * sequence of one alternative; `fusedBody()` resolves it left-to-right against the
17
- * WINNING rules, UNIONING each segment's first-set and STOPPING after the first
18
- * segment that is not nullable. A segment is either
19
- * - a concrete first-set (`set`) with its build-time-known `nullable` flag, or
20
- * - a rule REFERENCE (`ref`) whose first-set AND nullability are resolved at fuse
21
- * time (`nullable` is a conservative placeholder until then).
22
- *
23
- * Why the ORDER + per-segment nullability matter (the bug this shape fixes): a rule
24
- * like `sequence(g.CssAstSyntaxStatementAtRuleName, prelude, ';')` leads with a
25
- * cross-artifact ref. At compile time that ref's nullability is unknown, so a flat
26
- * "concrete chars + ref names" recipe would conservatively treat it as nullable and
27
- * union the FOLLOWING terms' first-sets — and the prelude's first-set is `any` (a
28
- * `scanTo`), collapsing the whole recipe to `any` and losing first-char dispatch.
29
- * Keeping the leading chain ordered lets fuse-time resolution see the ref is actually
30
- * NON-nullable and STOP — so the arm gates on `{@}`, exactly as a grammar-local
31
- * `regex(/@…/)` would. Grammar authors had to hand-copy those recognizers to work
32
- * around this; the ordered chain removes the need.
33
- *
34
- * Soundness: the resolved set is always a SUPERSET of the rule's true first chars.
35
- * An unknown/opaque construct contributes its shallow `_meta.firstSet`; a ref whose
36
- * nullability can't be resolved defaults to nullable (keep unioning — never drops a
37
- * valid first char).
38
- */
39
- export type FirstSetSeg = {
40
- set: FirstSet;
41
- nullable: boolean;
42
- ref?: string;
43
- };
44
- export type FirstSetRecipe = {
45
- alts: FirstSetSeg[][];
46
- };
47
- export declare function leadingFirstSetRecipe(p: Combinator<unknown>, seen?: Set<Combinator<unknown>>): FirstSetRecipe;
48
- import { type GrammarCoveragePlan } from './grammar-coverage-ids.ts';
49
- import { type GrammarReflection } from '../cst/reflection.ts';
50
- /**
51
- * Runtime prelude helper for the structural-node capture gate. Answers "does the
52
- * injected `_ctx.build` host read its (n+1)th positional arg?" — `.length` alone
53
- * under-counts with rest/default params and can't see through a bound fn, so a
54
- * rest/default param or an `arguments` reference forces full capture (output-safe).
55
- * Plain positional and bound-native hosts (the common case) trust `.length`.
56
- * Emitted (memoized on `_ctx._pmCapTL`/`_pmCapST`) wherever a structural node()
57
- * arity-gates host capture; shared, un-namespaced, mirrors `_EMPTY_TL` placement.
58
- */
59
- export declare const HOST_READS_DECL = "const _hostReads = (b, n) => { if (b === undefined) return false; let s; try { s = Function.prototype.toString.call(b) } catch (e) { return true } if (/\\barguments\\b/.test(s)) return true; const m = /^[^(]*\\(([\\s\\S]*?)\\)/.exec(s); if (m && /\\.\\.\\.|=/.test(m[1])) return true; return b.length > n }";
60
- /**
61
- * Raw-children coercion, hoisted out of every node site.
62
- *
63
- * The `rawChildren` entry for a produced value is either the value itself (when it
64
- * is already a tagged CST thing) or a synthesized leaf. Inlined, that test plus the
65
- * leaf literal is ~300 bytes emitted PER `node()` site — measured at 2.6% of
66
- * `example/css`, 7.1% of `probe/node-scale-32`, 11.2% of `probe/trivia-off`.
67
- *
68
- * Allocation behaviour is preserved exactly, which is why `span` is the last
69
- * parameter and may be absent:
70
- * - line-tracked grammars already hold their span in a local, so they pass it and
71
- * nothing extra is allocated;
72
- * - untracked grammars pass nothing and the `{ start, end }` literal is built
73
- * INSIDE, on the fallback branch only — exactly where the inline form built it.
74
- * Passing the literal as an argument instead would have allocated a span on the
75
- * fast path, which is the one thing this hoist must not do.
76
- */
77
- export declare const RAW_ENTRY_DECL = "const _rawEntry = (v, input, s, e, span) => (typeof v === 'object' && v !== null && (v._tag === 'node' || v._tag === 'leaf' || v._tag === 'parseError')) ? v : { _tag: 'leaf', value: typeof v === 'string' ? v : (typeof v === 'object' && v !== null ? input.slice(s, e) : ''), span: span ?? { start: s, end: e } }";
78
- export declare const LINE_TRACK_DECL = "const _trackLines = (_ctx, input, start, end) => { const from = _ctx._lineScannedTo ?? 0; if (end <= from) return; for (let i = from; i < end; i++) if (input.charCodeAt(i) === 10) _ctx._lineStarts.push(i + 1); _ctx._lineScannedTo = end }";
79
- export declare const LINE_SPAN_DECL: string;
80
- /** Begin capturing regexes that fall back to `RegExp.exec` (didn't lower). */
81
- export declare function beginLoweringCapture(): void;
82
- /** Stop capturing and return the un-lowered regex sources seen since begin. */
83
- export declare function endLoweringCapture(): string[];
84
- /** One emitted function whose inline budget was spent, and what it cost. */
85
- export type InlineCapSite = {
86
- /** The emitted function that hit the budget. */
87
- fn: string;
88
- /** Approximate combinator nodes in the ref body that became a call instead. */
89
- nodes: number;
90
- };
91
- /** Begin collecting inline-cap sites. */
92
- export declare function beginInlineCapCapture(): void;
93
- /** Stop collecting and return the sites, in emission order (deterministic). */
94
- export declare function endInlineCapCapture(): InlineCapSite[];
95
- /**
96
- * One line per capped function, in the shape the degradation formatter uses so the two
97
- * read alike. Says exactly what happened and exactly what to do about it, because a
98
- * diagnostic that does neither is noise.
99
- */
100
- export declare function formatInlineCapSites(sites: readonly InlineCapSite[], max: number): string[];
101
- export declare function firstSetCond(codeVar: string, fs: FirstSet): string;
102
- export declare function __setForceDisjointIf(on: boolean): void;
103
- export declare function __setForceNoSharedPrefix(on: boolean): void;
104
- export { assertHostModeCompatible, FUSED_HOST_MODE, FUSED_HOST_ELIDED } from '../cst/host-mode.ts';
105
- export type { HostMode } from '../cst/host-mode.ts';
106
- export type CompiledParser<T> = {
107
- parse(input: string, pos?: number): ParseResult<T>;
108
- /** Like parse(), but with a caller-supplied ParseContext (e.g. `_triviaLog` for CST grammars). */
109
- parseWithContext(input: string, ctx: ParseContext, pos?: number): ParseResult<T>;
110
- /**
111
- * Like parse(), but activates the error-collection channel. Recovery points
112
- * (expect()) collect their ParseErrors into result.errors instead of only
113
- * embedding them as values. Always returns ParseOk — top-level failures are
114
- * still ParseFail.
115
- */
116
- parseWithErrors(input: string, pos?: number): ParseResult<T> & {
117
- errors: ParseError[];
118
- };
119
- /** The generated source (for inspection / future source maps) */
120
- source: string;
121
- /**
122
- * A self-contained JS expression (IIFE) that evaluates to a parse function.
123
- * Safe to inline directly into transformed source — no external references
124
- * except for runtime-fallback parsers embedded via closures.
125
- * Returns null if the parser cannot be fully inlined (e.g. contains user
126
- * closures that can't be serialized).
127
- */
128
- inlineExpression: string | null;
129
- /** Present only when compiled with `{ coverage: true }`. */
130
- coverageDefinitions?: readonly import('./grammar-coverage-ids.ts').GrammarCoverageDefinition[];
131
- };
132
- /**
133
- * INLINE EXPANSION CAP — a bound on how much one emitted function may grow by pasting
134
- * single-use ref bodies into it.
135
- *
136
- * The decision procedure, in one sentence: **each emitted function gets a budget of
137
- * `INLINE_MAX_NODES` combinator nodes of inlined single-use refs; once it is spent, the
138
- * remaining single-use refs in that function become named functions and are called.**
139
- *
140
- * What this limits, precisely. `emitLazy` inlines a ref that is used ONCE and is not
141
- * recursive, because hoisting a function nobody else calls is pure overhead. That is
142
- * correct per ref and unbounded in aggregate: a rule whose body is a chain of
143
- * single-use helpers expands transitively, and the expansion has no ceiling that a
144
- * grammar author can see or predict. This is NOT the identity-keyed hoisting of a
145
- * MULTIPLY-referenced subtree (`HOIST_MIN_SUBTREE` above) — that already works, and a
146
- * shared object referenced 1 or 38 times emits flat. Conflating the two is what made
147
- * the size problem look like a duplication problem.
148
- *
149
- * Why a per-function budget rather than a per-ref size limit or a whole-artifact budget:
150
- * - a per-ref limit bounds each paste but not the transitive total, which is the
151
- * quantity that actually grows;
152
- * - a whole-artifact budget needs an eviction order, and any order that depends on
153
- * which function was compiled first is a decision the author cannot predict;
154
- * - a per-function budget needs no eviction order at all. Emission order within one
155
- * function is the grammar's own left-to-right order, so "the refs after the budget
156
- * runs out" is stable and explainable.
157
- *
158
- * Charge unit is `subtreeSizes` — the same approximate node count `HOIST_MIN_SUBTREE`
159
- * uses, so the two policies are denominated in one currency.
160
- *
161
- * The default is measured, not chosen by taste: see `bench/size/inline-cap.md` for the
162
- * size/speed sweep this number came from.
163
- */
164
- export declare const INLINE_MAX_NODES = 1000;
165
- /**
166
- * Resolve the cap: explicit option wins, then `PARSEMAN_MAX_INLINE`, then the default.
167
- * The escape hatch is deliberately explicit and OFF by default — a grammar that really
168
- * wants unbounded inlining sets `Infinity` and says so, rather than discovering that a
169
- * silent policy took it away. Read ONCE per compile and stored on the ctx, so a single
170
- * compile can never observe two different values.
171
- */
172
- export declare function resolveInlineMax(explicit?: number): number;
173
- /**
174
- * Dependency manifest for the linkable form: for each rule in the map, the set
175
- * of OTHER rule names its body references (by name). A referenced rule is a
176
- * boundary — we record the edge and do NOT descend into it (its own deps are its
177
- * own entry). Used by the linker for à la carte dep-closure selection and the
178
- * compose-time name-closure check (every referenced name must resolve in the
179
- * final set). Self-references are included (a recursive rule depends on itself).
180
- */
181
- export declare function ruleDependencies(ruleMap: ReadonlyArray<readonly [string, Combinator<unknown>]>): Map<string, string[]>;
182
- /**
183
- * Compile a combinator tree into an optimized parse function at runtime.
184
- *
185
- * Uses `new Function` internally, so it will fail in environments with a strict
186
- * Content Security Policy that omits `'unsafe-eval'`. Prefer the interpreter or
187
- * macro build plugin in those cases.
188
- *
189
- * @see https://www.greadme.com/blog/security/what-is-content-security-policy-complete-guide
190
- */
191
- /**
192
- * The `duplication` compile option. A bare level is shorthand for `{ level }`; the
193
- * object form adds the `accept` allowlist (finding ids acknowledged as intentional)
194
- * and the ranking knobs.
195
- *
196
- * DEFAULT IS `'off'`, unlike gating. An ungated hot choice is a cliff with no other
197
- * symptom; a duplicated subtree is a maintenance cost the author may have chosen.
198
- * More to the point, most findings here are CANDIDATES that need an AST check
199
- * before they are applied — a diagnostic that prints "candidate, verify" on every
200
- * build teaches people to stop reading it. Run it deliberately (a lint script, a
201
- * review pass, `PARSEMAN_DUPLICATION=warn`), not on every compile.
202
- */
203
- export type DuplicationOption = DuplicationWarnLevel | {
204
- level?: DuplicationWarnLevel;
205
- accept?: Iterable<string>;
206
- minSize?: number;
207
- maxFindings?: number;
208
- entryName?: string;
209
- };
210
- export declare function compile<T>(combinator: Combinator<T>, mapFnSources?: string[], opts?: {
211
- recovery?: boolean;
212
- hostMode?: HostMode;
213
- coverage?: boolean;
214
- duplication?: DuplicationOption;
215
- trackLines?: boolean;
216
- maxInline?: number;
217
- }): CompiledParser<T>;
218
- export declare function compileRuleMap(ruleMap: ReadonlyArray<readonly [string, Combinator<unknown>]>, opts?: {
219
- trivia?: Combinator<unknown>;
220
- scanSkip?: Combinator<unknown>[];
221
- recovery?: boolean;
222
- hostMode?: HostMode;
223
- trackLines?: boolean;
224
- coverage?: boolean;
225
- duplication?: DuplicationOption;
226
- maxInline?: number;
227
- }): {
228
- keys: string[];
229
- replacement: string;
230
- hostMode: HostMode;
231
- hostBranchElided: boolean;
232
- reflection: GrammarReflection;
233
- coverageDefinitions?: readonly import('./grammar-coverage-ids.ts').GrammarCoverageDefinition[];
234
- } | null;
235
- /**
236
- * The linkable form of a rule map (RULE_ABI_PLAN §3): the same compiled rule
237
- * bodies as `compileRuleMap`, but returned as **splice-able pieces** under a
238
- * namespace `ns` so multiple independently-compiled maps fuse into one scope
239
- * (see `fuseRules`). `ns` MUST be non-empty and unique per artifact (the caller
240
- * derives it — module identity in the macro, a counter in `compile()`).
241
- *
242
- * prelude — namespaced hoisted decls (regexes, expected, `_mf`/`_build`, and
243
- * private `_pf` helper fns). Sentinels / `_EMPTY_TL`
244
- * are NOT here — they are SHARED, emitted once by the linker.
245
- * ruleFns — name → `function _r_<Name>(…) { … }` source (the composition
246
- * surface; siblings call these by name).
247
- * wrappers — name → public `(input,pos,ctx) => ParseResult` wrapper source.
248
- * deps — name → referenced rule names (from `ruleDependencies`).
249
- *
250
- * Returns null on the same "can't inline" conditions as `compileRuleMap`.
251
- */
252
- export type LinkablePieces = {
253
- /**
254
- * The parseman version that produced this artifact (the ARTIFACT VERSION LOCK; see
255
- * `src/version.ts`). REQUIRED — `compileLinkable` always stamps it. `fusedBody`
256
- * refuses to link a piece whose stamp differs from the linking parseman OR is absent
257
- * (a stale pre-invariant artifact, whose recipe/pieces shape is unsupported).
258
- * Artifacts are version-locked; the format carries no cross-version back-compat.
259
- */
260
- v: string;
261
- ns: string;
262
- keys: string[];
263
- prelude: string[];
264
- ruleFns: Map<string, string>;
265
- wrappers: Map<string, string>;
266
- /**
267
- * Per-rule first-set (this artifact's own rules). fusedBody() uses the WINNING
268
- * artifact's entry to resolve `/*@FS:rule:codevar@*​/true` dispatch placeholders
269
- * emitted for rule-ref choice arms — sound under compose override.
270
- */
271
- firstSets: Map<string, FirstSet>;
272
- /**
273
- * Per-rule nullability (does the rule match the empty string?). `fusedBody()`
274
- * reads it when resolving an ordered-chain recipe segment that REFERENCES this
275
- * rule: a non-nullable ref terminates the leading chain (stop unioning the tail),
276
- * a nullable one lets it continue. Optional/absent → treated as nullable (the safe
277
- * default: keep unioning, never drop a valid first char).
278
- */
279
- nullable?: Map<string, boolean>;
280
- /**
281
- * Per-rule LEADING first-set recipe — a union of ordered leading-term chains.
282
- * `fusedBody()` fixpoint-resolves the leading ref names over the WINNING rules so a
283
- * `sequence(ref, …)`-led arm/node dispatches on the ref's real first char —
284
- * matching a monolithic compile — instead of degrading to always-try because the
285
- * ref baked `any`. Optional (absent for hand-built pieces → `any`, always try).
286
- */
287
- firstSetRecipes?: Map<string, FirstSetRecipe>;
288
- deps: Map<string, string[]>;
289
- needsEmptyTl: boolean;
290
- needsHostReads: boolean;
291
- needsRawEntry: boolean;
292
- /** Compile-time host mode this piece was lowered for ('ast' when absent). */
293
- hostMode?: HostMode;
294
- /** Set when a direct builder's positioned-CST branch was omitted. */
295
- hostBranchElided?: boolean;
296
- /** True when this piece contains any direct `node(..., build)` reduction. */
297
- hasDirectBuilders?: boolean;
298
- /** True only when this piece has no direct builder or callback-based semantics. */
299
- isRecognitionOnly?: boolean;
300
- /** Per-rule CST node reflection for grammar-aware visitors. */
301
- nodeMeta: Map<string, GrammarReflection>;
302
- /**
303
- * Transform (`_mf`) / build (`_build`) callback FUNCTIONS, injected into the
304
- * fused scope via `_env` when their SOURCE isn't available (runtime `compile()`
305
- * mode). Empty when the callbacks were inlined from source (macro mode). Keyed
306
- * for `_env` as `<ns>mf` / `<ns>build`.
307
- */
308
- mfFns: ReadonlyArray<(...args: unknown[]) => unknown>;
309
- buildFns: ReadonlyArray<(...args: unknown[]) => unknown>;
310
- };
311
- export declare function compileLinkable(ruleMapArg: ReadonlyArray<readonly [string, Combinator<unknown>]>, ns: string, opts?: {
312
- trivia?: Combinator<unknown>;
313
- scanSkip?: Combinator<unknown>[];
314
- recovery?: boolean;
315
- hostMode?: HostMode;
316
- trackLines?: boolean;
317
- captureTerminals?: boolean;
318
- coverage?: GrammarCoveragePlan;
319
- duplication?: DuplicationOption;
320
- maxInline?: number;
321
- }): LinkablePieces | null;
322
- /**
323
- * Does this rule map reference a rule it doesn't define — a NAMED `ref` (`g.Foo`)
324
- * that never got `.define()`d? That is the SHARED-SHAPE signature: the grammar is a
325
- * shape with a hole, so it can't be inlined as a standalone parser, but it IS
326
- * linkable (`compileLinkable` emits a by-name `_r_Foo` call for the hole, bound at
327
- * fuse time). Callers use this to tell that case apart from a genuine
328
- * "couldn't compile, fall back to the interpreter".
329
- *
330
- * A `rules()` map's own `Object.entries` also leaks accessed-but-undefined names as
331
- * top-level entries, so both the entry values AND their bodies are scanned.
332
- */
333
- export declare function hasExternalRuleRef(ruleMap: ReadonlyArray<readonly [string, Combinator<unknown>]>): boolean;
334
- //# sourceMappingURL=codegen.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/compiler/codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,UAAU,EAAa,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAA4B,MAAM,aAAa,CAAA;AAKnI,OAAO,EAA4B,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC7E,OAA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} from '../types.ts';
2
- /**
3
- * When a node() build is a thin `mk(type, …)` wrapper, emit the object literal
4
- * at the call site instead of `_build[n](…)`.
5
- */
6
- export declare function analyzeMkInlineBuild(def: Extract<ParserDef, {
7
- tag: 'node';
8
- }>): string | null;
9
- /** Object literal matching `stub-build.ts` `mk()` without the function call. */
10
- export declare function emitInlineMkNodeExpr(type: string, chV: string, rawV: string, spanExpr: string, tlV: string): string;
11
- //# sourceMappingURL=inline-build.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inline-build.d.ts","sourceRoot":"","sources":["../../src/compiler/inline-build.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AA+D5C;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,MAAM,GAAG,IAAI,CAmB5F;AAeD,gFAAgF;AAChF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,MAAM,CAER"}
@@ -1,21 +0,0 @@
1
- /** Source text for a transform callback — macro `fnSrc` or arrow `toString()`. */
2
- export declare function transformFnSource(fn: Function, fnSrc?: string | null): string | null;
3
- /** `s => expr` / `() => expr` when expr only uses the param (+ builtins). */
4
- export declare function tryInlineUnaryTransform(src: string, valueVar: string): string | null;
5
- /** Parse `[a, , c]` destructuring slots (null = ignore). */
6
- export declare function parseArrayDestructure(pattern: string, arity: number): (string | null)[];
7
- /**
8
- * `([x, y]) => body` — substitute destructure names with sequence value vars.
9
- * Caller must ensure body only references slotted params (+ builtins).
10
- */
11
- export declare function tryInlineDestructureTransform(src: string, valueVars: string[]): string | null;
12
- /**
13
- * `([, tail]) => tail` / `([_, tail]) => tail` over dispatch().
14
- *
15
- * This is a codegen-only proof that the public `[selector, tail]` pair is not
16
- * observed, so dispatch may return the selected branch value directly. It is
17
- * intentionally narrower than general destructuring inlining: public dispatch
18
- * semantics stay unchanged unless the immediate transform discards the selector.
19
- */
20
- export declare function isDispatchTailOnlyTransform(src: string): boolean;
21
- //# sourceMappingURL=inline-callback.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inline-callback.d.ts","sourceRoot":"","sources":["../../src/compiler/inline-callback.ts"],"names":[],"mappings":"AASA,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAKpF;AA4BD,6EAA6E;AAC7E,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAWpF;AAED,4DAA4D;AAC5D,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAQvF;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EAAE,GAClB,MAAM,GAAG,IAAI,CAaf;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAMhE"}
@@ -1,2 +0,0 @@
1
- export * from '../line-index.ts';
2
- //# sourceMappingURL=line-index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"line-index.d.ts","sourceRoot":"","sources":["../../src/compiler/line-index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
@@ -1,106 +0,0 @@
1
- /**
2
- * MODULE-LEVEL HOIST OF BYTE-IDENTICAL FUSED DECLARATIONS
3
- * ======================================================
4
- *
5
- * Every `compose()` / `composeLeaf()` in a module lowers to its OWN self-contained
6
- * IIFE (`emitFusedSource` → `/* @__PURE__ *​/ (() => { … })()`). A module that
7
- * publishes N variants of one grammar — the jess shape: shared recognition pieces
8
- * plus N leaves differing only in `hostMode` / `trackLines` — therefore emits the
9
- * recognition piece's rule functions N times, under the SAME namespaced names,
10
- * in N sibling scopes. The namespace is content-addressed, so those N copies are
11
- * byte-identical: `probe/variants-4` emits 5 `_r_` rule functions, four of which
12
- * have exactly one distinct body across all four IIFEs.
13
- *
14
- * Measured on the committed size probe (bench/size/probe.ts), byte-identical
15
- * declaration text available for dedup:
16
- *
17
- * probe/variants-2 41,446 B generated 9,557 B duplicated (23.1%)
18
- * probe/variants-4 82,058 B generated 29,286 B duplicated (35.7%)
19
- *
20
- * This module collects the top-level declarations of every fused IIFE in one
21
- * module, decides which are safe to emit ONCE at module scope, and rewrites each
22
- * IIFE to drop its copy.
23
- *
24
- * THE CORRECTNESS PROBLEM, AND WHY THE DECISION IS KEYED ON THE NAME
25
- * -----------------------------------------------------------------
26
- * `_pfFail` is an identity sentinel: a rule function signals failure by returning
27
- * it and every caller tests `v === _pfFail`. Each IIFE declares its own
28
- * `const _pfFail = {}`, so today the producer and the consumer are always the same
29
- * object. A PARTIAL hoist breaks that: if some scopes read the module-level
30
- * sentinel while others keep a local one, a rule that FAILED returns object A and
31
- * its caller compares against object B — the test is false, and the failure is
32
- * read as a SUCCESS carrying the value `{}`. Silent wrong output, the worst class
33
- * of bug this compiler can have.
34
- *
35
- * So the hoist decision is made per DECLARED NAME, not per occurrence:
36
- *
37
- * a name is hoistable only if EVERY declaration of that name anywhere in the
38
- * module is byte-identical,
39
- *
40
- * and when it is, EVERY occurrence is removed and one copy is emitted at module
41
- * scope. A mixed state is unrepresentable: there is no code path that removes one
42
- * occurrence and keeps another. If two scopes ever disagreed about `_pfFail`'s
43
- * text, the name would have two distinct texts, would fail the uniformity test,
44
- * and NO scope would hoist it. `test/unit/module-hoist.test.ts` asserts both
45
- * directions.
46
- *
47
- * `_pfEnd` (`let _pfEnd`) is a single-slot out-parameter and is safe to share
48
- * unconditionally: the write is the last statement before a rule function returns
49
- * (src/compiler/codegen.ts, `pushNamedFnDecl` — `_pfEnd = <end>` immediately
50
- * precedes `return <value>`) and the read is the next statement at the call site
51
- * (`emitNamedFnCall` — `const _pfe = _pfEnd` immediately follows the sentinel
52
- * test). Nothing user-controlled runs between the write and the read, so even a
53
- * builder that re-enters another grammar cannot observe a stale slot: the nested
54
- * parse completes entirely before the outer write.
55
- *
56
- * FREE-VARIABLE FIXPOINT
57
- * ----------------------
58
- * A hoisted declaration must not reference anything that stayed IIFE-local. Every
59
- * top-level name of every IIFE is known here (the declarations ARE the input), so
60
- * a hoisted text is rejected if it mentions any name that is not itself hoisted,
61
- * iterated to a fixpoint. Reference detection is a `\bNAME\b` scan over the
62
- * declaration text: that over-approximates (it also matches inside strings and
63
- * comments), and over-approximation is the safe direction — it only ever blocks a
64
- * hoist, never permits an unsound one.
65
- *
66
- * This also disposes of the un-namespaced `_wcf<N>` hazard. `withCtx` names its
67
- * wrapper `_wcf${namedParsers.size}` with no namespace prefix, so two different
68
- * artifacts can both declare `_wcf0` with DIFFERENT bodies. Such a name has two
69
- * distinct texts, so it is not hoistable, and by the fixpoint nothing that
70
- * references it is hoistable either.
71
- *
72
- * SCOPE
73
- * -----
74
- * Hoisting is sound only because every macro replacement is made from the
75
- * plugin's top-level `for (const stmt of body)` loop — the call sites are all
76
- * module-level statements, so an IIFE's free variables can only resolve to
77
- * module-level bindings, which are still in scope at module level. The prelude is
78
- * inserted at the START of the earliest top-level statement that carries a
79
- * replacement, which is never earlier than the earliest IIFE, so no binding those
80
- * declarations already depended on moves out of scope.
81
- */
82
- /** Non-global marker test, for asking whether a generated replacement claimed any
83
- * declarations (a `/g` regex would carry `lastIndex` between calls). */
84
- export declare const HOIST_MARKER_PROBE: RegExp;
85
- /** The names a generated top-level declaration binds. */
86
- export declare function declaredNames(text: string): string[];
87
- export type HoistResult = {
88
- /** Declarations to emit ONCE at module scope, in first-claim order. Empty when
89
- * nothing qualified. Ends with a newline when non-empty. */
90
- prelude: string;
91
- /** Replace every marker in a generated source string with either nothing (the
92
- * declaration was hoisted) or its original text (it was not). */
93
- resolve(src: string): string;
94
- /** Diagnostics: bytes removed from the IIFEs, minus the bytes re-emitted once. */
95
- savedBytes: number;
96
- /** Names emitted at module scope. */
97
- hoistedNames: string[];
98
- };
99
- export type ModuleHoist = {
100
- /** Register one fused IIFE's top-level declarations; returns the marker lines to
101
- * emit in their place. */
102
- claim(decls: readonly string[]): string[];
103
- finalize(): HoistResult;
104
- };
105
- export declare function createModuleHoist(): ModuleHoist;
106
- //# sourceMappingURL=module-hoist.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"module-hoist.d.ts","sourceRoot":"","sources":["../../src/compiler/module-hoist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFG;AASH;yEACyE;AACzE,eAAO,MAAM,kBAAkB,QAAsB,CAAA;AAWrD,yDAAyD;AACzD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAOpD;AAED,MAAM,MAAM,WAAW,GAAG;IACxB;iEAC6D;IAC7D,OAAO,EAAE,MAAM,CAAA;IACf;sEACkE;IAClE,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;IAC5B,kFAAkF;IAClF,UAAU,EAAE,MAAM,CAAA;IAClB,qCAAqC;IACrC,YAAY,EAAE,MAAM,EAAE,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB;+BAC2B;IAC3B,KAAK,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAAA;IACzC,QAAQ,IAAI,WAAW,CAAA;CACxB,CAAA;AAED,wBAAgB,iBAAiB,IAAI,WAAW,CAkF/C"}
@@ -1 +0,0 @@
1
- {"version":3,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M,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAexG"}
@@ -1,23 +0,0 @@
1
- /**
2
- * Lower scannable regex shapes to tight `charCodeAt` scan loops for terminal
3
- * `regex()` combinators (PERF_IDEAS §8). Trivia uses the SAME match core via
4
- * `scannable-run.ts` (`emitShapeMatch`); this module is just the terminal
5
- * wrapper: run the shared match, fail when it doesn't match, then slice the
6
- * value. Keeping one match core means terminal and trivia can never disagree on
7
- * what an incomplete token (unclosed string/comment) means.
8
- */
9
- import { type ScanShape } from './scannable-run.ts';
10
- export type ScanEmitCtx = {
11
- ind: string;
12
- pos: string;
13
- valueVar: string;
14
- /** Emit `if (cond) { failLine }` lines (no trailing blank). */
15
- failIf: (cond: string) => string[];
16
- fresh: (prefix?: string) => string;
17
- };
18
- /** Emit stmts for one terminal regex match, or null when the shape is unsupported. */
19
- export declare function emitScannableTerminal(shape: ScanShape, c: ScanEmitCtx): {
20
- stmts: string[];
21
- endVar: string;
22
- } | null;
23
- //# sourceMappingURL=scannable-terminal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scannable-terminal.d.ts","sourceRoot":"","sources":["../../src/compiler/scannable-terminal.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,SAAS,EAAkB,MAAM,oBAAoB,CAAA;AAEnE,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,CAAA;IAChB,+DAA+D;IAC/D,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EAAE,CAAA;IAClC,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;CACnC,CAAA;AAED,sFAAsF;AACtF,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,SAAS,EAChB,CAAC,EAAE,WAAW,GACb;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAO5C"}
@@ -1,38 +0,0 @@
1
- import type { Combinator } from '../types.ts';
2
- import type { LabeledTriviaSpec } from '../cst/trivia-kinds.ts';
3
- import { type ScanShape } from './scannable-run.ts';
4
- /**
5
- * A trivia parser that lowers to a hand-rolled char-scan loop: `oneOrMore(choice(
6
- * …))` (or `many`, min≥1) where EVERY arm is a scannable shape (a `[X]+` run, a
7
- * `<lit>[^X]*` open-until-terminator, or a `<open>(?:…)*<close>` delimited token
8
- * — see scannable-run.ts). Returns the per-arm shapes, or a single-element list
9
- * for a bare scannable regex, or null (→ caller falls back to the regex/generic
10
- * trivia path). A single alternation regex is NOT scannable (one exec matches one
11
- * arm per call, defeating the loop).
12
- */
13
- export declare function analyzeTriviaFastPath(trivia: Combinator<unknown>): ScanShape[] | null;
14
- /** Emit a specialized `_tfN` that skips (unlabeled) trivia via a char-scan loop. */
15
- export declare function buildFastTriviaFnDecl(fnName: string, shapes: ScanShape[]): string;
16
- /**
17
- * A LABELED trivia parser whose every arm is scannable → per-arm shape + kind
18
- * index, or null. Same recognition as analyzeTriviaFastPath, but keyed by the
19
- * label table so the fast loop can log each chunk's category. It accepts any
20
- * structurally scannable arm set / arm count; labels do not affect recognition.
21
- */
22
- export declare function analyzeLabeledScannableRun(trivia: Combinator<unknown>): Array<{
23
- shape: ScanShape;
24
- kindIndex: number;
25
- label: string;
26
- }> | null;
27
- /** Emit a labeled scannable trivia `_tfN`: char-scan loop with per-chunk kind capture. */
28
- export declare function buildLabeledScannableTriviaFnDecl(fnName: string, arms: ReadonlyArray<{
29
- shape: ScanShape;
30
- kindIndex: number;
31
- label: string;
32
- }>): string;
33
- /** Labeled trivia with regex arms — per-chunk kind capture in compiled output. */
34
- export declare function buildLabeledRegexTriviaFnDecl(fnName: string, spec: LabeledTriviaSpec, reNames: string[]): string;
35
- export declare function labeledTriviaRegexArms(trivia: Combinator<unknown>): LabeledTriviaSpec | null;
36
- /** Labeled trivia via per-arm runtime parsers (non-regex or mixed arms). */
37
- export declare function buildLabeledRuntimeTriviaFnDecl(fnName: string, spec: LabeledTriviaSpec, rpStartIndex: number): string;
38
- //# sourceMappingURL=trivia-fast-path.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trivia-fast-path.d.ts","sourceRoot":"","sources":["../../src/compiler/trivia-fast-path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAG/D,OAAO,EAAE,KAAK,SAAS,EAAgE,MAAM,oBAAoB,CAAA;AAgCjH;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,SAAS,EAAE,GAAG,IAAI,CAyBrF;AA2BD,oFAAoF;AACpF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CASjF;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,GAC1B,KAAK,CAAC;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,IAAI,CAWtE;AAED,0FAA0F;AAC1F,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,aAAa,CAAC;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GAC1E,MAAM,CAeR;AAED,kFAAkF;AAClF,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,MAAM,EAAE,GAChB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