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,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,OAAO,EAA2H,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAE/L;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAOH,MAAM,MAAM,WAAW,GAAG;IAAE,GAAG,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAC5E,MAAM,MAAM,cAAc,GAAG;IAAE,IAAI,EAAE,WAAW,EAAE,EAAE,CAAA;CAAE,CAAA;AACtD,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,IAAI,GAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAa,GAAG,cAAc,CA8FxH;AAGD,OAAO,EAAoB,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAuBtF,OAAO,EAA4B,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AA2CvF;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,uTAC0R,CAAA;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UAAU,CAAC,OAAO,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAAC,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACxP,cAAc,GAAG,IAAI,CA4QvB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,GAC7D,OAAO,CAeT"}
@@ -1,11 +0,0 @@
1
- import type { ParserDef } 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 +0,0 @@
1
- {"version":3,"file":"scannable-run.d.ts","sourceRoot":"","sources":["../../src/compiler/scannable-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,OAAO,GACf;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GAKjD;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC5F;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAA;AAEvE,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAAC,M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AAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AAoCrE,wBAAgB,cAAc,CAC5B,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,MAAM,EACX,SAAS,CAAC,EAAE,MAAM,GACjB,UAAU,CAuTZ;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAG/D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,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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