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

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,699 @@
1
+ import { BUILTIN_OPERATORS, DEPRECATED_BUILTINS } from '@azx-pbc/axiom-runtime';
2
+ import { ExpressionCompileError } from '../diagnostics.js';
3
+ import { spellStringLiteral, spellSource } from '../print/spell.js';
4
+ import { closestNames, spreadsheetSuggestions } from '../suggest.js';
5
+ import { COMPREHENSION_AGGREGATES, PROJECTION_AGGREGATES, PREDICATE_AGGREGATES, isAggregateBuiltin, } from './aggregates.js';
6
+ import { parseMoneyLiteral, parseMoneySpelling, typedScalarLiteral } from './literals.js';
7
+ /** The repair a comprehension outside an aggregate's argument list is refused with. */
8
+ function comprehensionRepair() {
9
+ return `a comprehension is only an argument of ${COMPREHENSION_AGGREGATES.map((name) => `\`${name}\``).join(', ')}; wrap it in one of those, or pass a plain list`;
10
+ }
11
+ const BUILTIN_NAMES = new Set(BUILTIN_OPERATORS);
12
+ /**
13
+ * The names Expr v1 withdrew, and the spelling that replaced each.
14
+ *
15
+ * A stored document may still name one. The refusal is the migration: it names the operator or
16
+ * function that carries the same answer, so an author repairs it without consulting a changelog.
17
+ * `spec/release/expr-retention.json` records the same mapping as the release's retention policy.
18
+ */
19
+ const REMOVED_BUILTINS = {
20
+ div_round: '`round(a / b, places)` (or `round_even`, `round_up`, `round_down` for another rounding)',
21
+ div_int: '`a // b`',
22
+ mod_int: '`a % b`',
23
+ sum0: '`sum(xs)`; an empty numeric list totals `0`',
24
+ };
25
+ function isBuiltinOperator(name) {
26
+ return BUILTIN_NAMES.has(name);
27
+ }
28
+ /**
29
+ * The closed set of host-language method names the parser reads as built-in calls.
30
+ *
31
+ * The receiver becomes the first operand: `s.trim()` is `trim(s)` and `s.startsWith("a")` is
32
+ * `starts_with(s, "a")`. The map is closed on purpose: a name outside it is not a method, and a
33
+ * record member read keeps its path spelling. Property-style `.length` (without parentheses) is
34
+ * disambiguated at typecheck time so a record member named `length` is not shadowed by `len`.
35
+ */
36
+ const METHOD_ALIASES = new Map([
37
+ ['length', 'len'],
38
+ ['trim', 'trim'],
39
+ ['lower', 'lower'],
40
+ ['toLowerCase', 'lower'],
41
+ ['upper', 'upper'],
42
+ ['toUpperCase', 'upper'],
43
+ ['startsWith', 'starts_with'],
44
+ ['endsWith', 'ends_with'],
45
+ ['includes', 'contains'],
46
+ ['slice', 'slice'],
47
+ ['split', 'split'],
48
+ ['join', 'join'],
49
+ ['replace', 'replace'],
50
+ ['indexOf', 'index_of'],
51
+ ]);
52
+ /**
53
+ * Whether a built-in's arguments may be comprehensions, `[EXPR-3.1.2]`. The parser owns which
54
+ * names fold a comprehension, so an emitter asks this rather than restating the set.
55
+ */
56
+ /** The root production: one expression over the whole cursor. */
57
+ export function parseExpression(stream) {
58
+ return stream.nest(() => parseConditional(stream));
59
+ }
60
+ /** The ternary `condition ? then : else`; below `??`, and right-associative. */
61
+ function parseConditional(stream) {
62
+ const condition = parseCoalesce(stream);
63
+ if (!stream.eatPunctuation('?'))
64
+ return condition;
65
+ const thenNode = parseExpression(stream);
66
+ stream.expectPunctuation(':');
67
+ const elseNode = parseExpression(stream);
68
+ return stream.node({ kind: 'if', args: [condition, thenNode, elseNode] });
69
+ }
70
+ function parseCoalesce(stream) {
71
+ const args = [parseDisjunction(stream)];
72
+ while (stream.eatPunctuation('??'))
73
+ args.push(parseDisjunction(stream));
74
+ return args.length === 1 && args[0] !== undefined
75
+ ? args[0]
76
+ : stream.node({ kind: 'coalesce', args });
77
+ }
78
+ function parseDisjunction(stream) {
79
+ const args = [parseConjunction(stream)];
80
+ for (;;) {
81
+ if (stream.eatKeyword('or') || stream.eatPunctuation('||')) {
82
+ args.push(parseConjunction(stream));
83
+ continue;
84
+ }
85
+ return args.length === 1 && args[0] !== undefined ? args[0] : stream.node({ kind: 'or', args });
86
+ }
87
+ }
88
+ function parseConjunction(stream) {
89
+ const args = [parseComparison(stream)];
90
+ for (;;) {
91
+ if (stream.eatKeyword('and') || stream.eatPunctuation('&&')) {
92
+ args.push(parseComparison(stream));
93
+ continue;
94
+ }
95
+ return args.length === 1 && args[0] !== undefined
96
+ ? args[0]
97
+ : stream.node({ kind: 'and', args });
98
+ }
99
+ }
100
+ function parseComparison(stream) {
101
+ const operands = [parseAdditive(stream)];
102
+ const ops = [];
103
+ const offsets = [];
104
+ for (;;) {
105
+ const op = comparisonOperator(stream.peek());
106
+ if (op === undefined)
107
+ break;
108
+ offsets.push(stream.peek().offset);
109
+ ops.push(op);
110
+ stream.next();
111
+ operands.push(parseAdditive(stream));
112
+ }
113
+ const first = ops[0];
114
+ if (first === undefined) {
115
+ const only = operands[0];
116
+ if (only === undefined)
117
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', 0, 'a comparison requires an operand');
118
+ return only;
119
+ }
120
+ if (ops.length > 1) {
121
+ // `1 < x < 5` states one relation per adjacent pair, exactly as `1 < x and x < 5` does.
122
+ // The operands are pure and total, so writing the middle one once in source and twice in
123
+ // the tree is unobservable. `in` states a membership, and a chain of memberships states
124
+ // nothing, so it is refused with the explicit conjunction as the repair.
125
+ if (ops.includes('in')) {
126
+ const repair = chainedComparisonRepair(operands, ops);
127
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', offsets[1] ?? offsets[0] ?? 0, repair === undefined
128
+ ? '`in` does not chain; join the adjacent comparisons with `and`'
129
+ : `\`in\` does not chain; write \`${repair}\``);
130
+ }
131
+ const args = [];
132
+ for (const [index, op] of ops.entries()) {
133
+ const left = operands[index];
134
+ const right = operands[index + 1];
135
+ if (left === undefined || right === undefined) {
136
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', 0, 'a comparison requires two operands');
137
+ }
138
+ args.push(stream.node({ kind: 'compare', op, args: [left, right] }, offsets[index]));
139
+ }
140
+ return stream.node({ kind: 'and', args }, offsets[0]);
141
+ }
142
+ const [left, right] = operands;
143
+ if (left === undefined || right === undefined) {
144
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', 0, 'a comparison requires two operands');
145
+ }
146
+ return stream.node({ kind: 'compare', op: first, args: [left, right] });
147
+ }
148
+ /** The conjunction a chained comparison means: `a < b and b < c`. */
149
+ function chainedComparisonRepair(operands, ops) {
150
+ const sources = [];
151
+ for (const operand of operands) {
152
+ const source = spellSource(operand);
153
+ if (source === undefined)
154
+ return undefined;
155
+ sources.push(source);
156
+ }
157
+ const terms = [];
158
+ for (const [index, op] of ops.entries()) {
159
+ const left = sources[index];
160
+ const right = sources[index + 1];
161
+ if (left === undefined || right === undefined)
162
+ return undefined;
163
+ terms.push(`${left} ${op} ${right}`);
164
+ }
165
+ return terms.join(' and ');
166
+ }
167
+ /** The comparison operator at `token`, or `undefined`; `in` is infix-only. */
168
+ function comparisonOperator(token) {
169
+ if (token.kind === 'punctuation') {
170
+ switch (token.text) {
171
+ case '==':
172
+ case '=':
173
+ return '==';
174
+ case '!=':
175
+ case '<>':
176
+ return '!=';
177
+ case '<':
178
+ case '<=':
179
+ case '>':
180
+ case '>=':
181
+ return token.text;
182
+ default:
183
+ return undefined;
184
+ }
185
+ }
186
+ if (token.kind === 'keyword' && token.text === 'in')
187
+ return 'in';
188
+ return undefined;
189
+ }
190
+ function parseAdditive(stream) {
191
+ let left = parseMultiplicative(stream);
192
+ for (;;) {
193
+ if (stream.eatPunctuation('+')) {
194
+ const args = [left, parseMultiplicative(stream)];
195
+ while (stream.eatPunctuation('+'))
196
+ args.push(parseMultiplicative(stream));
197
+ left = stream.node({ kind: 'call', op: '+', args });
198
+ continue;
199
+ }
200
+ if (stream.eatPunctuation('-')) {
201
+ left = stream.node({
202
+ kind: 'call',
203
+ op: '-',
204
+ args: [left, parseMultiplicative(stream)],
205
+ });
206
+ continue;
207
+ }
208
+ if (stream.atPunctuation('&'))
209
+ throw ampersandRefusal(stream, left);
210
+ return left;
211
+ }
212
+ }
213
+ /**
214
+ * The refusal for `&`, which BASIC and Excel spell as string concatenation.
215
+ *
216
+ * `concat` takes text, so the function is named only when one operand is a string literal: that
217
+ * is the shape the author almost certainly wrote (`f_name & " Ltd"`). Two names or two numbers
218
+ * are not certain enough to recommend a call that would then be refused for its operand types.
219
+ */
220
+ function ampersandRefusal(stream, left) {
221
+ const token = stream.next();
222
+ const right = probeOperand(stream, parseMultiplicative);
223
+ const leftSource = right === undefined ? undefined : spellSource(left);
224
+ const rightSource = right === undefined ? undefined : spellSource(right);
225
+ const textOperand = right !== undefined &&
226
+ ((left.kind === 'literal' && left.domain === 'string') ||
227
+ (right.kind === 'literal' && right.domain === 'string'));
228
+ if (leftSource === undefined || rightSource === undefined || !textOperand) {
229
+ return new ExpressionCompileError('EXPR_PARSE_ERROR', token.offset, '`&` is not an Expr v1 operator; string concatenation is written `concat(a, b)`', ['concat']);
230
+ }
231
+ return new ExpressionCompileError('EXPR_PARSE_ERROR', token.offset, `\`&\` is not an Expr v1 operator; write \`concat(${leftSource}, ${rightSource})\``, ['concat']);
232
+ }
233
+ function parseMultiplicative(stream) {
234
+ let left = parsePower(stream);
235
+ for (;;) {
236
+ if (stream.eatPunctuation('%')) {
237
+ left = stream.node({ kind: 'call', op: '%', args: [left, parsePower(stream)] });
238
+ continue;
239
+ }
240
+ if (stream.eatPunctuation('//')) {
241
+ left = stream.node({ kind: 'call', op: '//', args: [left, parsePower(stream)] });
242
+ continue;
243
+ }
244
+ if (stream.eatPunctuation('/')) {
245
+ // `/` is binary and left-associative: `a / b / c` is `(a / b) / c`. It never folds a run
246
+ // into one n-ary node, because division is not associative.
247
+ left = stream.node({ kind: 'call', op: '/', args: [left, parsePower(stream)] });
248
+ continue;
249
+ }
250
+ if (!stream.eatPunctuation('*'))
251
+ return left;
252
+ const args = [left, parsePower(stream)];
253
+ while (stream.eatPunctuation('*'))
254
+ args.push(parsePower(stream));
255
+ left = stream.node({ kind: 'call', op: '*', args });
256
+ }
257
+ }
258
+ /**
259
+ * `**` and `^` are power, written `pow(a, b)`. The production is right-associative:
260
+ * `2 ** 3 ** 2` is `2 ** (3 ** 2)`, as in Python, Ruby and ordinary mathematical notation.
261
+ * `pow` is the canonical name, so the AST never carries the operator spelling.
262
+ */
263
+ function parsePower(stream) {
264
+ const left = parseUnary(stream);
265
+ if (!stream.atPunctuation('**') && !stream.atPunctuation('^'))
266
+ return left;
267
+ const token = stream.next();
268
+ const node = stream.node({ kind: 'call', op: 'pow', args: [left, parsePower(stream)] }, token.offset);
269
+ stream.powerOperators.add(node);
270
+ return node;
271
+ }
272
+ /**
273
+ * Parses the operand after a refused infix spelling, or `undefined` when one does not parse.
274
+ *
275
+ * The operator is already the author's first problem: `15%` is a percentage reflex with no right
276
+ * operand at all, and reporting the missing operand instead would bury the sentence that names
277
+ * the operator. A defect still escapes; only the language's own refusal is absorbed.
278
+ */
279
+ function probeOperand(stream, parse) {
280
+ try {
281
+ return parse(stream);
282
+ }
283
+ catch (error) {
284
+ if (error instanceof ExpressionCompileError)
285
+ return undefined;
286
+ throw error;
287
+ }
288
+ }
289
+ function parseUnary(stream) {
290
+ if (stream.eatKeyword('not') || stream.eatPunctuation('!')) {
291
+ return stream.node({ kind: 'not', args: [stream.nest(() => parseUnary(stream))] });
292
+ }
293
+ if (stream.atPunctuation('-')) {
294
+ const minus = stream.next();
295
+ const token = stream.peek();
296
+ if (token.kind === 'integer') {
297
+ stream.next();
298
+ const value = -token.value;
299
+ if (value === 0) {
300
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', minus.offset, '`-0` is not a canonical numeric literal; write `0`');
301
+ }
302
+ if (!Number.isSafeInteger(value)) {
303
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', minus.offset, `integer -${token.text} is outside the canonical range`);
304
+ }
305
+ refuseNumericMember(stream);
306
+ return stream.node({ kind: 'literal', domain: 'integer', value });
307
+ }
308
+ if (token.kind === 'decimal') {
309
+ stream.next();
310
+ if (token.value === '0') {
311
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', minus.offset, '`-0` is not a canonical decimal literal; write `0`');
312
+ }
313
+ refuseNumericMember(stream);
314
+ return stream.node({ kind: 'literal', domain: 'decimal', value: `-${token.value}` });
315
+ }
316
+ return stream.node({ kind: 'call', op: '-', args: [stream.nest(() => parseUnary(stream))] });
317
+ }
318
+ return parsePrimary(stream);
319
+ }
320
+ /** Refuses `.name` immediately after an integer or decimal literal with an accurate diagnostic. */
321
+ function refuseNumericMember(stream) {
322
+ if (!stream.atPunctuation('.'))
323
+ return;
324
+ const segment = stream.peek(1);
325
+ if (segment.kind !== 'identifier')
326
+ return;
327
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', stream.peek().offset, `a numeric literal has no member or method \`${segment.text}\`; numbers are not records, strings or lists`);
328
+ }
329
+ function parsePrimary(stream) {
330
+ const token = stream.peek();
331
+ switch (token.kind) {
332
+ case 'integer':
333
+ stream.next();
334
+ refuseNumericMember(stream);
335
+ return stream.node({ kind: 'literal', domain: 'integer', value: token.value });
336
+ case 'decimal':
337
+ stream.next();
338
+ refuseNumericMember(stream);
339
+ return stream.node({ kind: 'literal', domain: 'decimal', value: token.value });
340
+ case 'string':
341
+ stream.next();
342
+ return parseTrailingMembers(stream, stream.node({ kind: 'literal', domain: 'string', value: token.value }));
343
+ case 'punctuation':
344
+ if (token.text === '(') {
345
+ stream.next();
346
+ const inner = parseExpression(stream);
347
+ stream.expectPunctuation(')');
348
+ return parseTrailingMembers(stream, inner);
349
+ }
350
+ if (token.text === '[') {
351
+ stream.next();
352
+ return parseTrailingMembers(stream, stream.node({ kind: 'list', items: parseListItems(stream) }));
353
+ }
354
+ if (token.text === '$') {
355
+ stream.next();
356
+ const first = stream.expectIdentifier('an implicit binder name');
357
+ const path = stream.node({ kind: 'path', path: `$${first}` }, token.offset);
358
+ return parseTrailingMembers(stream, path, token.offset);
359
+ }
360
+ if (token.text === '=') {
361
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', token.offset, stream.isAtStart()
362
+ ? 'a leading `=` is a spreadsheet formula marker, not Expr v1; delete it, because Expr takes the expression itself'
363
+ : '`=` is equality between two operands; write `f_a = 2`', stream.isAtStart() ? [] : ['==']);
364
+ }
365
+ throw stream.unexpected('expected an expression');
366
+ case 'keyword':
367
+ return parseTrailingMembers(stream, parseKeywordPrimary(stream, token.text));
368
+ case 'identifier':
369
+ stream.next();
370
+ if (stream.atPunctuation('(')) {
371
+ return parseTrailingMembers(stream, parseCall(stream, token));
372
+ }
373
+ return parseTrailingMembers(stream, stream.node({ kind: 'path', path: token.text }, token.offset), token.offset);
374
+ default:
375
+ throw stream.unexpected('expected an expression');
376
+ }
377
+ }
378
+ /**
379
+ * Trailing `.name` segments of an expression.
380
+ *
381
+ * `lookup(t, [k]).col` reads a member of a record an expression produced. The closed AST has
382
+ * no member node, so the form lowers to `member(<expr>, "col")`, which is the same record read
383
+ * a path performs and the type checker can prove against the declared output columns.
384
+ *
385
+ * A closed-set method name with `(` is a call with the receiver as its first operand: `s.trim()`
386
+ * is `trim(s)`. Every bare `.name` (including `.length`) stays a path segment on a path and a
387
+ * `member` read on any other expression; postfix `.length` is lowered to `len` at typecheck time
388
+ * when the receiver is a string or list, so a genuine record member named `length` is never
389
+ * shadowed.
390
+ */
391
+ function parseTrailingMembers(stream, base, pathOffset) {
392
+ let node = base;
393
+ for (;;) {
394
+ if (!stream.atPunctuation('.'))
395
+ return node;
396
+ const segment = stream.peek(1);
397
+ if (segment.kind !== 'identifier')
398
+ return node;
399
+ const builtin = METHOD_ALIASES.get(segment.text);
400
+ const atCall = stream.peek(2).kind === 'punctuation' && stream.peek(2).text === '(';
401
+ if (builtin !== undefined && atCall) {
402
+ const dot = stream.next();
403
+ stream.next();
404
+ const args = parseArguments(stream, segment.text);
405
+ node = stream.node({ kind: 'call', op: builtin, args: [node, ...args] }, dot.offset);
406
+ continue;
407
+ }
408
+ if (atCall) {
409
+ throw new ExpressionCompileError('UNKNOWN_IDENTIFIER', segment.offset, `\`${segment.text}\` is not a method in Expr v1; read a member with a dot, as \`f_record.f_name\``, closestNames(segment.text, [...METHOD_ALIASES.keys()]));
410
+ }
411
+ const dot = stream.next();
412
+ stream.next();
413
+ if (node.kind === 'path') {
414
+ node = stream.node({ kind: 'path', path: `${node.path}.${segment.text}` }, pathOffset ?? dot.offset);
415
+ continue;
416
+ }
417
+ const memberNode = stream.node({
418
+ kind: 'call',
419
+ op: 'member',
420
+ args: [node, stream.node({ kind: 'literal', domain: 'string', value: segment.text })],
421
+ }, dot.offset);
422
+ if (segment.text === 'length')
423
+ stream.lengthProperties.add(memberNode);
424
+ node = memberNode;
425
+ }
426
+ }
427
+ function parseKeywordPrimary(stream, keyword) {
428
+ if (keyword === 'true' || keyword === 'false') {
429
+ stream.next();
430
+ return stream.node({ kind: 'literal', domain: 'boolean', value: keyword === 'true' });
431
+ }
432
+ if (keyword === 'null' || keyword === 'None' || keyword === 'nil') {
433
+ stream.next();
434
+ return stream.node({ kind: 'literal', domain: 'null', value: null });
435
+ }
436
+ if (keyword === 'decimal' || keyword === 'date' || keyword === 'instant') {
437
+ stream.next();
438
+ const token = stream.next();
439
+ if (token.kind !== 'string') {
440
+ const repair = typedLiteralRepair(stream, keyword, token);
441
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', token.offset, `\`${keyword}\` requires a quoted canonical spelling${repair === undefined ? '' : `; write \`${repair}\``}`, [], repair);
442
+ }
443
+ return stream.node(typedScalarLiteral(keyword, token.value, token.offset));
444
+ }
445
+ if (keyword === 'money') {
446
+ stream.next();
447
+ // A parenthesised call is the spelling a host language's helper function has: name the two
448
+ // literal forms rather than the `{` production the parser expected, because the author's
449
+ // mistake is the whole shape, not the character here.
450
+ if (stream.atPunctuation('(')) {
451
+ const paren = stream.next();
452
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', paren.offset, 'a money literal is `money "35.00" "AUD"`, or `money {"minor": "3500", "currency": "AUD", "scale": 2}`');
453
+ }
454
+ // `money "5000.00" "AUD"` is the literal form; `money { ... }` is the wire object. The
455
+ // first token after the keyword decides which production applies.
456
+ return stream.peek().kind === 'string' ? parseMoneySpelling(stream) : parseMoneyLiteral(stream);
457
+ }
458
+ if (keyword === 'if') {
459
+ const keywordToken = stream.next();
460
+ // A bare `if` ends a comprehension's value projection and introduces its filter
461
+ // so it is only the conditional form when a call follows.
462
+ if (!stream.atPunctuation('(')) {
463
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', keywordToken.offset, '`if` is the conditional form `if(condition, then, else)`');
464
+ }
465
+ const args = parseArguments(stream, 'if');
466
+ if (args.length !== 3) {
467
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', keywordToken.offset, `\`if\` takes exactly three arguments, found ${String(args.length)}`);
468
+ }
469
+ const [condition, thenNode, elseNode] = args;
470
+ if (condition === undefined || thenNode === undefined || elseNode === undefined) {
471
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', keywordToken.offset, '`if` takes exactly three arguments');
472
+ }
473
+ return stream.node({ kind: 'if', args: [condition, thenNode, elseNode] });
474
+ }
475
+ if (keyword === 'in' && stream.peek(1).kind === 'punctuation' && stream.peek(1).text === '(') {
476
+ throw new ExpressionCompileError('UNKNOWN_IDENTIFIER', stream.peek().offset, '`in` is an infix operator; write `x in xs`', []);
477
+ }
478
+ throw stream.unexpected('expected an expression');
479
+ }
480
+ /**
481
+ * The canonical spelling a typed literal most likely meant, when the shape is certain.
482
+ *
483
+ * `decimal 1.5` states the value without the quotes the grammar requires; `date("2026-01-01")`
484
+ * borrows a host language's call syntax. Both are repaired from tokens the parser already read,
485
+ * so the sentence names the exact text to write rather than the shape alone. Any other following
486
+ * token keeps the original refusal, because a wrong example is worse than none.
487
+ */
488
+ function typedLiteralRepair(stream, keyword, token) {
489
+ if (keyword === 'decimal') {
490
+ if (token.kind === 'integer')
491
+ return `decimal "${token.text}"`;
492
+ if (token.kind === 'decimal')
493
+ return `decimal "${token.value}"`;
494
+ }
495
+ if (token.kind === 'punctuation' && token.text === '(') {
496
+ const value = stream.peek();
497
+ const close = stream.peek(1);
498
+ if (value.kind === 'string' && close.kind === 'punctuation' && close.text === ')') {
499
+ return `${keyword} ${spellStringLiteral(value.value)}`;
500
+ }
501
+ }
502
+ return undefined;
503
+ }
504
+ function parseArguments(stream, name) {
505
+ stream.expectPunctuation('(');
506
+ if (stream.eatPunctuation(')'))
507
+ return [];
508
+ const args = [];
509
+ for (;;) {
510
+ args.push(parseExpression(stream));
511
+ if (stream.eatPunctuation(')'))
512
+ return args;
513
+ if (stream.atPunctuation(':')) {
514
+ // A comprehension fed to a name outside the aggregate set would otherwise surface as
515
+ // "expected )", which names the token rather than the form. Name both instead.
516
+ const token = stream.peek();
517
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', token.offset, `\`${name}\` takes no comprehension; ${comprehensionRepair()}`);
518
+ }
519
+ stream.expectPunctuation(',');
520
+ if (name === 'if' && args.length >= 3) {
521
+ throw stream.unexpected('`if` takes exactly three arguments');
522
+ }
523
+ }
524
+ }
525
+ function parseListItems(stream) {
526
+ if (stream.eatPunctuation(']'))
527
+ return [];
528
+ const items = [];
529
+ for (;;) {
530
+ items.push(parseExpression(stream));
531
+ if (stream.eatPunctuation(']'))
532
+ return items;
533
+ stream.expectPunctuation(',');
534
+ }
535
+ }
536
+ function parseCall(stream, token) {
537
+ const name = token.text;
538
+ const connective = CONNECTIVE_CALLS.get(name.toUpperCase());
539
+ if (connective !== undefined) {
540
+ const args = parseArguments(stream, name);
541
+ const expected = connective === 'not' ? 1 : 2;
542
+ if (args.length !== expected) {
543
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', token.offset, `\`${name}\` takes ${String(expected)} argument${expected === 1 ? '' : 's'}, found ${String(args.length)}`);
544
+ }
545
+ if (connective === 'not') {
546
+ const [only] = args;
547
+ if (only === undefined) {
548
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', token.offset, '`NOT` requires one operand');
549
+ }
550
+ return stream.node({ kind: 'not', args: [only] }, token.offset);
551
+ }
552
+ const [left, right] = args;
553
+ if (left === undefined || right === undefined) {
554
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', token.offset, `\`${name}\` takes two operands`);
555
+ }
556
+ return stream.node({ kind: connective, args: [left, right] }, token.offset);
557
+ }
558
+ if (!isBuiltinOperator(name)) {
559
+ const removed = REMOVED_BUILTINS[name];
560
+ if (removed !== undefined) {
561
+ throw new ExpressionCompileError('UNKNOWN_IDENTIFIER', token.offset, `\`${name}\` was removed from Expr v1; write ${removed}`);
562
+ }
563
+ const familiar = familiarCallRefusal(stream, token);
564
+ if (familiar !== undefined)
565
+ throw familiar;
566
+ throw new ExpressionCompileError('UNKNOWN_IDENTIFIER', token.offset, `\`${name}\` is not a built-in of Expr v1`, [...new Set([...closestNames(name, [...BUILTIN_NAMES]), ...spreadsheetSuggestions(name)])]);
567
+ }
568
+ // Only an authored call is recorded: `x.y` and `lookup(t, [k]).col` lower to the same AST op
569
+ // without passing here, and those are the source forms the deprecation recommends.
570
+ if (DEPRECATED_BUILTINS.some((entry) => entry.name === name)) {
571
+ stream.noteDeprecated(name, token.offset);
572
+ }
573
+ if (isAggregateBuiltin(name)) {
574
+ return stream.node({ kind: 'call', op: name, args: parseAggregateArguments(stream, name) }, token.offset);
575
+ }
576
+ return stream.node({ kind: 'call', op: name, args: parseArguments(stream, name) }, token.offset);
577
+ }
578
+ /** The spreadsheet connective calls and the node each one produces. */
579
+ const CONNECTIVE_CALLS = new Map([
580
+ ['AND', 'and'],
581
+ ['OR', 'or'],
582
+ ['NOT', 'not'],
583
+ ]);
584
+ /**
585
+ * The refusal for a call spelled the way Excel or Visual Basic spells an emptiness test.
586
+ *
587
+ * `AND`, `OR` and `NOT` are accepted as their connectives, so only `is_empty` remains: it names
588
+ * `empty` and `absent`, because "no content" and "was never captured" are two different readings
589
+ * and the author may mean either. `len(...) == 0` agrees with `empty` on text and lists.
590
+ */
591
+ function familiarCallRefusal(stream, token) {
592
+ const name = token.text;
593
+ if (name.toLowerCase() !== 'is_empty')
594
+ return undefined;
595
+ const args = parseArguments(stream, name);
596
+ const [arg] = args;
597
+ const source = args.length === 1 && arg !== undefined ? spellSource(arg) : undefined;
598
+ if (source === undefined)
599
+ return undefined;
600
+ return new ExpressionCompileError('UNKNOWN_IDENTIFIER', token.offset, `\`${name}\` is not an Expr v1 built-in; write \`empty(${source})\` for "no content", or \`absent(${source})\` for "was never captured"`);
601
+ }
602
+ /**
603
+ * An aggregate's arguments are either ordinary expressions or one comprehension,
604
+ * A comprehension is recognised by its binder and the `:` that fixes
605
+ * its body, so `x in xs` without a body stays the comparison it looks like.
606
+ */
607
+ function parseAggregateArguments(stream, name) {
608
+ stream.expectPunctuation('(');
609
+ if (stream.eatPunctuation(')'))
610
+ return [];
611
+ const args = [];
612
+ for (;;) {
613
+ args.push(atComprehension(stream) ? parseComprehension(stream, name) : parseExpression(stream));
614
+ if (stream.eatPunctuation(')'))
615
+ return args;
616
+ stream.expectPunctuation(',');
617
+ }
618
+ }
619
+ function atComprehension(stream) {
620
+ const binder = stream.peek();
621
+ if (binder.kind !== 'identifier')
622
+ return false;
623
+ if (!stream.keywordAt(1, 'in'))
624
+ return false;
625
+ return hasTopLevelColon(stream);
626
+ }
627
+ /**
628
+ * Whether a `:` follows before the argument ends, ignoring separators inside brackets and
629
+ * colons that close a `?` in a ternary conditional.
630
+ */
631
+ function hasTopLevelColon(stream) {
632
+ let depth = 0;
633
+ let ternaryDepth = 0;
634
+ for (let offset = 0;; offset += 1) {
635
+ const token = stream.peek(offset);
636
+ if (token.kind === 'eof')
637
+ return false;
638
+ if (token.kind === 'punctuation') {
639
+ if (token.text === '(' || token.text === '[' || token.text === '{')
640
+ depth += 1;
641
+ else if (token.text === ')' || token.text === ']' || token.text === '}') {
642
+ if (depth === 0)
643
+ return false;
644
+ depth -= 1;
645
+ }
646
+ else if (depth === 0) {
647
+ if (token.text === ',')
648
+ return false;
649
+ if (token.text === '?')
650
+ ternaryDepth += 1;
651
+ else if (token.text === ':') {
652
+ if (ternaryDepth === 0)
653
+ return true;
654
+ ternaryDepth -= 1;
655
+ }
656
+ }
657
+ }
658
+ }
659
+ }
660
+ function parseComprehension(stream, name) {
661
+ const binderToken = stream.next();
662
+ const binder = binderToken.text;
663
+ if (stream.hasBinder(binder)) {
664
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', binderToken.offset, `binder \`${binder}\` shadows an enclosing binder; give this one a different name`);
665
+ }
666
+ stream.next();
667
+ const source = parseExpression(stream);
668
+ stream.expectPunctuation(':');
669
+ stream.pushBinder(binder);
670
+ try {
671
+ const body = parseExpression(stream);
672
+ const predicate = stream.eatKeyword('if') ? parseExpression(stream) : undefined;
673
+ if (PREDICATE_AGGREGATES.has(name)) {
674
+ if (predicate !== undefined) {
675
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', binderToken.offset, `\`${name}\` already answers yes or no for each row, so its comprehension takes no \`if\` clause; write \`${name}(r in xs: condition)\``);
676
+ }
677
+ return stream.node({
678
+ kind: 'comprehension',
679
+ binder: { name: binder },
680
+ source,
681
+ predicate: body,
682
+ });
683
+ }
684
+ if (!PROJECTION_AGGREGATES.has(name)) {
685
+ throw new ExpressionCompileError('EXPR_PARSE_ERROR', binderToken.offset, `a comprehension belongs only inside an aggregate call such as \`sum(r in rows: r.amount)\``);
686
+ }
687
+ return stream.node({
688
+ kind: 'comprehension',
689
+ binder: { name: binder },
690
+ source,
691
+ valueExpr: body,
692
+ ...(predicate === undefined ? {} : { predicate }),
693
+ });
694
+ }
695
+ finally {
696
+ stream.popBinder();
697
+ }
698
+ }
699
+ //# sourceMappingURL=grammar.js.map