@azx-pbc/axiom-compiler 0.0.0-stage → 0.0.6

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 (655) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +415 -2
  3. package/dist/article.d.ts +12 -0
  4. package/dist/article.d.ts.map +1 -0
  5. package/dist/article.js +16 -0
  6. package/dist/article.js.map +1 -0
  7. package/dist/cli/args.d.ts +101 -0
  8. package/dist/cli/args.d.ts.map +1 -0
  9. package/dist/cli/args.js +158 -0
  10. package/dist/cli/args.js.map +1 -0
  11. package/dist/cli/check.d.ts +2 -0
  12. package/dist/cli/check.d.ts.map +1 -0
  13. package/dist/cli/check.js +33 -0
  14. package/dist/cli/check.js.map +1 -0
  15. package/dist/cli/compile.d.ts +2 -0
  16. package/dist/cli/compile.d.ts.map +1 -0
  17. package/dist/cli/compile.js +43 -0
  18. package/dist/cli/compile.js.map +1 -0
  19. package/dist/cli/count.d.ts +15 -0
  20. package/dist/cli/count.d.ts.map +1 -0
  21. package/dist/cli/count.js +21 -0
  22. package/dist/cli/count.js.map +1 -0
  23. package/dist/cli/dataset.d.ts +28 -0
  24. package/dist/cli/dataset.d.ts.map +1 -0
  25. package/dist/cli/dataset.js +115 -0
  26. package/dist/cli/dataset.js.map +1 -0
  27. package/dist/cli/diff.d.ts +2 -0
  28. package/dist/cli/diff.d.ts.map +1 -0
  29. package/dist/cli/diff.js +297 -0
  30. package/dist/cli/diff.js.map +1 -0
  31. package/dist/cli/explain.d.ts +2 -0
  32. package/dist/cli/explain.d.ts.map +1 -0
  33. package/dist/cli/explain.js +95 -0
  34. package/dist/cli/explain.js.map +1 -0
  35. package/dist/cli/fields.d.ts +11 -0
  36. package/dist/cli/fields.d.ts.map +1 -0
  37. package/dist/cli/fields.js +13 -0
  38. package/dist/cli/fields.js.map +1 -0
  39. package/dist/cli/main.d.ts +2 -0
  40. package/dist/cli/main.d.ts.map +1 -0
  41. package/dist/cli/main.js +40 -0
  42. package/dist/cli/main.js.map +1 -0
  43. package/dist/cli/read.d.ts +56 -0
  44. package/dist/cli/read.d.ts.map +1 -0
  45. package/dist/cli/read.js +179 -0
  46. package/dist/cli/read.js.map +1 -0
  47. package/dist/cli/render.d.ts +58 -0
  48. package/dist/cli/render.d.ts.map +1 -0
  49. package/dist/cli/render.js +422 -0
  50. package/dist/cli/render.js.map +1 -0
  51. package/dist/cli/schema.d.ts +28 -0
  52. package/dist/cli/schema.d.ts.map +1 -0
  53. package/dist/cli/schema.js +46 -0
  54. package/dist/cli/schema.js.map +1 -0
  55. package/dist/cli/suite-report.d.ts +18 -0
  56. package/dist/cli/suite-report.d.ts.map +1 -0
  57. package/dist/cli/suite-report.js +58 -0
  58. package/dist/cli/suite-report.js.map +1 -0
  59. package/dist/cli/suites.d.ts +25 -0
  60. package/dist/cli/suites.d.ts.map +1 -0
  61. package/dist/cli/suites.js +67 -0
  62. package/dist/cli/suites.js.map +1 -0
  63. package/dist/cli/terminal.d.ts +45 -0
  64. package/dist/cli/terminal.d.ts.map +1 -0
  65. package/dist/cli/terminal.js +119 -0
  66. package/dist/cli/terminal.js.map +1 -0
  67. package/dist/cli/test.d.ts +12 -0
  68. package/dist/cli/test.d.ts.map +1 -0
  69. package/dist/cli/test.js +199 -0
  70. package/dist/cli/test.js.map +1 -0
  71. package/dist/cli/usage.d.ts +15 -0
  72. package/dist/cli/usage.d.ts.map +1 -0
  73. package/dist/cli/usage.js +95 -0
  74. package/dist/cli/usage.js.map +1 -0
  75. package/dist/cli.d.ts +3 -0
  76. package/dist/cli.d.ts.map +1 -0
  77. package/dist/cli.js +51 -0
  78. package/dist/cli.js.map +1 -0
  79. package/dist/compile/artifact-members.d.ts +57 -0
  80. package/dist/compile/artifact-members.d.ts.map +1 -0
  81. package/dist/compile/artifact-members.js +130 -0
  82. package/dist/compile/artifact-members.js.map +1 -0
  83. package/dist/compile/artifact.d.ts +20 -0
  84. package/dist/compile/artifact.d.ts.map +1 -0
  85. package/dist/compile/artifact.js +87 -0
  86. package/dist/compile/artifact.js.map +1 -0
  87. package/dist/compile/compilation.d.ts +46 -0
  88. package/dist/compile/compilation.d.ts.map +1 -0
  89. package/dist/compile/compilation.js +4 -0
  90. package/dist/compile/compilation.js.map +1 -0
  91. package/dist/compile/computed.d.ts +22 -0
  92. package/dist/compile/computed.d.ts.map +1 -0
  93. package/dist/compile/computed.js +245 -0
  94. package/dist/compile/computed.js.map +1 -0
  95. package/dist/compile/condition-warnings.d.ts +12 -0
  96. package/dist/compile/condition-warnings.d.ts.map +1 -0
  97. package/dist/compile/condition-warnings.js +26 -0
  98. package/dist/compile/condition-warnings.js.map +1 -0
  99. package/dist/compile/conditions.d.ts +18 -0
  100. package/dist/compile/conditions.d.ts.map +1 -0
  101. package/dist/compile/conditions.js +22 -0
  102. package/dist/compile/conditions.js.map +1 -0
  103. package/dist/compile/cross-checks.d.ts +67 -0
  104. package/dist/compile/cross-checks.d.ts.map +1 -0
  105. package/dist/compile/cross-checks.js +238 -0
  106. package/dist/compile/cross-checks.js.map +1 -0
  107. package/dist/compile/datasets.d.ts +52 -0
  108. package/dist/compile/datasets.d.ts.map +1 -0
  109. package/dist/compile/datasets.js +183 -0
  110. package/dist/compile/datasets.js.map +1 -0
  111. package/dist/compile/dead-weight.d.ts +26 -0
  112. package/dist/compile/dead-weight.d.ts.map +1 -0
  113. package/dist/compile/dead-weight.js +244 -0
  114. package/dist/compile/dead-weight.js.map +1 -0
  115. package/dist/compile/declaration-rules.d.ts +54 -0
  116. package/dist/compile/declaration-rules.d.ts.map +1 -0
  117. package/dist/compile/declaration-rules.js +510 -0
  118. package/dist/compile/declaration-rules.js.map +1 -0
  119. package/dist/compile/declarations.d.ts +44 -0
  120. package/dist/compile/declarations.d.ts.map +1 -0
  121. package/dist/compile/declarations.js +160 -0
  122. package/dist/compile/declarations.js.map +1 -0
  123. package/dist/compile/document.d.ts +4 -0
  124. package/dist/compile/document.d.ts.map +1 -0
  125. package/dist/compile/document.js +13 -0
  126. package/dist/compile/document.js.map +1 -0
  127. package/dist/compile/expression.d.ts +38 -0
  128. package/dist/compile/expression.d.ts.map +1 -0
  129. package/dist/compile/expression.js +288 -0
  130. package/dist/compile/expression.js.map +1 -0
  131. package/dist/compile/hashes.d.ts +26 -0
  132. package/dist/compile/hashes.d.ts.map +1 -0
  133. package/dist/compile/hashes.js +96 -0
  134. package/dist/compile/hashes.js.map +1 -0
  135. package/dist/compile/item-targets.d.ts +12 -0
  136. package/dist/compile/item-targets.d.ts.map +1 -0
  137. package/dist/compile/item-targets.js +287 -0
  138. package/dist/compile/item-targets.js.map +1 -0
  139. package/dist/compile/messages.d.ts +8 -0
  140. package/dist/compile/messages.d.ts.map +1 -0
  141. package/dist/compile/messages.js +62 -0
  142. package/dist/compile/messages.js.map +1 -0
  143. package/dist/compile/option-availability.d.ts +51 -0
  144. package/dist/compile/option-availability.d.ts.map +1 -0
  145. package/dist/compile/option-availability.js +171 -0
  146. package/dist/compile/option-availability.js.map +1 -0
  147. package/dist/compile/option-codes.d.ts +27 -0
  148. package/dist/compile/option-codes.d.ts.map +1 -0
  149. package/dist/compile/option-codes.js +212 -0
  150. package/dist/compile/option-codes.js.map +1 -0
  151. package/dist/compile/references.d.ts +14 -0
  152. package/dist/compile/references.d.ts.map +1 -0
  153. package/dist/compile/references.js +126 -0
  154. package/dist/compile/references.js.map +1 -0
  155. package/dist/compile/rows-from.d.ts +27 -0
  156. package/dist/compile/rows-from.d.ts.map +1 -0
  157. package/dist/compile/rows-from.js +164 -0
  158. package/dist/compile/rows-from.js.map +1 -0
  159. package/dist/compile/rules.d.ts +58 -0
  160. package/dist/compile/rules.d.ts.map +1 -0
  161. package/dist/compile/rules.js +327 -0
  162. package/dist/compile/rules.js.map +1 -0
  163. package/dist/compile/suggestions.d.ts +52 -0
  164. package/dist/compile/suggestions.d.ts.map +1 -0
  165. package/dist/compile/suggestions.js +633 -0
  166. package/dist/compile/suggestions.js.map +1 -0
  167. package/dist/compile/targets.d.ts +22 -0
  168. package/dist/compile/targets.d.ts.map +1 -0
  169. package/dist/compile/targets.js +125 -0
  170. package/dist/compile/targets.js.map +1 -0
  171. package/dist/compile/types.d.ts +84 -0
  172. package/dist/compile/types.d.ts.map +1 -0
  173. package/dist/compile/types.js +2 -0
  174. package/dist/compile/types.js.map +1 -0
  175. package/dist/compile/warning.d.ts +45 -0
  176. package/dist/compile/warning.d.ts.map +1 -0
  177. package/dist/compile/warning.js +2 -0
  178. package/dist/compile/warning.js.map +1 -0
  179. package/dist/compile-yaml.d.ts +23 -0
  180. package/dist/compile-yaml.d.ts.map +1 -0
  181. package/dist/compile-yaml.js +30 -0
  182. package/dist/compile-yaml.js.map +1 -0
  183. package/dist/compile.d.ts +78 -0
  184. package/dist/compile.d.ts.map +1 -0
  185. package/dist/compile.js +372 -0
  186. package/dist/compile.js.map +1 -0
  187. package/dist/csv/limits.d.ts +43 -0
  188. package/dist/csv/limits.d.ts.map +1 -0
  189. package/dist/csv/limits.js +51 -0
  190. package/dist/csv/limits.js.map +1 -0
  191. package/dist/csv/scalar.d.ts +33 -0
  192. package/dist/csv/scalar.d.ts.map +1 -0
  193. package/dist/csv/scalar.js +77 -0
  194. package/dist/csv/scalar.js.map +1 -0
  195. package/dist/datasets/csv.d.ts +46 -0
  196. package/dist/datasets/csv.d.ts.map +1 -0
  197. package/dist/datasets/csv.js +293 -0
  198. package/dist/datasets/csv.js.map +1 -0
  199. package/dist/datasets/declaration.d.ts +16 -0
  200. package/dist/datasets/declaration.d.ts.map +1 -0
  201. package/dist/datasets/declaration.js +104 -0
  202. package/dist/datasets/declaration.js.map +1 -0
  203. package/dist/datasets/diagnostics.d.ts +65 -0
  204. package/dist/datasets/diagnostics.d.ts.map +1 -0
  205. package/dist/datasets/diagnostics.js +2 -0
  206. package/dist/datasets/diagnostics.js.map +1 -0
  207. package/dist/datasets/diff.d.ts +46 -0
  208. package/dist/datasets/diff.d.ts.map +1 -0
  209. package/dist/datasets/diff.js +84 -0
  210. package/dist/datasets/diff.js.map +1 -0
  211. package/dist/datasets/document.d.ts +12 -0
  212. package/dist/datasets/document.d.ts.map +1 -0
  213. package/dist/datasets/document.js +382 -0
  214. package/dist/datasets/document.js.map +1 -0
  215. package/dist/datasets/index.d.ts +43 -0
  216. package/dist/datasets/index.d.ts.map +1 -0
  217. package/dist/datasets/index.js +68 -0
  218. package/dist/datasets/index.js.map +1 -0
  219. package/dist/datasets/repair.d.ts +26 -0
  220. package/dist/datasets/repair.d.ts.map +1 -0
  221. package/dist/datasets/repair.js +60 -0
  222. package/dist/datasets/repair.js.map +1 -0
  223. package/dist/document-path.d.ts +62 -0
  224. package/dist/document-path.d.ts.map +1 -0
  225. package/dist/document-path.js +200 -0
  226. package/dist/document-path.js.map +1 -0
  227. package/dist/expr/boundary.d.ts +8 -0
  228. package/dist/expr/boundary.d.ts.map +1 -0
  229. package/dist/expr/boundary.js +243 -0
  230. package/dist/expr/boundary.js.map +1 -0
  231. package/dist/expr/compile-expr.d.ts +35 -0
  232. package/dist/expr/compile-expr.d.ts.map +1 -0
  233. package/dist/expr/compile-expr.js +66 -0
  234. package/dist/expr/compile-expr.js.map +1 -0
  235. package/dist/expr/deprecation.d.ts +23 -0
  236. package/dist/expr/deprecation.d.ts.map +1 -0
  237. package/dist/expr/deprecation.js +28 -0
  238. package/dist/expr/deprecation.js.map +1 -0
  239. package/dist/expr/diagnostics.d.ts +31 -0
  240. package/dist/expr/diagnostics.d.ts.map +1 -0
  241. package/dist/expr/diagnostics.js +34 -0
  242. package/dist/expr/diagnostics.js.map +1 -0
  243. package/dist/expr/lexer.d.ts +49 -0
  244. package/dist/expr/lexer.d.ts.map +1 -0
  245. package/dist/expr/lexer.js +277 -0
  246. package/dist/expr/lexer.js.map +1 -0
  247. package/dist/expr/lint-warnings.d.ts +11 -0
  248. package/dist/expr/lint-warnings.d.ts.map +1 -0
  249. package/dist/expr/lint-warnings.js +20 -0
  250. package/dist/expr/lint-warnings.js.map +1 -0
  251. package/dist/expr/lint.d.ts +41 -0
  252. package/dist/expr/lint.d.ts.map +1 -0
  253. package/dist/expr/lint.js +1034 -0
  254. package/dist/expr/lint.js.map +1 -0
  255. package/dist/expr/parse/aggregates.d.ts +13 -0
  256. package/dist/expr/parse/aggregates.d.ts.map +1 -0
  257. package/dist/expr/parse/aggregates.js +48 -0
  258. package/dist/expr/parse/aggregates.js.map +1 -0
  259. package/dist/expr/parse/budget.d.ts +11 -0
  260. package/dist/expr/parse/budget.d.ts.map +1 -0
  261. package/dist/expr/parse/budget.js +57 -0
  262. package/dist/expr/parse/budget.js.map +1 -0
  263. package/dist/expr/parse/grammar.d.ts +9 -0
  264. package/dist/expr/parse/grammar.d.ts.map +1 -0
  265. package/dist/expr/parse/grammar.js +699 -0
  266. package/dist/expr/parse/grammar.js.map +1 -0
  267. package/dist/expr/parse/literals.d.ts +20 -0
  268. package/dist/expr/parse/literals.d.ts.map +1 -0
  269. package/dist/expr/parse/literals.js +132 -0
  270. package/dist/expr/parse/literals.js.map +1 -0
  271. package/dist/expr/parse/stream.d.ts +60 -0
  272. package/dist/expr/parse/stream.d.ts.map +1 -0
  273. package/dist/expr/parse/stream.js +151 -0
  274. package/dist/expr/parse/stream.js.map +1 -0
  275. package/dist/expr/parser.d.ts +45 -0
  276. package/dist/expr/parser.d.ts.map +1 -0
  277. package/dist/expr/parser.js +110 -0
  278. package/dist/expr/parser.js.map +1 -0
  279. package/dist/expr/print/spell.d.ts +78 -0
  280. package/dist/expr/print/spell.d.ts.map +1 -0
  281. package/dist/expr/print/spell.js +592 -0
  282. package/dist/expr/print/spell.js.map +1 -0
  283. package/dist/expr/print.d.ts +20 -0
  284. package/dist/expr/print.d.ts.map +1 -0
  285. package/dist/expr/print.js +102 -0
  286. package/dist/expr/print.js.map +1 -0
  287. package/dist/expr/suggest.d.ts +26 -0
  288. package/dist/expr/suggest.d.ts.map +1 -0
  289. package/dist/expr/suggest.js +77 -0
  290. package/dist/expr/suggest.js.map +1 -0
  291. package/dist/expr/typecheck/aggregates.d.ts +8 -0
  292. package/dist/expr/typecheck/aggregates.d.ts.map +1 -0
  293. package/dist/expr/typecheck/aggregates.js +334 -0
  294. package/dist/expr/typecheck/aggregates.js.map +1 -0
  295. package/dist/expr/typecheck/arithmetic.d.ts +6 -0
  296. package/dist/expr/typecheck/arithmetic.d.ts.map +1 -0
  297. package/dist/expr/typecheck/arithmetic.js +258 -0
  298. package/dist/expr/typecheck/arithmetic.js.map +1 -0
  299. package/dist/expr/typecheck/arity.d.ts +38 -0
  300. package/dist/expr/typecheck/arity.d.ts.map +1 -0
  301. package/dist/expr/typecheck/arity.js +173 -0
  302. package/dist/expr/typecheck/arity.js.map +1 -0
  303. package/dist/expr/typecheck/calls.d.ts +6 -0
  304. package/dist/expr/typecheck/calls.d.ts.map +1 -0
  305. package/dist/expr/typecheck/calls.js +137 -0
  306. package/dist/expr/typecheck/calls.js.map +1 -0
  307. package/dist/expr/typecheck/comparison.d.ts +13 -0
  308. package/dist/expr/typecheck/comparison.d.ts.map +1 -0
  309. package/dist/expr/typecheck/comparison.js +200 -0
  310. package/dist/expr/typecheck/comparison.js.map +1 -0
  311. package/dist/expr/typecheck/compound.d.ts +24 -0
  312. package/dist/expr/typecheck/compound.d.ts.map +1 -0
  313. package/dist/expr/typecheck/compound.js +175 -0
  314. package/dist/expr/typecheck/compound.js.map +1 -0
  315. package/dist/expr/typecheck/context.d.ts +44 -0
  316. package/dist/expr/typecheck/context.d.ts.map +1 -0
  317. package/dist/expr/typecheck/context.js +2 -0
  318. package/dist/expr/typecheck/context.js.map +1 -0
  319. package/dist/expr/typecheck/datasets.d.ts +17 -0
  320. package/dist/expr/typecheck/datasets.d.ts.map +1 -0
  321. package/dist/expr/typecheck/datasets.js +136 -0
  322. package/dist/expr/typecheck/datasets.js.map +1 -0
  323. package/dist/expr/typecheck/digest.d.ts +7 -0
  324. package/dist/expr/typecheck/digest.d.ts.map +1 -0
  325. package/dist/expr/typecheck/digest.js +44 -0
  326. package/dist/expr/typecheck/digest.js.map +1 -0
  327. package/dist/expr/typecheck/fold.d.ts +41 -0
  328. package/dist/expr/typecheck/fold.d.ts.map +1 -0
  329. package/dist/expr/typecheck/fold.js +71 -0
  330. package/dist/expr/typecheck/fold.js.map +1 -0
  331. package/dist/expr/typecheck/gate-folds.d.ts +22 -0
  332. package/dist/expr/typecheck/gate-folds.d.ts.map +1 -0
  333. package/dist/expr/typecheck/gate-folds.js +40 -0
  334. package/dist/expr/typecheck/gate-folds.js.map +1 -0
  335. package/dist/expr/typecheck/guards.d.ts +6 -0
  336. package/dist/expr/typecheck/guards.d.ts.map +1 -0
  337. package/dist/expr/typecheck/guards.js +38 -0
  338. package/dist/expr/typecheck/guards.js.map +1 -0
  339. package/dist/expr/typecheck/member.d.ts +17 -0
  340. package/dist/expr/typecheck/member.d.ts.map +1 -0
  341. package/dist/expr/typecheck/member.js +46 -0
  342. package/dist/expr/typecheck/member.js.map +1 -0
  343. package/dist/expr/typecheck/money.d.ts +8 -0
  344. package/dist/expr/typecheck/money.d.ts.map +1 -0
  345. package/dist/expr/typecheck/money.js +49 -0
  346. package/dist/expr/typecheck/money.js.map +1 -0
  347. package/dist/expr/typecheck/numeric.d.ts +8 -0
  348. package/dist/expr/typecheck/numeric.d.ts.map +1 -0
  349. package/dist/expr/typecheck/numeric.js +84 -0
  350. package/dist/expr/typecheck/numeric.js.map +1 -0
  351. package/dist/expr/typecheck/operands.d.ts +27 -0
  352. package/dist/expr/typecheck/operands.d.ts.map +1 -0
  353. package/dist/expr/typecheck/operands.js +106 -0
  354. package/dist/expr/typecheck/operands.js.map +1 -0
  355. package/dist/expr/typecheck/paths.d.ts +21 -0
  356. package/dist/expr/typecheck/paths.d.ts.map +1 -0
  357. package/dist/expr/typecheck/paths.js +321 -0
  358. package/dist/expr/typecheck/paths.js.map +1 -0
  359. package/dist/expr/typecheck/records.d.ts +24 -0
  360. package/dist/expr/typecheck/records.d.ts.map +1 -0
  361. package/dist/expr/typecheck/records.js +53 -0
  362. package/dist/expr/typecheck/records.js.map +1 -0
  363. package/dist/expr/typecheck/sequences.d.ts +15 -0
  364. package/dist/expr/typecheck/sequences.d.ts.map +1 -0
  365. package/dist/expr/typecheck/sequences.js +55 -0
  366. package/dist/expr/typecheck/sequences.js.map +1 -0
  367. package/dist/expr/typecheck/strings.d.ts +8 -0
  368. package/dist/expr/typecheck/strings.d.ts.map +1 -0
  369. package/dist/expr/typecheck/strings.js +188 -0
  370. package/dist/expr/typecheck/strings.js.map +1 -0
  371. package/dist/expr/typecheck/temporal.d.ts +7 -0
  372. package/dist/expr/typecheck/temporal.d.ts.map +1 -0
  373. package/dist/expr/typecheck/temporal.js +80 -0
  374. package/dist/expr/typecheck/temporal.js.map +1 -0
  375. package/dist/expr/typecheck/types.d.ts +163 -0
  376. package/dist/expr/typecheck/types.d.ts.map +1 -0
  377. package/dist/expr/typecheck/types.js +404 -0
  378. package/dist/expr/typecheck/types.js.map +1 -0
  379. package/dist/expr/typecheck.d.ts +75 -0
  380. package/dist/expr/typecheck.d.ts.map +1 -0
  381. package/dist/expr/typecheck.js +242 -0
  382. package/dist/expr/typecheck.js.map +1 -0
  383. package/dist/expr/undecided.d.ts +13 -0
  384. package/dist/expr/undecided.d.ts.map +1 -0
  385. package/dist/expr/undecided.js +58 -0
  386. package/dist/expr/undecided.js.map +1 -0
  387. package/dist/expr/values/code-points.d.ts +13 -0
  388. package/dist/expr/values/code-points.d.ts.map +1 -0
  389. package/dist/expr/values/code-points.js +25 -0
  390. package/dist/expr/values/code-points.js.map +1 -0
  391. package/dist/expr/values/inline.d.ts +77 -0
  392. package/dist/expr/values/inline.d.ts.map +1 -0
  393. package/dist/expr/values/inline.js +404 -0
  394. package/dist/expr/values/inline.js.map +1 -0
  395. package/dist/expr/values/interval.d.ts +19 -0
  396. package/dist/expr/values/interval.d.ts.map +1 -0
  397. package/dist/expr/values/interval.js +1180 -0
  398. package/dist/expr/values/interval.js.map +1 -0
  399. package/dist/index.d.ts +163 -0
  400. package/dist/index.d.ts.map +1 -0
  401. package/dist/index.js +128 -0
  402. package/dist/index.js.map +1 -0
  403. package/dist/ingest/document.d.ts +58 -0
  404. package/dist/ingest/document.d.ts.map +1 -0
  405. package/dist/ingest/document.js +83 -0
  406. package/dist/ingest/document.js.map +1 -0
  407. package/dist/ingest/yaml-document.d.ts +15 -0
  408. package/dist/ingest/yaml-document.d.ts.map +1 -0
  409. package/dist/ingest/yaml-document.js +42 -0
  410. package/dist/ingest/yaml-document.js.map +1 -0
  411. package/dist/ingest/yaml.d.ts +51 -0
  412. package/dist/ingest/yaml.d.ts.map +1 -0
  413. package/dist/ingest/yaml.js +340 -0
  414. package/dist/ingest/yaml.js.map +1 -0
  415. package/dist/layout/compile.d.ts +6 -0
  416. package/dist/layout/compile.d.ts.map +1 -0
  417. package/dist/layout/compile.js +224 -0
  418. package/dist/layout/compile.js.map +1 -0
  419. package/dist/layout/context.d.ts +12 -0
  420. package/dist/layout/context.d.ts.map +1 -0
  421. package/dist/layout/context.js +26 -0
  422. package/dist/layout/context.js.map +1 -0
  423. package/dist/layout/grammar.d.ts +34 -0
  424. package/dist/layout/grammar.d.ts.map +1 -0
  425. package/dist/layout/grammar.js +171 -0
  426. package/dist/layout/grammar.js.map +1 -0
  427. package/dist/layout/read.d.ts +54 -0
  428. package/dist/layout/read.d.ts.map +1 -0
  429. package/dist/layout/read.js +101 -0
  430. package/dist/layout/read.js.map +1 -0
  431. package/dist/layout/shape.d.ts +34 -0
  432. package/dist/layout/shape.d.ts.map +1 -0
  433. package/dist/layout/shape.js +149 -0
  434. package/dist/layout/shape.js.map +1 -0
  435. package/dist/messages/compile.d.ts +47 -0
  436. package/dist/messages/compile.d.ts.map +1 -0
  437. package/dist/messages/compile.js +202 -0
  438. package/dist/messages/compile.js.map +1 -0
  439. package/dist/messages/locale.d.ts +18 -0
  440. package/dist/messages/locale.d.ts.map +1 -0
  441. package/dist/messages/locale.js +33 -0
  442. package/dist/messages/locale.js.map +1 -0
  443. package/dist/messages/slots.d.ts +54 -0
  444. package/dist/messages/slots.d.ts.map +1 -0
  445. package/dist/messages/slots.js +137 -0
  446. package/dist/messages/slots.js.map +1 -0
  447. package/dist/overlay/compile-overlay.d.ts +29 -0
  448. package/dist/overlay/compile-overlay.d.ts.map +1 -0
  449. package/dist/overlay/compile-overlay.js +120 -0
  450. package/dist/overlay/compile-overlay.js.map +1 -0
  451. package/dist/overlay/compose.d.ts +26 -0
  452. package/dist/overlay/compose.d.ts.map +1 -0
  453. package/dist/overlay/compose.js +674 -0
  454. package/dist/overlay/compose.js.map +1 -0
  455. package/dist/overlay/types.d.ts +41 -0
  456. package/dist/overlay/types.d.ts.map +1 -0
  457. package/dist/overlay/types.js +2 -0
  458. package/dist/overlay/types.js.map +1 -0
  459. package/dist/publish/classify.d.ts +50 -0
  460. package/dist/publish/classify.d.ts.map +1 -0
  461. package/dist/publish/classify.js +85 -0
  462. package/dist/publish/classify.js.map +1 -0
  463. package/dist/publish/environment.d.ts +15 -0
  464. package/dist/publish/environment.d.ts.map +1 -0
  465. package/dist/publish/environment.js +2 -0
  466. package/dist/publish/environment.js.map +1 -0
  467. package/dist/publish/migrations.d.ts +108 -0
  468. package/dist/publish/migrations.d.ts.map +1 -0
  469. package/dist/publish/migrations.js +166 -0
  470. package/dist/publish/migrations.js.map +1 -0
  471. package/dist/publish/observation.d.ts +29 -0
  472. package/dist/publish/observation.d.ts.map +1 -0
  473. package/dist/publish/observation.js +43 -0
  474. package/dist/publish/observation.js.map +1 -0
  475. package/dist/publish/readiness.d.ts +197 -0
  476. package/dist/publish/readiness.d.ts.map +1 -0
  477. package/dist/publish/readiness.js +239 -0
  478. package/dist/publish/readiness.js.map +1 -0
  479. package/dist/publish/vectors.d.ts +50 -0
  480. package/dist/publish/vectors.d.ts.map +1 -0
  481. package/dist/publish/vectors.js +306 -0
  482. package/dist/publish/vectors.js.map +1 -0
  483. package/dist/publish/verify.d.ts +146 -0
  484. package/dist/publish/verify.d.ts.map +1 -0
  485. package/dist/publish/verify.js +548 -0
  486. package/dist/publish/verify.js.map +1 -0
  487. package/dist/scenarios/branch.d.ts +36 -0
  488. package/dist/scenarios/branch.d.ts.map +1 -0
  489. package/dist/scenarios/branch.js +30 -0
  490. package/dist/scenarios/branch.js.map +1 -0
  491. package/dist/scenarios/capture.d.ts +89 -0
  492. package/dist/scenarios/capture.d.ts.map +1 -0
  493. package/dist/scenarios/capture.js +443 -0
  494. package/dist/scenarios/capture.js.map +1 -0
  495. package/dist/scenarios/classifier.d.ts +20 -0
  496. package/dist/scenarios/classifier.d.ts.map +1 -0
  497. package/dist/scenarios/classifier.js +88 -0
  498. package/dist/scenarios/classifier.js.map +1 -0
  499. package/dist/scenarios/credit.d.ts +33 -0
  500. package/dist/scenarios/credit.d.ts.map +1 -0
  501. package/dist/scenarios/credit.js +330 -0
  502. package/dist/scenarios/credit.js.map +1 -0
  503. package/dist/scenarios/csv.d.ts +34 -0
  504. package/dist/scenarios/csv.d.ts.map +1 -0
  505. package/dist/scenarios/csv.js +1047 -0
  506. package/dist/scenarios/csv.js.map +1 -0
  507. package/dist/scenarios/data-identity.d.ts +39 -0
  508. package/dist/scenarios/data-identity.d.ts.map +1 -0
  509. package/dist/scenarios/data-identity.js +28 -0
  510. package/dist/scenarios/data-identity.js.map +1 -0
  511. package/dist/scenarios/document.d.ts +148 -0
  512. package/dist/scenarios/document.d.ts.map +1 -0
  513. package/dist/scenarios/document.js +513 -0
  514. package/dist/scenarios/document.js.map +1 -0
  515. package/dist/scenarios/environment.d.ts +64 -0
  516. package/dist/scenarios/environment.d.ts.map +1 -0
  517. package/dist/scenarios/environment.js +106 -0
  518. package/dist/scenarios/environment.js.map +1 -0
  519. package/dist/scenarios/evidence.d.ts +128 -0
  520. package/dist/scenarios/evidence.d.ts.map +1 -0
  521. package/dist/scenarios/evidence.js +179 -0
  522. package/dist/scenarios/evidence.js.map +1 -0
  523. package/dist/scenarios/expectations.d.ts +63 -0
  524. package/dist/scenarios/expectations.d.ts.map +1 -0
  525. package/dist/scenarios/expectations.js +490 -0
  526. package/dist/scenarios/expectations.js.map +1 -0
  527. package/dist/scenarios/references.d.ts +15 -0
  528. package/dist/scenarios/references.d.ts.map +1 -0
  529. package/dist/scenarios/references.js +239 -0
  530. package/dist/scenarios/references.js.map +1 -0
  531. package/dist/scenarios/report.d.ts +216 -0
  532. package/dist/scenarios/report.d.ts.map +1 -0
  533. package/dist/scenarios/report.js +54 -0
  534. package/dist/scenarios/report.js.map +1 -0
  535. package/dist/scenarios/runner.d.ts +55 -0
  536. package/dist/scenarios/runner.d.ts.map +1 -0
  537. package/dist/scenarios/runner.js +205 -0
  538. package/dist/scenarios/runner.js.map +1 -0
  539. package/dist/scenarios/vocabulary.d.ts +19 -0
  540. package/dist/scenarios/vocabulary.d.ts.map +1 -0
  541. package/dist/scenarios/vocabulary.js +56 -0
  542. package/dist/scenarios/vocabulary.js.map +1 -0
  543. package/dist/schema/catalogue.d.ts +54 -0
  544. package/dist/schema/catalogue.d.ts.map +1 -0
  545. package/dist/schema/catalogue.js +221 -0
  546. package/dist/schema/catalogue.js.map +1 -0
  547. package/dist/schema/check.d.ts +22 -0
  548. package/dist/schema/check.d.ts.map +1 -0
  549. package/dist/schema/check.js +30 -0
  550. package/dist/schema/check.js.map +1 -0
  551. package/dist/schema/closed.d.ts +19 -0
  552. package/dist/schema/closed.d.ts.map +1 -0
  553. package/dist/schema/closed.js +33 -0
  554. package/dist/schema/closed.js.map +1 -0
  555. package/dist/schema/collapse.d.ts +27 -0
  556. package/dist/schema/collapse.d.ts.map +1 -0
  557. package/dist/schema/collapse.js +143 -0
  558. package/dist/schema/collapse.js.map +1 -0
  559. package/dist/schema/controls.d.ts +46 -0
  560. package/dist/schema/controls.d.ts.map +1 -0
  561. package/dist/schema/controls.js +75 -0
  562. package/dist/schema/controls.js.map +1 -0
  563. package/dist/schema/dataset-declaration.d.ts +11 -0
  564. package/dist/schema/dataset-declaration.d.ts.map +1 -0
  565. package/dist/schema/dataset-declaration.js +11 -0
  566. package/dist/schema/dataset-declaration.js.map +1 -0
  567. package/dist/schema/declaration-warnings.d.ts +14 -0
  568. package/dist/schema/declaration-warnings.d.ts.map +1 -0
  569. package/dist/schema/declaration-warnings.js +77 -0
  570. package/dist/schema/declaration-warnings.js.map +1 -0
  571. package/dist/schema/declarations.d.ts +41 -0
  572. package/dist/schema/declarations.d.ts.map +1 -0
  573. package/dist/schema/declarations.js +1299 -0
  574. package/dist/schema/declarations.js.map +1 -0
  575. package/dist/schema/diagnostic.d.ts +118 -0
  576. package/dist/schema/diagnostic.d.ts.map +1 -0
  577. package/dist/schema/diagnostic.js +39 -0
  578. package/dist/schema/diagnostic.js.map +1 -0
  579. package/dist/schema/document.d.ts +93 -0
  580. package/dist/schema/document.d.ts.map +1 -0
  581. package/dist/schema/document.js +507 -0
  582. package/dist/schema/document.js.map +1 -0
  583. package/dist/schema/fields.d.ts +11 -0
  584. package/dist/schema/fields.d.ts.map +1 -0
  585. package/dist/schema/fields.js +265 -0
  586. package/dist/schema/fields.js.map +1 -0
  587. package/dist/schema/gates.d.ts +4 -0
  588. package/dist/schema/gates.d.ts.map +1 -0
  589. package/dist/schema/gates.js +68 -0
  590. package/dist/schema/gates.js.map +1 -0
  591. package/dist/schema/located.d.ts +27 -0
  592. package/dist/schema/located.d.ts.map +1 -0
  593. package/dist/schema/located.js +56 -0
  594. package/dist/schema/located.js.map +1 -0
  595. package/dist/schema/measurement.d.ts +9 -0
  596. package/dist/schema/measurement.d.ts.map +1 -0
  597. package/dist/schema/measurement.js +38 -0
  598. package/dist/schema/measurement.js.map +1 -0
  599. package/dist/schema/member-wording.d.ts +35 -0
  600. package/dist/schema/member-wording.d.ts.map +1 -0
  601. package/dist/schema/member-wording.js +286 -0
  602. package/dist/schema/member-wording.js.map +1 -0
  603. package/dist/schema/metaschema.d.ts +20 -0
  604. package/dist/schema/metaschema.d.ts.map +1 -0
  605. package/dist/schema/metaschema.js +476 -0
  606. package/dist/schema/metaschema.js.map +1 -0
  607. package/dist/schema/pointer.d.ts +31 -0
  608. package/dist/schema/pointer.d.ts.map +1 -0
  609. package/dist/schema/pointer.js +73 -0
  610. package/dist/schema/pointer.js.map +1 -0
  611. package/dist/schema/primary.d.ts +29 -0
  612. package/dist/schema/primary.d.ts.map +1 -0
  613. package/dist/schema/primary.js +48 -0
  614. package/dist/schema/primary.js.map +1 -0
  615. package/dist/schema/publish-vector.d.ts +17 -0
  616. package/dist/schema/publish-vector.d.ts.map +1 -0
  617. package/dist/schema/publish-vector.js +34 -0
  618. package/dist/schema/publish-vector.js.map +1 -0
  619. package/dist/schema/repair.d.ts +34 -0
  620. package/dist/schema/repair.d.ts.map +1 -0
  621. package/dist/schema/repair.js +163 -0
  622. package/dist/schema/repair.js.map +1 -0
  623. package/dist/schema/schema-v1.generated.d.ts +14 -0
  624. package/dist/schema/schema-v1.generated.d.ts.map +1 -0
  625. package/dist/schema/schema-v1.generated.js +7089 -0
  626. package/dist/schema/schema-v1.generated.js.map +1 -0
  627. package/dist/schema/screens.d.ts +4 -0
  628. package/dist/schema/screens.d.ts.map +1 -0
  629. package/dist/schema/screens.js +28 -0
  630. package/dist/schema/screens.js.map +1 -0
  631. package/dist/schema/test-values.d.ts +12 -0
  632. package/dist/schema/test-values.d.ts.map +1 -0
  633. package/dist/schema/test-values.js +97 -0
  634. package/dist/schema/test-values.js.map +1 -0
  635. package/dist/schema/unions.d.ts +46 -0
  636. package/dist/schema/unions.d.ts.map +1 -0
  637. package/dist/schema/unions.js +131 -0
  638. package/dist/schema/unions.js.map +1 -0
  639. package/dist/schema/validate-yaml.d.ts +14 -0
  640. package/dist/schema/validate-yaml.d.ts.map +1 -0
  641. package/dist/schema/validate-yaml.js +17 -0
  642. package/dist/schema/validate-yaml.js.map +1 -0
  643. package/dist/schema/validate.d.ts +46 -0
  644. package/dist/schema/validate.d.ts.map +1 -0
  645. package/dist/schema/validate.js +186 -0
  646. package/dist/schema/validate.js.map +1 -0
  647. package/dist/testing.d.ts +21 -0
  648. package/dist/testing.d.ts.map +1 -0
  649. package/dist/testing.js +28 -0
  650. package/dist/testing.js.map +1 -0
  651. package/dist/vocabulary.d.ts +6 -0
  652. package/dist/vocabulary.d.ts.map +1 -0
  653. package/dist/vocabulary.js +26 -0
  654. package/dist/vocabulary.js.map +1 -0
  655. package/package.json +66 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spell.js","sourceRoot":"","sources":["../../../src/expr/print/spell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAcnG,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AA0DnD,MAAM,gBAAgB,GAAG;IACvB,GAAG,EAAE,aAAa;IAClB,EAAE,EAAE,aAAa;IACjB,QAAQ,EAAE,UAAU;CAC4C,CAAC;AAEnE,MAAM,eAAe,GAAG;IACtB,GAAG,EAAE,KAAK;IACV,EAAE,EAAE,IAAI;IACR,QAAQ,EAAE,IAAI;CAC8C,CAAC;AAgB/D,MAAM,UAAU,GAAG;IACjB,QAAQ,EAAE,CAAC;IACX,WAAW,EAAE,CAAC;IACd,WAAW,EAAE,CAAC;IACd,UAAU,EAAE,CAAC;IACb,QAAQ,EAAE,CAAC;IACX,cAAc,EAAE,CAAC;IACjB,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;CACmC,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,IAAc;IACxC,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC9C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,QAAQ,IAAI,OAAO,CAAC,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;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,yBAAyB,CAAC;AAC5E,CAAC","sourcesContent":["import { DECIMAL_TEXT_PATTERN, assertNever, isRecord, toMoneyValue } from '@azx-pbc/axiom-runtime';\nimport type {\n ArithmeticOperator,\n CallNode,\n CompareNode,\n ComprehensionNode,\n ExprNode,\n IfNode,\n ListNode,\n LiteralNode,\n NotNode,\n PathNode,\n WireValue,\n} from '@azx-pbc/axiom-runtime';\nimport { EXPR_RESERVED_WORDS } from '../lexer.js';\nimport { isAggregateBuiltin } from '../parse/aggregates.js';\nimport { MAX_AST_NODES } from '../parse/budget.js';\n\n/**\n * The one AST-to-source authority of Expr v1.\n *\n * The printer is the parser's inverse, not a formatter: it emits the canonical spelling of the\n * tree so that re-reading the text yields *the same AST*, never merely an equivalent one.\n * Operand order and nesting are preserved (`and(and(a, b), c)` keeps its inner connective),\n * every form below the operand's precedence is parenthesised, and a one-argument `-` call stays\n * `-(1)` instead of folding into the negative literal `-1`.\n *\n * The printer does not enumerate what it can write. It spells the tree, re-parses its own output\n * and compares the two structurally, so representability is derived from the parser: a node with\n * no source form — a comprehension outside an aggregate's argument list, a `media_ref` literal, a\n * path segment that is a reserved word, a tree the writer can spell but the parser reads\n * differently — comes back as a tagged refusal with a code and a detail, and never as lossy source.\n *\n * The walk recurses, so it is entered only after two iterative passes: a shape pass that refuses\n * a malformed hand-built node — a hole, a missing operand list, an unknown kind — before any walk\n * dereferences a member, and the expression budget that keeps the recursion inside the host stack.\n * A tree no parser produced is therefore a tagged refusal at either pass, never a `TypeError` or a\n * stack overflow. The emitted *text* has its own budget, so the printer also measures what it\n * wrote. A decimal is two tokens in its canonical typed form (`decimal \"1.5\"`) and one in the\n * untyped form the lexer also reads (`1.5`), so a text past the source budget is retried with the\n * shorter spelling where it reads back as the same value; a text still past the budget is refused\n * as `printed_budget_exceeded`, never reported as a parser failure.\n */\n\n/** Why an AST has no source the parser reads back as the same tree. */\nexport type PrintRefusal =\n | 'root_comprehension'\n | 'singleton_connective'\n | 'unsupported_literal_domain'\n | 'reserved_path_segment'\n | 'printed_budget_exceeded'\n | 'self_check_failed';\n\n/** The canonical source of an AST, or the refusal that stopped the printer. */\nexport type PrintResult =\n | { readonly ok: true; readonly source: string }\n | { readonly ok: false; readonly reason: PrintRefusal; readonly detail: string };\n\nexport type Failure = Extract<PrintResult, { readonly ok: false }>;\n\n/** The source one node spells. Verification happens once, in `printExpr`. */\nexport type Spelling =\n | {\n readonly source: string;\n }\n | Failure;\n\n/**\n * How a decimal literal is spelled. The typed form is canonical; the untyped form is the\n * one-token spelling the lexer also accepts for the same value, and is used only on the retry\n * that an over-budget canonical text forces.\n */\nexport type DecimalSpelling = 'typed' | 'untyped';\n\nconst CONNECTIVE_LEVEL = {\n and: 'conjunction',\n or: 'disjunction',\n coalesce: 'coalesce',\n} as const satisfies Record<'and' | 'or' | 'coalesce', Precedence>;\n\nconst CONNECTIVE_TEXT = {\n and: 'and',\n or: 'or',\n coalesce: '??',\n} as const satisfies Record<'and' | 'or' | 'coalesce', string>;\n\n/**\n * The ladder of `[EXPR-4.1.1]`, lowest first, as the numbers an operand check compares. It is\n * the parser's descent read backwards: the root production is the lowest rung.\n */\ntype Precedence =\n | 'coalesce'\n | 'disjunction'\n | 'conjunction'\n | 'comparison'\n | 'additive'\n | 'multiplicative'\n | 'unary'\n | 'primary';\n\nconst PRECEDENCE = {\n coalesce: 1,\n disjunction: 2,\n conjunction: 3,\n comparison: 4,\n additive: 5,\n multiplicative: 6,\n unary: 7,\n primary: 8,\n} as const satisfies Record<Precedence, number>;\n\n/**\n * The source one parsed node spells, without the self-check `printExpr` runs.\n *\n * A refusal is building a sentence about the tree it already parsed, so the tree is known to have\n * a source form: this is the spelling walk alone, and `undefined` means only that the node has no\n * canonical source (a comprehension outside an aggregate, a reserved path segment). A caller that\n * has no source to offer must then keep its plain refusal rather than invent a wrong repair.\n */\nexport function spellSource(node: ExprNode): string | undefined {\n const malformed = shapeRefusal(node);\n if (malformed !== undefined) return undefined;\n const spelled = spell(node, 'typed');\n return 'source' in spelled ? spelled.source : undefined;\n}\n\n/** One string literal in the language's own canonical spelling, for a repair sentence. */\nexport function spellStringLiteral(text: string): string {\n return spellString(text);\n}\n\n/** Every node kind the closed AST declares; a new kind fails typecheck until it is listed. */\nconst EXPRESSION_KIND_TABLE = {\n literal: true,\n path: true,\n list: true,\n and: true,\n or: true,\n not: true,\n compare: true,\n if: true,\n coalesce: true,\n call: true,\n comprehension: true,\n} as const satisfies Record<ExprNode['kind'], true>;\n\nconst EXPRESSION_KINDS: ReadonlySet<string> = new Set(Object.keys(EXPRESSION_KIND_TABLE));\n\n/** Every literal domain `spellLiteral` has an arm for; a new domain fails typecheck until listed. */\nconst LITERAL_DOMAIN_TABLE = {\n string: true,\n boolean: true,\n integer: true,\n decimal: true,\n money: true,\n date: true,\n instant: true,\n time: true,\n media_ref: true,\n signature_ref: true,\n timeslot: true,\n quantity: true,\n duration: true,\n address: true,\n coordinate: true,\n record: true,\n array: true,\n null: true,\n} as const satisfies Record<LiteralNode['domain'], true>;\n\nconst LITERAL_DOMAINS: ReadonlySet<string> = new Set(Object.keys(LITERAL_DOMAIN_TABLE));\n\n/** Whether `value` is an object whose `kind` is one of the closed AST's node kinds. */\nfunction hasExpressionKind(value: unknown): boolean {\n return (\n isRecord(value) && typeof value['kind'] === 'string' && EXPRESSION_KINDS.has(value['kind'])\n );\n}\n\n/**\n * The iterative state of the shape walk: the nodes still to inspect and how many have been\n * inspected. The count lives here so the walk enforces the same node bound the budget walk does,\n * which is also what stops a cyclic hand-built tree from spinning.\n */\ninterface ShapeState {\n readonly pending: unknown[];\n inspected: number;\n}\n\n/**\n * The refusal for the first node whose shallow shape cannot be spelled, or `undefined` when every\n * node in the tree can. The walk is iterative and validates only what the spelling walk will\n * dereference: an object, a known node kind, a literal's known domain, a path's text, a call's\n * operator, a comprehension's binder and source, and — for every operand list — a dense array of\n * expression nodes. A hole or a missing member is refused here, before `checkExpressionBudget`\n * reads `undefined.kind` or `join` reads a hole.\n *\n * It runs before the budget walk because that walk also dereferences every child, and before the\n * spelling walk because that walk recurses; a shape refusal is therefore a tagged outcome rather\n * than a `TypeError` escaping a function documented never to raise.\n */\nexport function shapeRefusal(root: unknown): Failure | undefined {\n const state: ShapeState = { pending: [root], inspected: 0 };\n while (state.pending.length > 0) {\n state.inspected += 1;\n if (state.inspected > MAX_AST_NODES) return nodeBudgetRefusal();\n const refusal = inspectNode(state.pending.pop(), state);\n if (refusal !== undefined) return refusal;\n }\n return undefined;\n}\n\nfunction nodeBudgetRefusal(): Failure {\n return unreproducible(`the expression exceeds the ${String(MAX_AST_NODES)}-node AST budget`);\n}\n\nfunction inspectNode(node: unknown, state: ShapeState): Failure | undefined {\n if (!isRecord(node)) return unreproducible('an expression node must be an object');\n const kind = node['kind'];\n if (typeof kind !== 'string') {\n return unreproducible('an expression node must declare a string kind');\n }\n switch (kind) {\n case 'literal': {\n const domain = node['domain'];\n return typeof domain === 'string' && LITERAL_DOMAINS.has(domain)\n ? undefined\n : unreproducible(`\\`${String(domain)}\\` is not a literal domain`);\n }\n case 'path':\n return typeof node['path'] === 'string'\n ? undefined\n : unreproducible('a path node must declare its text');\n case 'list':\n return collectChildren(node['items'], 'items', 'a list', state);\n case 'and':\n case 'or':\n case 'coalesce':\n // The count stays `spellConnective`'s answer, so a one-operand fold keeps its own refusal.\n return collectChildren(node['args'], 'args', `\\`${kind}\\``, state);\n case 'compare':\n if (typeof node['op'] !== 'string') {\n return unreproducible('a comparison node must declare a string operator');\n }\n return collectFixed(node, 'compare', 2, state);\n case 'not':\n return collectFixed(node, 'not', 1, state);\n case 'if':\n return collectFixed(node, 'if', 3, state);\n case 'call':\n if (typeof node['op'] !== 'string') {\n return unreproducible('a call node must declare a string operator');\n }\n return collectChildren(node['args'], 'args', `\\`${node['op']}\\``, state);\n case 'comprehension':\n return collectComprehension(node, state);\n default:\n return unreproducible(`\\`${kind}\\` is not an expression node kind`);\n }\n}\n\nfunction collectChildren(\n value: unknown,\n member: string,\n owner: string,\n state: ShapeState,\n): Failure | undefined {\n if (!Array.isArray(value)) {\n return unreproducible(`${owner} must declare an \\`${member}\\` array`);\n }\n const entries: readonly unknown[] = value;\n return collectEntries(entries, member, owner, state);\n}\n\nfunction collectFixed(\n node: Record<string, unknown>,\n kind: 'compare' | 'not' | 'if',\n expected: number,\n state: ShapeState,\n): Failure | undefined {\n const value = node['args'];\n if (!Array.isArray(value)) {\n return unreproducible(`\\`${kind}\\` must declare an \\`args\\` array`);\n }\n if (value.length !== expected) return malformedArity(kind, value.length, expected);\n const entries: readonly unknown[] = value;\n return collectEntries(entries, 'args', `\\`${kind}\\``, state);\n}\n\nfunction collectEntries(\n entries: readonly unknown[],\n member: string,\n owner: string,\n state: ShapeState,\n): Failure | undefined {\n // Inspected plus queued plus this batch may not exceed the node budget. Checking before pushing\n // keeps a hostile fan-out from growing the queue, and the same count decides the same bound the\n // budget walk would report.\n if (state.inspected + state.pending.length + entries.length > MAX_AST_NODES) {\n return nodeBudgetRefusal();\n }\n // A sparse array's holes are skipped by `map` and `every`; counting up and testing each index\n // refuses a hole and a present `undefined` before either walk can read them.\n for (let index = 0; index < entries.length; index += 1) {\n const child = entries[index];\n if (!hasExpressionKind(child)) {\n return unreproducible(`${owner} \\`${member}\\`[${String(index)}] is not an expression node`);\n }\n state.pending.push(child);\n }\n return undefined;\n}\n\nfunction collectComprehension(\n node: Record<string, unknown>,\n state: ShapeState,\n): Failure | undefined {\n const binder = node['binder'];\n if (!isRecord(binder) || typeof binder['name'] !== 'string') {\n return unreproducible('a comprehension must declare a binder with a string name');\n }\n const source = node['source'];\n if (!hasExpressionKind(source)) {\n return unreproducible('a comprehension must declare a source expression');\n }\n const value = node['valueExpr'];\n if (value !== undefined && !hasExpressionKind(value)) {\n return unreproducible('a comprehension `valueExpr` must be an expression node');\n }\n const predicate = node['predicate'];\n if (predicate !== undefined && !hasExpressionKind(predicate)) {\n return unreproducible('a comprehension `predicate` must be an expression node');\n }\n const children: unknown[] = [source];\n if (value !== undefined) children.push(value);\n if (predicate !== undefined) children.push(predicate);\n if (state.inspected + state.pending.length + children.length > MAX_AST_NODES) {\n return nodeBudgetRefusal();\n }\n state.pending.push(...children);\n return undefined;\n}\n\n/** Spells one node, or reports why the walk cannot continue. */\nexport function spell(node: ExprNode, decimals: DecimalSpelling): Spelling {\n switch (node.kind) {\n case 'literal':\n return spellLiteral(node, decimals);\n case 'path':\n return spellPath(node);\n case 'list':\n return spellList(node, decimals);\n case 'not':\n return spellNot(node, decimals);\n case 'and':\n case 'or':\n case 'coalesce':\n return spellConnective(node.kind, node.args, decimals);\n case 'compare':\n return spellCompare(node, decimals);\n case 'if':\n return spellIf(node, decimals);\n case 'call':\n return spellCall(node, decimals);\n case 'comprehension':\n // `[EXPR-3.1.2]` places a comprehension only in an aggregate's argument list, which\n // `spellCall` handles; every other position has no production to spell it with.\n return refusal(\n 'root_comprehension',\n 'a comprehension is only an argument of an aggregate built-in, so it has no source form here',\n );\n default:\n return assertNever(node);\n }\n}\n\nfunction precedenceOf(node: ExprNode): Precedence {\n switch (node.kind) {\n case 'coalesce':\n return 'coalesce';\n case 'or':\n return 'disjunction';\n case 'and':\n return 'conjunction';\n case 'compare':\n return 'comparison';\n case 'not':\n return 'unary';\n case 'call':\n switch (node.op) {\n case '+':\n case '-':\n return node.op === '-' && node.args.length === 1 ? 'unary' : 'additive';\n case '*':\n case '/':\n case '%':\n case '//':\n return 'multiplicative';\n default:\n return 'primary';\n }\n case 'literal':\n case 'path':\n case 'list':\n case 'if':\n case 'comprehension':\n return 'primary';\n default:\n return assertNever(node);\n }\n}\n\n/**\n * Spells an operand of a form at `level`. `tieNeedsParens` states the form's associativity: a\n * left-associative chain and a non-associative comparison both re-read an equal-precedence child\n * as part of themselves, so only a strictly higher child may be written bare.\n */\nfunction spellOperand(\n node: ExprNode,\n level: Precedence,\n tieNeedsParens: boolean,\n decimals: DecimalSpelling,\n): Spelling {\n const inner = spell(node, decimals);\n if (!('source' in inner)) return inner;\n const own = PRECEDENCE[precedenceOf(node)];\n const outer = PRECEDENCE[level];\n if (own > outer || (own === outer && !tieNeedsParens)) return inner;\n return spelled(`(${inner.source})`);\n}\n\n/** Spells every part and joins the sources with `separator`, or reports the first failure. */\nfunction join(parts: readonly Spelling[], separator: string): Spelling {\n const sources: string[] = [];\n for (const part of parts) {\n if (!('source' in part)) return part;\n sources.push(part.source);\n }\n return spelled(sources.join(separator));\n}\n\nfunction spellChain(\n args: readonly ExprNode[],\n level: Precedence,\n separator: string,\n decimals: DecimalSpelling,\n): Spelling {\n return join(\n args.map((arg) => spellOperand(arg, level, true, decimals)),\n separator,\n );\n}\n\nfunction spellConnective(\n kind: 'and' | 'or' | 'coalesce',\n args: readonly ExprNode[],\n decimals: DecimalSpelling,\n): Spelling {\n if (args.length < 2) {\n return refusal(\n 'singleton_connective',\n `\\`${kind}\\` folds ${String(args.length)} operand(s), and the grammar has no form below two`,\n );\n }\n return spellChain(args, CONNECTIVE_LEVEL[kind], ` ${CONNECTIVE_TEXT[kind]} `, decimals);\n}\n\nfunction spellCompare(node: CompareNode, decimals: DecimalSpelling): Spelling {\n const [left, right] = node.args;\n return join(\n [\n spellOperand(left, 'comparison', true, decimals),\n spellOperand(right, 'comparison', true, decimals),\n ],\n ` ${node.op} `,\n );\n}\n\nfunction spellNot(node: NotNode, decimals: DecimalSpelling): Spelling {\n const [operand] = node.args;\n const inner = spellOperand(operand, 'unary', false, decimals);\n if (!('source' in inner)) return inner;\n return spelled(`not ${inner.source}`);\n}\n\nfunction spellIf(node: IfNode, decimals: DecimalSpelling): Spelling {\n // `if`'s operands are whole expressions up to the comma, so none of them needs parentheses.\n const [condition, thenExpr, elseExpr] = node.args;\n const operands = join(\n [spell(condition, decimals), spell(thenExpr, decimals), spell(elseExpr, decimals)],\n ', ',\n );\n if (!('source' in operands)) return operands;\n return spelled(`if(${operands.source})`);\n}\n\nfunction spellList(node: ListNode, decimals: DecimalSpelling): Spelling {\n const items = join(\n node.items.map((item) => spell(item, decimals)),\n ', ',\n );\n if (!('source' in items)) return items;\n return spelled(`[${items.source}]`);\n}\n\nfunction spellCall(node: CallNode, decimals: DecimalSpelling): Spelling {\n const { op, args } = node;\n if (op === '+' || op === '-' || op === '*' || op === '/' || op === '%' || op === '//') {\n return spellArithmetic(op, args, decimals);\n }\n if (op === 'member') return spellMember(args, decimals);\n const operands = join(\n args.map((arg) =>\n arg.kind === 'comprehension' && isAggregateBuiltin(op)\n ? spellComprehension(arg, decimals)\n : spell(arg, decimals),\n ),\n ', ',\n );\n if (!('source' in operands)) return operands;\n return spelled(`${op}(${operands.source})`);\n}\n\n/**\n * `member(base, \"name\")` back to `base.name`, the form an author wrote.\n *\n * The sugar is printed only where it re-reads as the same call: a call or conditional base\n * is a primary, and the name is an identifier. A path or any other base keeps the call form,\n * because `f_x.name` would parse as one path rather than a member read.\n */\nfunction spellMember(args: readonly ExprNode[], decimals: DecimalSpelling): Spelling {\n const [base, name] = args;\n if (\n base === undefined ||\n name === undefined ||\n name.kind !== 'literal' ||\n typeof name.value !== 'string' ||\n !/^[A-Za-z_][A-Za-z0-9_]*$/.test(name.value) ||\n !(\n base.kind === 'if' ||\n (base.kind === 'call' &&\n base.op !== '+' &&\n base.op !== '-' &&\n base.op !== '*' &&\n base.op !== '/' &&\n base.op !== '%' &&\n base.op !== '//')\n )\n ) {\n return spellCallArguments('member', args, decimals);\n }\n const inner = spell(base, decimals);\n return 'source' in inner ? spelled(`${inner.source}.${name.value}`) : inner;\n}\n\nfunction spellCallArguments(\n op: string,\n args: readonly ExprNode[],\n decimals: DecimalSpelling,\n): Spelling {\n const operands = join(\n args.map((arg) =>\n arg.kind === 'comprehension' && isAggregateBuiltin(op)\n ? spellComprehension(arg, decimals)\n : spell(arg, decimals),\n ),\n ', ',\n );\n return 'source' in operands ? spelled(`${op}(${operands.source})`) : operands;\n}\n\nfunction spellArithmetic(\n op: ArithmeticOperator,\n args: readonly ExprNode[],\n decimals: DecimalSpelling,\n): Spelling {\n const [left, right] = args;\n if (left === undefined) return unreproducible(`\\`${op}\\` carries no operand`);\n if (op === '-' && args.length === 1) return spellNegation(left, decimals);\n if ((op === '/' || op === '%' || op === '//') && right !== undefined && args.length === 2) {\n // Division is binary and left-associative: a tie on the left is the chain itself\n // (`a / b / c` *is* `(a / b) / c`), while a tie on the right needs its parentheses.\n return join(\n [\n spellOperand(left, 'multiplicative', false, decimals),\n spellOperand(right, 'multiplicative', true, decimals),\n ],\n ` ${op} `,\n );\n }\n if (op === '-' && right !== undefined && args.length === 2) {\n // Subtraction is binary and left-associative, so a tie on the left is the chain itself\n // (`a - b - c` *is* `(a - b) - c`) while a tie on the right needs its parentheses.\n return join(\n [\n spellOperand(left, 'additive', false, decimals),\n spellOperand(right, 'additive', true, decimals),\n ],\n ' - ',\n );\n }\n return spellChain(args, op === '*' ? 'multiplicative' : 'additive', ` ${op} `, decimals);\n}\n\nfunction spellNegation(operand: ExprNode, decimals: DecimalSpelling): Spelling {\n const inner = spellOperand(operand, 'unary', false, decimals);\n if (!('source' in inner)) return inner;\n // `-1` and `-1.5` fold into a negative literal, so a numeric literal operand keeps its\n // parentheses and the call stays a call of arity one.\n const folds =\n operand.kind === 'literal' && (operand.domain === 'integer' || operand.domain === 'decimal');\n return spelled(folds ? `-(${inner.source})` : `-${inner.source}`);\n}\n\nfunction spellComprehension(node: ComprehensionNode, decimals: DecimalSpelling): Spelling {\n const source = spell(node.source, decimals);\n if (!('source' in source)) return source;\n const value = node.valueExpr === undefined ? undefined : spell(node.valueExpr, decimals);\n if (value !== undefined && !('source' in value)) return value;\n const predicate = node.predicate === undefined ? undefined : spell(node.predicate, decimals);\n if (predicate !== undefined && !('source' in predicate)) return predicate;\n\n const valueSource = sourceOf(value);\n const predicateSource = sourceOf(predicate);\n const body = valueSource ?? predicateSource;\n if (body === undefined) {\n return unreproducible(\n `binder \\`${node.binder.name}\\` declares neither a value nor a predicate, so it has no body`,\n );\n }\n // A value projection's filter follows its body; a predicate aggregate has one body that is\n // already the predicate, so only a `valueExpr` carries the `if` clause.\n const filter =\n valueSource === undefined || predicateSource === undefined ? '' : ` if ${predicateSource}`;\n return spelled(`${node.binder.name} in ${source.source}: ${body}${filter}`);\n}\n\nfunction spellPath(node: PathNode): Spelling {\n const body = node.path.startsWith('$') ? node.path.slice(1) : node.path;\n const reserved = body.split('.').find((segment) => EXPR_RESERVED_WORDS.has(segment));\n if (reserved !== undefined) {\n return refusal(\n 'reserved_path_segment',\n `\\`${reserved}\\` is a reserved word, so \\`${node.path}\\` has no source spelling`,\n );\n }\n return spelled(node.path);\n}\n\nfunction spellLiteral(node: LiteralNode, decimals: DecimalSpelling): Spelling {\n const { domain, value } = node;\n switch (domain) {\n case 'integer':\n return typeof value === 'number' && Number.isSafeInteger(value)\n ? spelled(String(value))\n : unreproducible('an integer literal must hold a canonical integer');\n case 'decimal':\n return typeof value === 'string'\n ? spellDecimal(value, decimals)\n : unreproducible('a decimal literal must hold its canonical text');\n case 'string':\n return typeof value === 'string'\n ? spelled(spellString(value))\n : unreproducible('a string literal must hold text');\n case 'boolean':\n return typeof value === 'boolean'\n ? spelled(value ? 'true' : 'false')\n : unreproducible('a boolean literal must hold a boolean');\n case 'null':\n return value === null ? spelled('null') : unreproducible('a null literal must hold null');\n case 'date':\n return typeof value === 'string'\n ? spelled(`date ${spellString(value)}`)\n : unreproducible('a date literal must hold its canonical text');\n case 'instant':\n return typeof value === 'string'\n ? spelled(`instant ${spellString(value)}`)\n : unreproducible('an instant literal must hold its canonical text');\n case 'money':\n return spellMoney(value);\n case 'media_ref':\n case 'signature_ref':\n case 'timeslot':\n case 'quantity':\n case 'time':\n case 'duration':\n case 'address':\n case 'coordinate':\n case 'record':\n case 'array':\n return refusal('unsupported_literal_domain', `\\`${domain}\\` has no Expr v1 literal syntax`);\n default:\n return assertNever(domain);\n }\n}\n\n/**\n * A canonical decimal the lexer reads back as the same value *without* the `decimal` keyword and\n * with fewer tokens: a positive value with a fractional part. The runtime's pattern rules out a\n * leading zero, an exponent and a trailing fractional zero; a whole value (`0`, `1`) is excluded\n * because the untyped token is then an integer, a different value, and a negative value (`-1.5`)\n * costs the same two tokens with or without its suffix, so it keeps the canonical typed spelling.\n * A decimal that cannot take the shorter form is refused when the typed text does not fit the\n * source budget.\n */\nfunction isUntypedDecimal(value: string): boolean {\n return !value.startsWith('-') && DECIMAL_TEXT_PATTERN.test(value) && value.includes('.');\n}\n\nfunction spellDecimal(value: string, decimals: DecimalSpelling): Spelling {\n if (decimals === 'untyped' && isUntypedDecimal(value)) return spelled(value);\n return spelled(`decimal ${spellString(value)}`);\n}\n\n/** A node whose operand count has no production, which no spelling can repair. */\nfunction malformedArity(kind: 'if' | 'compare' | 'not', arity: number, expected: number): Failure {\n return unreproducible(\n `\\`${kind}\\` carries ${String(arity)} operand(s) where the grammar has ${String(expected)}`,\n );\n}\n\nfunction spellMoney(value: WireValue): Spelling {\n if (!isRecord(value)) return unreproducible('a money literal must hold a money record');\n try {\n const money = toMoneyValue(value);\n return spelled(\n `money { \"minor\": ${spellString(money.minor)}, \"currency\": ${spellString(money.currency)}, \"scale\": ${String(money.scale)} }`,\n );\n } catch (error) {\n return unreproducible(`a money literal must hold a money record: ${messageOf(error)}`);\n }\n}\n\n/**\n * A string literal in the language's own spelling: the quote and the backslash, the three named\n * whitespace escapes, and a `\\u{...}` escape for every control code and lone surrogate so the text\n * stays readable. A surrogate that is not a Unicode scalar value survives the escape only as a\n * parser refusal, which the self-check reports rather than emitting text nobody can read back.\n */\n/**\n * One string value as a double-quoted literal.\n *\n * `'…'` is an accepted alternate spelling, but the printer emits one deterministic form:\n * a canonical report compares bytes, and preserving the author's quote style would make two\n * equal expressions print differently. A `'` needs no escape inside double quotes, so the\n * canonical form is the shorter one for the case that matters.\n */\nfunction spellString(text: string): string {\n let body = '';\n for (const character of text) body += spellCharacter(character);\n return `\"${body}\"`;\n}\n\nfunction spellCharacter(character: string): string {\n switch (character) {\n case '\"':\n return '\\\\\"';\n case '\\\\':\n return '\\\\\\\\';\n case '\\n':\n return '\\\\n';\n case '\\r':\n return '\\\\r';\n case '\\t':\n return '\\\\t';\n default: {\n const code = character.codePointAt(0);\n if (code === undefined) return character;\n const loneSurrogate = character.length === 1 && code >= 0xd800 && code <= 0xdfff;\n if (code < 0x20 || code === 0x7f || loneSurrogate) return `\\\\u{${code.toString(16)}}`;\n return character;\n }\n }\n}\n\nfunction sourceOf(spelling: Spelling | undefined): string | undefined {\n return spelling !== undefined && 'source' in spelling ? spelling.source : undefined;\n}\n\nfunction spelled(source: string): Spelling {\n return { source };\n}\n\nexport function refusal(reason: PrintRefusal, detail: string): Failure {\n return { ok: false, reason, detail };\n}\n\n/** A node the walk can spell text for, but no text the parser reads back as this tree. */\nfunction unreproducible(detail: string): Failure {\n return refusal('self_check_failed', detail);\n}\n\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : 'an unrecognised failure';\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import type { ExprNode } from '@azx-pbc/axiom-runtime';
2
+ import type { PrintResult } from './print/spell.js';
3
+ export type { PrintRefusal, PrintResult } from './print/spell.js';
4
+ /**
5
+ * Prints the closed AST as canonical Expr v1 source.
6
+ *
7
+ * The result is verified before it is returned: the function measures the text it wrote against
8
+ * the source budget, re-parses it and compares the tree structurally, so `ok` means the source is
9
+ * a faithful spelling and never a near miss. A canonical spelling that would overrun the budget is
10
+ * retried with the shortest spelling of each literal that reads back as the same value; a text
11
+ * that still does not fit is refused as `printed_budget_exceeded`. Pure, total and browser-safe:
12
+ * no clock, no locale, no `Intl`, no Node built-in, and an AST that has no source form returns
13
+ * `{ ok: false, reason, detail }` rather than raising.
14
+ *
15
+ * The spelling walk itself is `print/spell`, which the parser and the checker read to name a
16
+ * repair without importing this verification: a diagnostic about a tree the parser built needs the
17
+ * source form, not a second proof that the form re-reads as the same tree.
18
+ */
19
+ export declare function printExpr(node: ExprNode): PrintResult;
20
+ //# sourceMappingURL=print.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print.d.ts","sourceRoot":"","sources":["../../src/expr/print.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAMvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAElE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,WAAW,CAkCrD"}
@@ -0,0 +1,102 @@
1
+ import { canonicalizeRestricted } from '@azx-pbc/axiom-runtime';
2
+ import { ExpressionCompileError } from './diagnostics.js';
3
+ import { MAX_SOURCE_TOKENS, tokenize } from './lexer.js';
4
+ import { checkExpressionBudget, parseTokenizedExpr } from './parser.js';
5
+ import { refusal, shapeRefusal, spell } from './print/spell.js';
6
+ /**
7
+ * Prints the closed AST as canonical Expr v1 source.
8
+ *
9
+ * The result is verified before it is returned: the function measures the text it wrote against
10
+ * the source budget, re-parses it and compares the tree structurally, so `ok` means the source is
11
+ * a faithful spelling and never a near miss. A canonical spelling that would overrun the budget is
12
+ * retried with the shortest spelling of each literal that reads back as the same value; a text
13
+ * that still does not fit is refused as `printed_budget_exceeded`. Pure, total and browser-safe:
14
+ * no clock, no locale, no `Intl`, no Node built-in, and an AST that has no source form returns
15
+ * `{ ok: false, reason, detail }` rather than raising.
16
+ *
17
+ * The spelling walk itself is `print/spell`, which the parser and the checker read to name a
18
+ * repair without importing this verification: a diagnostic about a tree the parser built needs the
19
+ * source form, not a second proof that the form re-reads as the same tree.
20
+ */
21
+ export function printExpr(node) {
22
+ // `printExpr` is an exported door, and a document or a builder can hand it a tree the AST types
23
+ // call impossible. Validate every node's shallow shape before either walk dereferences a member:
24
+ // the budget walk would otherwise read `undefined.kind`, and the spelling walk recurses.
25
+ const malformed = shapeRefusal(node);
26
+ if (malformed !== undefined)
27
+ return malformed;
28
+ try {
29
+ // `[EXPR-3.1.4]`, measured before the spelling walk because that walk recurses: a tree deeper
30
+ // than the budget overflows the host stack instead of being refused, which is the failure the
31
+ // budget's own iterative walk exists to prevent. The parser measures the same budget, so a tree
32
+ // past it has no source and the self-check would have refused it anyway — this decides the
33
+ // order, never the answer.
34
+ checkExpressionBudget(node);
35
+ }
36
+ catch (error) {
37
+ // Only the budget's own refusal is a property of the tree; anything else is a defect and must
38
+ // not be reported as though the author's AST were at fault.
39
+ if (!(error instanceof ExpressionCompileError))
40
+ throw error;
41
+ return refusal('self_check_failed', `the tree is outside the expression budget: ${error.diagnostic.detail}`);
42
+ }
43
+ const canonical = spell(node, 'typed');
44
+ if (!('source' in canonical))
45
+ return canonical;
46
+ const printed = verify(node, canonical.source);
47
+ // The canonical typed spelling is what the grammar's literal section states, so it is kept
48
+ // wherever it fits. Only a text past the source budget is re-spelled: the untyped form of a
49
+ // decimal is one token instead of two, so a tree the parser accepted with `1.5` can be written
50
+ // back with `1.5` rather than refused for spelling the same value more expansively.
51
+ if (printed.ok || printed.reason !== 'printed_budget_exceeded')
52
+ return printed;
53
+ const compact = spell(node, 'untyped');
54
+ if (!('source' in compact))
55
+ return compact;
56
+ if (compact.source === canonical.source)
57
+ return printed;
58
+ return verify(node, compact.source);
59
+ }
60
+ function verify(node, source) {
61
+ let tokens;
62
+ try {
63
+ // Measure the text the printer wrote with the same lexer that will read it back: the token
64
+ // budget is a property of the printed source, not of the tree, and the canonical spelling of a
65
+ // literal can be longer than the one the author used. A token overrun is reported as its own
66
+ // refusal, before the parser can misattribute it to a parse failure.
67
+ tokens = tokenize(source);
68
+ }
69
+ catch (error) {
70
+ if (error instanceof ExpressionCompileError &&
71
+ error.diagnostic.code === 'COST_BUDGET_EXCEEDED') {
72
+ return refusal('printed_budget_exceeded', `the printed source is over the ${String(MAX_SOURCE_TOKENS)}-token source budget`);
73
+ }
74
+ return refusal('self_check_failed', `the printed source does not re-parse: ${messageOf(error)}`);
75
+ }
76
+ // The tokens measured above are the ones read back: the happy path lexes the printed text once.
77
+ const reparsed = parseTokenizedExpr(tokens);
78
+ if (!reparsed.ok) {
79
+ const [diagnostic] = reparsed.diagnostics;
80
+ return refusal('self_check_failed', `the printed source does not re-parse: ${diagnostic?.detail ?? 'no diagnostic'}`);
81
+ }
82
+ let expected;
83
+ let actual;
84
+ try {
85
+ // Canonical JSON is the equality the artifact already hashes under: members compare as a set,
86
+ // and a value outside the profile — negative zero, a float — is refused rather than written
87
+ // back as a different value.
88
+ expected = canonicalizeRestricted(node);
89
+ actual = canonicalizeRestricted(reparsed.node);
90
+ }
91
+ catch (error) {
92
+ return refusal('self_check_failed', `the tree is outside the canonical JSON profile: ${messageOf(error)}`);
93
+ }
94
+ if (expected !== actual) {
95
+ return refusal('self_check_failed', `the printed source re-parses to a different tree: ${source}`);
96
+ }
97
+ return { ok: true, source };
98
+ }
99
+ function messageOf(error) {
100
+ return error instanceof Error ? error.message : 'unknown failure';
101
+ }
102
+ //# sourceMappingURL=print.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print.js","sourceRoot":"","sources":["../../src/expr/print.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEzD,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAKhE;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,gGAAgG;IAChG,iGAAiG;IACjG,yFAAyF;IACzF,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC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EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC9B,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC;AACpE,CAAC","sourcesContent":["import { canonicalizeRestricted } from '@azx-pbc/axiom-runtime';\nimport type { ExprNode } from '@azx-pbc/axiom-runtime';\nimport { ExpressionCompileError } from './diagnostics.js';\nimport { MAX_SOURCE_TOKENS, tokenize } from './lexer.js';\nimport type { Token } from './lexer.js';\nimport { checkExpressionBudget, parseTokenizedExpr } from './parser.js';\nimport { refusal, shapeRefusal, spell } from './print/spell.js';\nimport type { PrintResult } from './print/spell.js';\n\nexport type { PrintRefusal, PrintResult } from './print/spell.js';\n\n/**\n * Prints the closed AST as canonical Expr v1 source.\n *\n * The result is verified before it is returned: the function measures the text it wrote against\n * the source budget, re-parses it and compares the tree structurally, so `ok` means the source is\n * a faithful spelling and never a near miss. A canonical spelling that would overrun the budget is\n * retried with the shortest spelling of each literal that reads back as the same value; a text\n * that still does not fit is refused as `printed_budget_exceeded`. Pure, total and browser-safe:\n * no clock, no locale, no `Intl`, no Node built-in, and an AST that has no source form returns\n * `{ ok: false, reason, detail }` rather than raising.\n *\n * The spelling walk itself is `print/spell`, which the parser and the checker read to name a\n * repair without importing this verification: a diagnostic about a tree the parser built needs the\n * source form, not a second proof that the form re-reads as the same tree.\n */\nexport function printExpr(node: ExprNode): PrintResult {\n // `printExpr` is an exported door, and a document or a builder can hand it a tree the AST types\n // call impossible. Validate every node's shallow shape before either walk dereferences a member:\n // the budget walk would otherwise read `undefined.kind`, and the spelling walk recurses.\n const malformed = shapeRefusal(node);\n if (malformed !== undefined) return malformed;\n try {\n // `[EXPR-3.1.4]`, measured before the spelling walk because that walk recurses: a tree deeper\n // than the budget overflows the host stack instead of being refused, which is the failure the\n // budget's own iterative walk exists to prevent. The parser measures the same budget, so a tree\n // past it has no source and the self-check would have refused it anyway — this decides the\n // order, never the answer.\n checkExpressionBudget(node);\n } catch (error) {\n // Only the budget's own refusal is a property of the tree; anything else is a defect and must\n // not be reported as though the author's AST were at fault.\n if (!(error instanceof ExpressionCompileError)) throw error;\n return refusal(\n 'self_check_failed',\n `the tree is outside the expression budget: ${error.diagnostic.detail}`,\n );\n }\n const canonical = spell(node, 'typed');\n if (!('source' in canonical)) return canonical;\n const printed = verify(node, canonical.source);\n // The canonical typed spelling is what the grammar's literal section states, so it is kept\n // wherever it fits. Only a text past the source budget is re-spelled: the untyped form of a\n // decimal is one token instead of two, so a tree the parser accepted with `1.5` can be written\n // back with `1.5` rather than refused for spelling the same value more expansively.\n if (printed.ok || printed.reason !== 'printed_budget_exceeded') return printed;\n const compact = spell(node, 'untyped');\n if (!('source' in compact)) return compact;\n if (compact.source === canonical.source) return printed;\n return verify(node, compact.source);\n}\n\nfunction verify(node: ExprNode, source: string): PrintResult {\n let tokens: readonly Token[];\n try {\n // Measure the text the printer wrote with the same lexer that will read it back: the token\n // budget is a property of the printed source, not of the tree, and the canonical spelling of a\n // literal can be longer than the one the author used. A token overrun is reported as its own\n // refusal, before the parser can misattribute it to a parse failure.\n tokens = tokenize(source);\n } catch (error) {\n if (\n error instanceof ExpressionCompileError &&\n error.diagnostic.code === 'COST_BUDGET_EXCEEDED'\n ) {\n return refusal(\n 'printed_budget_exceeded',\n `the printed source is over the ${String(MAX_SOURCE_TOKENS)}-token source budget`,\n );\n }\n return refusal(\n 'self_check_failed',\n `the printed source does not re-parse: ${messageOf(error)}`,\n );\n }\n // The tokens measured above are the ones read back: the happy path lexes the printed text once.\n const reparsed = parseTokenizedExpr(tokens);\n if (!reparsed.ok) {\n const [diagnostic] = reparsed.diagnostics;\n return refusal(\n 'self_check_failed',\n `the printed source does not re-parse: ${diagnostic?.detail ?? 'no diagnostic'}`,\n );\n }\n let expected: string;\n let actual: string;\n try {\n // Canonical JSON is the equality the artifact already hashes under: members compare as a set,\n // and a value outside the profile — negative zero, a float — is refused rather than written\n // back as a different value.\n expected = canonicalizeRestricted(node);\n actual = canonicalizeRestricted(reparsed.node);\n } catch (error) {\n return refusal(\n 'self_check_failed',\n `the tree is outside the canonical JSON profile: ${messageOf(error)}`,\n );\n }\n if (expected !== actual) {\n return refusal(\n 'self_check_failed',\n `the printed source re-parses to a different tree: ${source}`,\n );\n }\n return { ok: true, source };\n}\n\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : 'unknown failure';\n}\n"]}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Bounded edit-distance suggestions for a name the compiler could not resolve,
3
+ * The bound keeps a long unrelated list from turning a typo report into
4
+ * noise: a candidate is offered only when it is close relative to its own length, and at
5
+ * most three candidates are offered.
6
+ */
7
+ export declare function closestNames(name: string, candidates: readonly string[], limit?: number): readonly string[];
8
+ /** One candidate a reader reaches through a path, scored by the member name it ends in. */
9
+ export interface LeafCandidate {
10
+ /** The member name a bare read would have spelled, `fieldId` or a last path segment. */
11
+ readonly leaf: string;
12
+ /** The path that actually reaches it, `f_address.f_postcode` or `$it.f_qty`. */
13
+ readonly suggestion: string;
14
+ }
15
+ /** The Expr spelling a spreadsheet name means, or none when Expr has no equivalent. */
16
+ export declare function spreadsheetSuggestions(name: string): readonly string[];
17
+ /**
18
+ * Bounded suggestions for a bare name that names a member reached through a path.
19
+ *
20
+ * A nested member is never read by its leaf alone, so its edit distance from the bare name is
21
+ * the distance of the leaf, not of the whole path: `f_postcode` suggests
22
+ * `f_address.f_postcode` at distance zero, while comparing the two whole spellings would put
23
+ * them far apart and offer nothing.
24
+ */
25
+ export declare function closestByLeaf(name: string, candidates: readonly LeafCandidate[], limit?: number): readonly string[];
26
+ //# sourceMappingURL=suggest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../../src/expr/suggest.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,KAAK,SAAI,GACR,SAAS,MAAM,EAAE,CASnB;AAOD,2FAA2F;AAC3F,MAAM,WAAW,aAAa;IAC5B,wFAAwF;IACxF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,gFAAgF;IAChF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AA6BD,uFAAuF;AACvF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAGtE;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,SAAS,aAAa,EAAE,EACpC,KAAK,SAAI,GACR,SAAS,MAAM,EAAE,CAmBnB"}
@@ -0,0 +1,77 @@
1
+ import leven from 'leven';
2
+ /**
3
+ * Bounded edit-distance suggestions for a name the compiler could not resolve,
4
+ * The bound keeps a long unrelated list from turning a typo report into
5
+ * noise: a candidate is offered only when it is close relative to its own length, and at
6
+ * most three candidates are offered.
7
+ */
8
+ export function closestNames(name, candidates, limit = 3) {
9
+ const unique = [...new Set(candidates)].filter((candidate) => candidate !== name);
10
+ const scored = unique
11
+ .map((candidate) => ({ candidate, distance: leven(name, candidate) }))
12
+ .filter(({ candidate, distance }) => distance <= maxDistance(candidate))
13
+ .sort((a, b) => a.distance === b.distance ? (a.candidate < b.candidate ? -1 : 1) : a.distance - b.distance);
14
+ return scored.slice(0, limit).map((entry) => entry.candidate);
15
+ }
16
+ /** Two edits for a short name, three for a longer one, and never more than a third of it. */
17
+ function maxDistance(candidate) {
18
+ return Math.max(1, Math.min(3, Math.floor(candidate.length / 3) + 1));
19
+ }
20
+ /**
21
+ * The expression-language name a common spreadsheet spelling means.
22
+ *
23
+ * Spreadsheet names are upper-case and some of them (`IF`, `TRUE`) are Expr keywords, so the
24
+ * case-sensitive identifier lookup never reaches them and `SUM(x)` was refused with no
25
+ * suggestion at all. Only spellings whose meaning survives the translation are listed: a
26
+ * spreadsheet function with no Expr equivalent (`AVERAGE`, `COUNT`) gets no invented name,
27
+ * because a suggestion an author follows must compile.
28
+ */
29
+ const SPREADSHEET_SPELLINGS = new Map([
30
+ ['SUM', 'sum'],
31
+ ['IF', 'if'],
32
+ ['TRUE', 'true'],
33
+ ['FALSE', 'false'],
34
+ ['NULL', 'null'],
35
+ ['AND', 'and'],
36
+ ['OR', 'or'],
37
+ ['NOT', 'not'],
38
+ ['ROUND', 'round'],
39
+ ['MIN', 'min'],
40
+ ['MAX', 'max'],
41
+ ['LEN', 'len'],
42
+ ['LOWER', 'lower'],
43
+ ['UPPER', 'upper'],
44
+ ['TRIM', 'trim'],
45
+ ]);
46
+ /** The Expr spelling a spreadsheet name means, or none when Expr has no equivalent. */
47
+ export function spreadsheetSuggestions(name) {
48
+ const equivalent = SPREADSHEET_SPELLINGS.get(name);
49
+ return equivalent === undefined ? [] : [equivalent];
50
+ }
51
+ /**
52
+ * Bounded suggestions for a bare name that names a member reached through a path.
53
+ *
54
+ * A nested member is never read by its leaf alone, so its edit distance from the bare name is
55
+ * the distance of the leaf, not of the whole path: `f_postcode` suggests
56
+ * `f_address.f_postcode` at distance zero, while comparing the two whole spellings would put
57
+ * them far apart and offer nothing.
58
+ */
59
+ export function closestByLeaf(name, candidates, limit = 3) {
60
+ const unique = new Map();
61
+ for (const candidate of candidates) {
62
+ if (candidate.suggestion !== name && !unique.has(candidate.suggestion)) {
63
+ unique.set(candidate.suggestion, candidate);
64
+ }
65
+ }
66
+ return [...unique.values()]
67
+ .map((candidate) => ({ candidate, distance: leven(name, candidate.leaf) }))
68
+ .filter(({ candidate, distance }) => distance <= maxDistance(candidate.leaf))
69
+ .sort((left, right) => left.distance === right.distance
70
+ ? left.candidate.suggestion < right.candidate.suggestion
71
+ ? -1
72
+ : 1
73
+ : left.distance - right.distance)
74
+ .slice(0, limit)
75
+ .map(({ candidate }) => candidate.suggestion);
76
+ }
77
+ //# sourceMappingURL=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AAS,CAAC,UAAU,CAAC,EAAE,CAAC;YACvE,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;SACxB,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SAC1E,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,IAAI,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;SAC5E,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACpB,IAAI,CAAC,QAAQ,KAAK,KAAK,CAAC,QAAQ;QAC9B,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,UAAU;YACtD,CAAC,CAAC,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CACnC;SACA,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;SACf,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AAClD,CAAC","sourcesContent":["import leven from 'leven';\n\n/**\n * Bounded edit-distance suggestions for a name the compiler could not resolve,\n * The bound keeps a long unrelated list from turning a typo report into\n * noise: a candidate is offered only when it is close relative to its own length, and at\n * most three candidates are offered.\n */\nexport function closestNames(\n name: string,\n candidates: readonly string[],\n limit = 3,\n): readonly string[] {\n const unique = [...new Set(candidates)].filter((candidate) => candidate !== name);\n const scored = unique\n .map((candidate) => ({ candidate, distance: leven(name, candidate) }))\n .filter(({ candidate, distance }) => distance <= maxDistance(candidate))\n .sort((a, b) =>\n a.distance === b.distance ? (a.candidate < b.candidate ? -1 : 1) : a.distance - b.distance,\n );\n return scored.slice(0, limit).map((entry) => entry.candidate);\n}\n\n/** Two edits for a short name, three for a longer one, and never more than a third of it. */\nfunction maxDistance(candidate: string): number {\n return Math.max(1, Math.min(3, Math.floor(candidate.length / 3) + 1));\n}\n\n/** One candidate a reader reaches through a path, scored by the member name it ends in. */\nexport interface LeafCandidate {\n /** The member name a bare read would have spelled, `fieldId` or a last path segment. */\n readonly leaf: string;\n /** The path that actually reaches it, `f_address.f_postcode` or `$it.f_qty`. */\n readonly suggestion: string;\n}\n\n/**\n * The expression-language name a common spreadsheet spelling means.\n *\n * Spreadsheet names are upper-case and some of them (`IF`, `TRUE`) are Expr keywords, so the\n * case-sensitive identifier lookup never reaches them and `SUM(x)` was refused with no\n * suggestion at all. Only spellings whose meaning survives the translation are listed: a\n * spreadsheet function with no Expr equivalent (`AVERAGE`, `COUNT`) gets no invented name,\n * because a suggestion an author follows must compile.\n */\nconst SPREADSHEET_SPELLINGS: ReadonlyMap<string, string> = new Map([\n ['SUM', 'sum'],\n ['IF', 'if'],\n ['TRUE', 'true'],\n ['FALSE', 'false'],\n ['NULL', 'null'],\n ['AND', 'and'],\n ['OR', 'or'],\n ['NOT', 'not'],\n ['ROUND', 'round'],\n ['MIN', 'min'],\n ['MAX', 'max'],\n ['LEN', 'len'],\n ['LOWER', 'lower'],\n ['UPPER', 'upper'],\n ['TRIM', 'trim'],\n]);\n\n/** The Expr spelling a spreadsheet name means, or none when Expr has no equivalent. */\nexport function spreadsheetSuggestions(name: string): readonly string[] {\n const equivalent = SPREADSHEET_SPELLINGS.get(name);\n return equivalent === undefined ? [] : [equivalent];\n}\n\n/**\n * Bounded suggestions for a bare name that names a member reached through a path.\n *\n * A nested member is never read by its leaf alone, so its edit distance from the bare name is\n * the distance of the leaf, not of the whole path: `f_postcode` suggests\n * `f_address.f_postcode` at distance zero, while comparing the two whole spellings would put\n * them far apart and offer nothing.\n */\nexport function closestByLeaf(\n name: string,\n candidates: readonly LeafCandidate[],\n limit = 3,\n): readonly string[] {\n const unique = new Map<string, LeafCandidate>();\n for (const candidate of candidates) {\n if (candidate.suggestion !== name && !unique.has(candidate.suggestion)) {\n unique.set(candidate.suggestion, candidate);\n }\n }\n return [...unique.values()]\n .map((candidate) => ({ candidate, distance: leven(name, candidate.leaf) }))\n .filter(({ candidate, distance }) => distance <= maxDistance(candidate.leaf))\n .sort((left, right) =>\n left.distance === right.distance\n ? left.candidate.suggestion < right.candidate.suggestion\n ? -1\n : 1\n : left.distance - right.distance,\n )\n .slice(0, limit)\n .map(({ candidate }) => candidate.suggestion);\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import type { CallNode } from '@azx-pbc/axiom-runtime';
2
+ import type { CheckContext } from './context.js';
3
+ import type { Operands } from './operands.js';
4
+ import type { StaticType } from './types.js';
5
+ /** List aggregates, uniqueness and the ordered extrema. */
6
+ export type AggregateOperator = 'is_unique' | 'all' | 'any' | 'sum' | 'count_where' | 'count_distinct' | 'min' | 'max' | 'avg' | 'median' | 'first' | 'last' | 'mode' | 'map' | 'filter';
7
+ export declare function aggregateType(ctx: CheckContext, op: AggregateOperator, node: CallNode, operands: Operands): StaticType;
8
+ //# sourceMappingURL=aggregates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregates.d.ts","sourceRoot":"","sources":["../../../src/expr/typecheck/aggregates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,wBAAwB,CAAC;AAEjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAW7C,2DAA2D;AAC3D,MAAM,MAAM,iBAAiB,GACzB,WAAW,GACX,KAAK,GACL,KAAK,GACL,KAAK,GACL,aAAa,GACb,gBAAgB,GAChB,KAAK,GACL,KAAK,GACL,KAAK,GACL,QAAQ,GACR,OAAO,GACP,MAAM,GACN,MAAM,GACN,KAAK,GACL,QAAQ,CAAC;AAoDb,wBAAgB,aAAa,CAC3B,GAAG,EAAE,YAAY,EACjB,EAAE,EAAE,iBAAiB,EACrB,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,QAAQ,GACjB,UAAU,CAoXZ"}