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
package/README.md CHANGED
@@ -11,7 +11,8 @@ usually mean grammar files, generated code, and extra tooling. Parséman is a co
11
11
  library with an optional compiler, and it gives you both.
12
12
 
13
13
  **Parsing to JS values, the macro build is the fastest general-purpose JS parser in the
14
- suite** — ahead of every other library measured, at every grammar and every input size.
14
+ suite** — ahead of every other library measured, at every grammar and every input size in
15
+ that suite.
15
16
  Every parser in the suite builds real output: objects, row arrays, AST nodes. On a 7.7 kB
16
17
  GraphQL document Parséman takes **131 µs**; Peggy takes 328 µs. Only a purpose-built native
17
18
  edges it out, `JSON.parse` on JSON.
@@ -138,8 +139,9 @@ See **[The three modes](https://matthew-dean.github.io/parseman/guide/modes)**.
138
139
  coverage ("which rules and choice arms ran?") and trace ("what did it try, select, and
139
140
  backtrack through?").
140
141
  - 🚦 **[First-char gating diagnostics](https://matthew-dean.github.io/parseman/guide/first-char-gating)** —
141
- the build tells you which `choice` lost its O(1) dispatch, names the overlapping arms,
142
- and says how to fix it.
142
+ `diagnoseGrammar()` tells you which `choice` lost its O(1) dispatch, names the
143
+ overlapping arms, and says how to fix it. Run it in a test or a CI job — compiling
144
+ reports nothing.
143
145
  - 📈 **[Performance guide](https://matthew-dean.github.io/parseman/guide/performance)** —
144
146
  the levers that actually move a grammar, and [how regexes lower](https://matthew-dean.github.io/parseman/guide/regex-lowering).
145
147
 
@@ -161,6 +163,9 @@ GraphQL **131 µs** vs Peggy's 328 µs, JSON **133 µs** vs Chevrotain's 241 µs
161
163
  **75.3 µs** vs Peggy's 420 µs. Native `JSON.parse` does JSON large in 51.6 µs. On the CST
162
164
  chart, macro build runs 174 µs against Lezer's 594 µs parse-only.
163
165
 
166
+ Those are the committed charts, regenerated at 0.29.0 (2026-07-22) on an M4 Pro, measuring
167
+ the JS-codegen lowering that `compile()` and the macro build emit.
168
+
164
169
  ![JSON parsing benchmarks](https://raw.githubusercontent.com/matthew-dean/parseman/main/assets/bench-json.svg)
165
170
 
166
171
  ![CSV parsing benchmarks](https://raw.githubusercontent.com/matthew-dean/parseman/main/assets/bench-csv.svg)
@@ -46,6 +46,7 @@
46
46
  * produce two different outputs from one report and break exactly that.
47
47
  */
48
48
  import type { ChoiceInventoryReport, ChoiceInventoryEntry, WastedWorkReport } from './choice-cost.ts';
49
+ import { groupDigits } from './format-number.ts';
49
50
  export type RenderOptions = {
50
51
  /** Rows to show. Default 20. The report always holds all of them. */
51
52
  limit?: number;
@@ -55,10 +56,17 @@ export type RenderOptions = {
55
56
  */
56
57
  color?: boolean;
57
58
  };
58
- /** Deterministic thousands grouping. `toLocaleString()` is locale-dependent and would
59
- * make the output differ between machines — the one thing a gateable rendering
60
- * cannot do. */
61
- export declare function groupDigits(n: number): string;
59
+ /**
60
+ * Deterministic thousands grouping. `toLocaleString()` is locale-dependent and
61
+ * would make the output differ between machines — the one thing a gateable
62
+ * rendering cannot do.
63
+ *
64
+ * DEFINED IN `./format-number.ts` and re-exported here because this module's own
65
+ * callers import it from here. It was a byte-identical second copy: `./terminal.ts`
66
+ * declared one, this file declared another, and the two were one edit away from
67
+ * disagreeing about how a report reads on two different screens.
68
+ */
69
+ export { groupDigits };
62
70
  /** Byte counts at a glance. Binary units, fixed to one decimal, so 1,376,256 renders
63
71
  * as `1.3 MB` on every machine. */
64
72
  export declare function bytes(n: number): string;
@@ -1 +1 @@
1
- {"version":3,"file":"choice-cost-render.d.ts","sourceRoot":"","sources":["../../src/analysis/choice-cost-render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,KAAK,EACV,qBAAqB,EAAE,oBAAoB,EAAE,gBAAgB,EAC9D,MAAM,kBAAkB,CAAA;AAEzB,MAAM,MAAM,aAAa,GAAG;IAC1B,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAID;;iBAEiB;AACjB,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ7C;AAED;oCACoC;AACpC,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAIvC;AA8CD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,oBAAoB,GAAG,MAAM,GAAG,IAAI,CAOxE;AAID,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,qBAAqB,EAAE,IAAI,GAAE,aAAkB,GAAG,MAAM,CA0ChG;AAID;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,gBAAgB,EAAE,IAAI,GAAE,aAAkB,GAAG,MAAM,CAmEtF"}
1
+ {"version":3,"file":"choice-cost-render.d.ts","sourceRoot":"","sources":["../../src/analysis/choice-cost-render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,KAAK,EACV,qBAAqB,EAAE,oBAAoB,EAAE,gBAAgB,EAC9D,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,MAAM,MAAM,aAAa,GAAG;IAC1B,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAID;;;;;;;;;GASG;AACH,OAAO,EAAE,WAAW,EAAE,CAAA;AAEtB;oCACoC;AACpC,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAIvC;AA8CD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,oBAAoB,GAAG,MAAM,GAAG,IAAI,CAOxE;AAID,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,qBAAqB,EAAE,IAAI,GAAE,aAAkB,GAAG,MAAM,CA0ChG;AAID;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,gBAAgB,EAAE,IAAI,GAAE,aAAkB,GAAG,MAAM,CAmEtF"}
@@ -5,8 +5,8 @@
5
5
  * READ THIS FIRST: THIS MEASURES THE INTERPRETER, NOT THE SHIPPED PARSER.
6
6
  * ----------------------------------------------------------------------
7
7
  * The interpreter's `firstMatch` loop (src/combinators/choice.ts:149-165) enters every
8
- * alternative unconditionally. COMPILED output does not: `emitFirstMatch`
9
- * (src/compiler/codegen.ts:2246-2277) emits a per-arm first-CHARACTER guard, so an arm
8
+ * alternative unconditionally. The EMITTED engine does not: `src/table/emit-assembly.ts`
9
+ * hoists a per-choice candidate mask and emits a per-arm first-CHARACTER guard, so an arm
10
10
  * whose first set excludes the character at the current position is never entered.
11
11
  * First-set gating is this project's single largest parse lever — 25-48% across all
12
12
  * four jess parsers — and a naive interpreted profile is blind to every byte of it.
@@ -1 +1 @@
1
- {"version":3,"file":"choice-cost.d.ts","sourceRoot":"","sources":["../../src/analysis/choice-cost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+IG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAwC,MAAM,aAAa,CAAA;AACnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAGpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAI3C,gFAAgF;AAChF,MAAM,MAAM,UAAU,GAAG;IACvB,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAA;IACZ,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;qFACqF;AACrF,eAAO,MAAM,aAAa,MAAO,UAAU,KAAG,MACI,CAAA;AAIlD,yDAAyD;AACzD,MAAM,MAAM,gBAAgB;AAC1B;;sFAEsF;AACpF,gBAAgB;AAClB,yEAAyE;GACvE,yBAAyB;AAC3B;;8BAE8B;GAC5B,+BAA+B;AACjC;;gCAEgC;GAC9B,4BAA4B,CAAA;AAEhC,qDAAqD;AACrD,MAAM,MAAM,iBAAiB;AAC3B;oDACoD;AAClD,mBAAmB;AACrB;qCACqC;GACnC,YAAY;AACd;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AO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK;QAAE,EAAE,EAAE,OAAO,CAAA;KAAE,CAAA;IACzG;uFACmF;IACnF,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAC9B,CAAA;AAgBD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,wBAAwB,GAAG,gBAAgB,CAkNlF"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * COMMITMENT ANALYSIS — where a construct can still fail after it has consumed
3
+ * input or dirtied the capture buffers.
4
+ *
5
+ * This is a whole-grammar property of the rule graph, and it has exactly two
6
+ * consumers: the compiler, which bakes the decisions into the emitted source,
7
+ * and the interpreter, which must reach the SAME decisions at load time. It
8
+ * lives here, in one module, for that reason. Two hand-written copies of a
9
+ * predicate like `mayFail` would drift, and a drift here is not a size
10
+ * regression — it is the compiled and interpreted parsers accepting different
11
+ * languages. One module, two consumers.
12
+ *
13
+ * Every predicate in this file is a sound OVER-approximation of "something can
14
+ * go wrong": each MUST err toward `true`. A `false` is a proof obligation
15
+ * discharged on the caller's behalf, and callers delete code on the strength of
16
+ * it. Elide only where non-failure is PROVEN; when in doubt, say `true` and keep
17
+ * the machinery.
18
+ */
19
+ import type { Combinator } from '../types.ts';
20
+ /**
21
+ * Can `p` FAIL at all?
22
+ *
23
+ * `false` needs a construct whose definition is total: the empty literal,
24
+ * trivia (a scan of width 0 is a match), and the repeats — but the repeats only
25
+ * conditionally, see below.
26
+ *
27
+ * Everything else stays `true`, including two cases that look elidable and are
28
+ * not. A `choice` whose last arm is infallible is NOT infallible, because
29
+ * first-set gating decides at runtime which arms are entered at all and the
30
+ * total arm may be skipped. And a re-entered cycle is `true` rather than
31
+ * `false`: a recursive rule's own fallibility is exactly what the recursion is
32
+ * being asked about, so the safe fixpoint seed is the conservative one.
33
+ *
34
+ * TODO(0.47): `expect` is conservative here. It converts its inner parser's
35
+ * failure into a zero-width success carrying a parse-error node and therefore
36
+ * never fails, but it currently reports its inner parser's fallibility. Making
37
+ * it `false` would elide further; it needs its own pass through the tree-diff
38
+ * gate first, because `expect` sits at exactly the closing-delimiter positions
39
+ * where a wrong answer is most visible.
40
+ */
41
+ export declare function mayFail(p: Combinator<unknown>, seen?: Set<Combinator<unknown>>): boolean;
42
+ /**
43
+ * Does `p`, WHEN IT SUCCEEDS, always consume at least one character?
44
+ *
45
+ * The mirror of `mayFail`, and the opposite polarity from
46
+ * `first-set.ts`'s `matchesEmpty`: this one MUST err toward `false`. A `true`
47
+ * is a proof that the success path advanced the position, and the sequence
48
+ * emitter deletes a trivia rewind on the strength of it.
49
+ *
50
+ * It cannot be written as `!matchesEmpty(p)`. `matchesEmpty` answers a
51
+ * first-set question and is allowed to under-report nullability; for `expect`
52
+ * it does, and that case is exactly the one that matters here. `expect(X)`
53
+ * turns X's FAILURE into a zero-width SUCCESS carrying a parse-error node —
54
+ * so `expect(literal('}'))` succeeds having consumed nothing, while
55
+ * `matchesEmpty` looks through to the non-nullable literal and says "always
56
+ * consumes". Eliding on that answer moves a rule's span end past trailing
57
+ * trivia (measured: 38 tree mismatches across the css corpus, spans absorbing
58
+ * whitespace their legacy build excluded). `recover` manufactures the same
59
+ * zero-width success, and both are `false` here.
60
+ *
61
+ * `dispatch` is `false` rather than deferring to its selector: the selector's
62
+ * consumption is not unconditionally part of the dispatch's own span, and the
63
+ * few bytes are not worth the proof obligation.
64
+ */
65
+ export declare function alwaysConsumes(p: Combinator<unknown>, seen?: Set<Combinator<unknown>>): boolean;
66
+ /**
67
+ * True when parsing `p` may push a capture (leaf/child/trivia) into the active
68
+ * buffers and THEN fail, leaving partial state that an enclosing node() would
69
+ * wrongly absorb. Used to decide whether a fallible block needs CST-rollback.
70
+ *
71
+ * Sound over-approximation: the ONLY constructs that capture-then-fail are
72
+ * - a sequence whose non-final term captures before a later term can fail
73
+ * - a sepBy/oneOrMore item-then-separator partial (handled by their own
74
+ * dedicated rollback, so still covered conservatively here)
75
+ * Atomic terminals (literal/regex/keywords/charClass/guard/not) fail without
76
+ * having captured. node() buffers into a private sub-scope and discards it on
77
+ * failure, so it never leaks. choice/firstMatch roll back each failed arm
78
+ * internally. optional/many never "fail" with partial output. Delegating
79
+ * wrappers (transform/label/grammar/withCtx/expect) pass through to inner.
80
+ */
81
+ export declare function mayLeavePartialCapture(p: Combinator<unknown>, seen?: Set<Combinator<unknown>>, triviaActive?: boolean): boolean;
82
+ /** True when `p` can push a leaf/node into the capture buffers on success. */
83
+ export declare function capturesLeaf(p: Combinator<unknown>, seen?: Set<Combinator<unknown>>): boolean;
84
+ /**
85
+ * Does this combinator tree contain a node() anywhere (following ref/lazy
86
+ * thunks)? Determines whether the compile emits CST capture — so non-node
87
+ * grammars stay byte-identical. `seen` guards against recursion cycles.
88
+ */
89
+ export declare function hasNodeDef(p: Combinator<unknown>, seen?: Set<Combinator<unknown>>): boolean;
90
+ /**
91
+ * Whether a grammar tree owns a DIRECT semantic node reduction — a `node(..., build)`
92
+ * whose callback produces the value itself, as opposed to a purely structural
93
+ * `node(parser)`.
94
+ *
95
+ * It is the predicate behind `hostBranchElided`: an artifact only drops a
96
+ * positioned-CST branch if there was a direct builder to drop, so an all-structural
97
+ * grammar stays usable with either host (`cst/host-mode.ts`).
98
+ *
99
+ * It belongs in THIS module for the reason stated at the top of it: both lowerings
100
+ * must reach the same answer, and a stamp they disagree about is a driver that
101
+ * accepts a host it should refuse. It previously lived in `compiler/codegen.ts`,
102
+ * which forced `table/compile-rule-map.ts` to import the engine the table replaced.
103
+ *
104
+ * The descent mirrors the source lowering's own `childrenOf` exactly — including a
105
+ * `routed()` fallback and a `dispatch` matcher arm, both of which are real emit
106
+ * sites and neither of which `hasNodeDef` above walks.
107
+ */
108
+ export declare function hasDirectBuildDef(p: Combinator<unknown>, seen?: Set<Combinator<unknown>>): boolean;
109
+ /** True when `p` can report a committed failure through emitFallible's failure channel. */
110
+ export declare function mayCommitFailure(p: Combinator<unknown>, seen?: Set<Combinator<unknown>>): boolean;
111
+ /**
112
+ * `hasDirectBuilders` / `isRecognitionOnly` for a rule map WITHOUT lowering it.
113
+ *
114
+ * `composeLeaf()` gates on both: every pre-final grammar must prove recognition-only,
115
+ * and the local leaf's direct builders decide whether the recognition pieces need
116
+ * terminal capture. Both were only ever available as fields on `LinkablePieces`, so
117
+ * the gate forced a full `compileLinkable()` of every piece purely to read two
118
+ * booleans off the result — which is why the table lowering appeared to be blocked on
119
+ * porting the source lowering wholesale.
120
+ *
121
+ * They are not lowering products. Both are predicates over the COMBINATOR GRAPH, and
122
+ * this computes them from the graph directly, with the SAME `externalRefs` rule the
123
+ * lowering applies (`:6008`): a named `lazy` whose thunk throws is a HOLE, bound by
124
+ * name at fuse time, and is therefore not evidence of unknown semantics. An UNNAMED
125
+ * unresolved `ref()` stays semantic — nobody can bind it, so it fails closed.
126
+ */
127
+ export declare function classifyRuleMap(ruleMap: ReadonlyArray<readonly [string, Combinator<unknown>]>): {
128
+ hasDirectBuilders: boolean;
129
+ isRecognitionOnly: boolean;
130
+ };
131
+ //# sourceMappingURL=commitment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commitment.d.ts","sourceRoot":"","sources":["../../src/analysis/commitment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,aAAa,CAAA;AAIxD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,IAAI,GAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAa,GAAG,OAAO,CAqCnG;AAkCD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,IAAI,GAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAa,GAAG,OAAO,CAiC1G;AAED;;;;;;;;;;;;;;GAcG;AACH,w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