solve-engine 1.1.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (395) hide show
  1. package/README.md +12 -17
  2. package/dist/{BytecodeBuilder-Bp9xeTmX.d.cts → BytecodeBuilder-DGGeByAP.d.cts} +18 -0
  3. package/dist/{BytecodeBuilder-Bp9xeTmX.d.ts → BytecodeBuilder-DGGeByAP.d.ts} +18 -0
  4. package/dist/{Configuration-C9W8tJv_.d.cts → Configuration-B6W0-T67.d.cts} +17 -4
  5. package/dist/{Configuration-C9W8tJv_.d.ts → Configuration-B6W0-T67.d.ts} +17 -4
  6. package/dist/{EngineError-B61GS1jp.d.cts → EngineError-Ce1lPkjZ.d.cts} +8 -0
  7. package/dist/{EngineError-B61GS1jp.d.ts → EngineError-Ce1lPkjZ.d.ts} +8 -0
  8. package/dist/{Lexer-BOs7euZe.d.cts → Lexer-B4C1qHXu.d.cts} +1 -1
  9. package/dist/{Lexer-CSI_lwbW.d.ts → Lexer-DKMlj7Sy.d.ts} +1 -1
  10. package/dist/{PackageCompatibility-B-7rK1TD.d.cts → PackageCompatibility-Bn5jnBtA.d.cts} +2 -2
  11. package/dist/{PackageCompatibility-Dh59eF-X.d.ts → PackageCompatibility-CIvq2MP5.d.ts} +2 -2
  12. package/dist/{PackageRegistry-_8rDlvxI.d.ts → PackageRegistry-DzeiWcv4.d.ts} +143 -175
  13. package/dist/{PackageRegistry-BHWJP83F.d.cts → PackageRegistry-dpdurBVO.d.cts} +143 -175
  14. package/dist/{Parselet-BBT8riYh.d.ts → Parselet-B-zoPrTa.d.ts} +9 -6
  15. package/dist/{Parselet-BHcgK9S7.d.cts → Parselet-C4Wu055_.d.cts} +9 -6
  16. package/dist/{ScopeManager-CxA24W5n.d.ts → ScopeManager-C2LDOrDx.d.ts} +14 -16
  17. package/dist/{ScopeManager-8vf02dwj.d.cts → ScopeManager-D7uMXbhS.d.cts} +14 -16
  18. package/dist/{Token-B1hdkedD.d.cts → Token-CbP_OutD.d.cts} +9 -0
  19. package/dist/{Token-B1hdkedD.d.ts → Token-CbP_OutD.d.ts} +9 -0
  20. package/dist/{TokenNormalizer-C6VzZgHa.d.ts → TokenNormalizer-DCWdZjGz.d.ts} +1 -1
  21. package/dist/{TokenNormalizer-DRc1Js1V.d.cts → TokenNormalizer-DnlL7_8c.d.cts} +1 -1
  22. package/dist/{VMCheckpoints-MK--EBH2.d.ts → VMCheckpoints-CGyFhivM.d.ts} +3 -3
  23. package/dist/{VMCheckpoints-ELYqITdF.d.cts → VMCheckpoints-I9jg3jWR.d.cts} +3 -3
  24. package/dist/{Value-BUi1RA3S.d.cts → Value-CCi_Eecs.d.cts} +72 -5
  25. package/dist/{Value-BUi1RA3S.d.ts → Value-CCi_Eecs.d.ts} +72 -5
  26. package/dist/{WorkerError-gzmaopj2.d.cts → WorkerError-B4p6PNfx.d.cts} +1 -1
  27. package/dist/{WorkerError-_-RkoQ5P.d.ts → WorkerError-Dhj9BQ_A.d.ts} +1 -1
  28. package/dist/chunk-2JMFUQZH.js +2 -0
  29. package/dist/chunk-2JMFUQZH.js.map +1 -0
  30. package/dist/chunk-2RWAXT6O.js +0 -1
  31. package/dist/chunk-4BZIYU7S.cjs +3 -0
  32. package/dist/chunk-4BZIYU7S.cjs.map +1 -0
  33. package/dist/chunk-4J7XZSZJ.cjs +5 -0
  34. package/dist/chunk-4J7XZSZJ.cjs.map +1 -0
  35. package/dist/chunk-4QVBSG6B.cjs +2 -0
  36. package/dist/chunk-4QVBSG6B.cjs.map +1 -0
  37. package/dist/chunk-5IJD5L3O.cjs +2 -0
  38. package/dist/chunk-5IJD5L3O.cjs.map +1 -0
  39. package/dist/chunk-62LMTO4F.js +2 -0
  40. package/dist/chunk-62LMTO4F.js.map +1 -0
  41. package/dist/chunk-6CY44ZPG.js +2 -0
  42. package/dist/chunk-6CY44ZPG.js.map +1 -0
  43. package/dist/chunk-6G3PMEPA.js +2 -0
  44. package/dist/chunk-6G3PMEPA.js.map +1 -0
  45. package/dist/chunk-6INX773F.cjs +2 -0
  46. package/dist/chunk-6INX773F.cjs.map +1 -0
  47. package/dist/chunk-6KFVG6UY.cjs +2 -0
  48. package/dist/chunk-6KFVG6UY.cjs.map +1 -0
  49. package/dist/chunk-76F3LCIL.js +4 -0
  50. package/dist/chunk-76F3LCIL.js.map +1 -0
  51. package/dist/chunk-7GK3XEZF.js +2 -0
  52. package/dist/chunk-7GK3XEZF.js.map +1 -0
  53. package/dist/chunk-APN442VD.cjs +2 -0
  54. package/dist/chunk-APN442VD.cjs.map +1 -0
  55. package/dist/chunk-AXMQG5TS.cjs +2 -0
  56. package/dist/chunk-AXMQG5TS.cjs.map +1 -0
  57. package/dist/chunk-CIQOK7Q4.cjs +2 -0
  58. package/dist/chunk-CIQOK7Q4.cjs.map +1 -0
  59. package/dist/chunk-E6Z4NQAS.js +2 -0
  60. package/dist/chunk-E6Z4NQAS.js.map +1 -0
  61. package/dist/chunk-EFJCC6FJ.cjs +2 -0
  62. package/dist/chunk-EFJCC6FJ.cjs.map +1 -0
  63. package/dist/chunk-ESUN2THE.cjs +2 -0
  64. package/dist/chunk-ESUN2THE.cjs.map +1 -0
  65. package/dist/chunk-EVAOPEO4.js +2 -0
  66. package/dist/chunk-EVAOPEO4.js.map +1 -0
  67. package/dist/chunk-EYRBENHC.js +3 -0
  68. package/dist/chunk-EYRBENHC.js.map +1 -0
  69. package/dist/chunk-FDE5HWDI.cjs +2 -0
  70. package/dist/chunk-FDE5HWDI.cjs.map +1 -0
  71. package/dist/chunk-FWW3M36J.cjs +2 -0
  72. package/dist/chunk-FWW3M36J.cjs.map +1 -0
  73. package/dist/chunk-GOIQYUWV.js +2 -0
  74. package/dist/chunk-GOIQYUWV.js.map +1 -0
  75. package/dist/chunk-HFKDWQUL.js +2 -0
  76. package/dist/chunk-HFKDWQUL.js.map +1 -0
  77. package/dist/chunk-HLBYHXQD.cjs +3 -0
  78. package/dist/chunk-HLBYHXQD.cjs.map +1 -0
  79. package/dist/chunk-IANAMBJQ.cjs +2 -0
  80. package/dist/chunk-IANAMBJQ.cjs.map +1 -0
  81. package/dist/chunk-IJMNVBIS.js +2 -0
  82. package/dist/chunk-IJMNVBIS.js.map +1 -0
  83. package/dist/chunk-J4LZD4ZY.js +3 -0
  84. package/dist/chunk-J4LZD4ZY.js.map +1 -0
  85. package/dist/chunk-JAK3RAFA.cjs +2 -0
  86. package/dist/chunk-JAK3RAFA.cjs.map +1 -0
  87. package/dist/chunk-JFAJN3C2.cjs +2 -0
  88. package/dist/chunk-JFAJN3C2.cjs.map +1 -0
  89. package/dist/chunk-JPFCXLJV.js +2 -0
  90. package/dist/chunk-JPFCXLJV.js.map +1 -0
  91. package/dist/chunk-JSPKKNPQ.js +3 -0
  92. package/dist/chunk-JSPKKNPQ.js.map +1 -0
  93. package/dist/chunk-L3FPQSGN.js +2 -0
  94. package/dist/chunk-L3FPQSGN.js.map +1 -0
  95. package/dist/chunk-LR4E4A4W.cjs +2 -0
  96. package/dist/chunk-LR4E4A4W.cjs.map +1 -0
  97. package/dist/chunk-MIQBJGGR.js +2 -0
  98. package/dist/chunk-MIQBJGGR.js.map +1 -0
  99. package/dist/chunk-MPB7KUN5.js +3 -0
  100. package/dist/chunk-MPB7KUN5.js.map +1 -0
  101. package/dist/chunk-MSYX32PF.cjs +2 -0
  102. package/dist/chunk-MSYX32PF.cjs.map +1 -0
  103. package/dist/chunk-MVZUTETT.js +2 -0
  104. package/dist/chunk-MVZUTETT.js.map +1 -0
  105. package/dist/chunk-N7N7MPMK.cjs +2 -0
  106. package/dist/chunk-N7N7MPMK.cjs.map +1 -0
  107. package/dist/chunk-NGBBNL4K.cjs +1 -3
  108. package/dist/chunk-P6WPEUAJ.cjs +2 -0
  109. package/dist/chunk-P6WPEUAJ.cjs.map +1 -0
  110. package/dist/chunk-PS272DZJ.cjs +2 -0
  111. package/dist/chunk-PS272DZJ.cjs.map +1 -0
  112. package/dist/chunk-QXQE7X4S.js +2 -0
  113. package/dist/chunk-QXQE7X4S.js.map +1 -0
  114. package/dist/chunk-R2ENWQ76.js +2 -0
  115. package/dist/chunk-R2ENWQ76.js.map +1 -0
  116. package/dist/chunk-R2SZFJTT.cjs +2 -0
  117. package/dist/chunk-R2SZFJTT.cjs.map +1 -0
  118. package/dist/chunk-RAF57WYO.js +2 -0
  119. package/dist/chunk-RAF57WYO.js.map +1 -0
  120. package/dist/chunk-RSF25YSJ.js +2 -0
  121. package/dist/chunk-RSF25YSJ.js.map +1 -0
  122. package/dist/chunk-SOMGSIO4.cjs +3 -0
  123. package/dist/chunk-SOMGSIO4.cjs.map +1 -0
  124. package/dist/chunk-SUXRZWH2.cjs +3 -0
  125. package/dist/chunk-SUXRZWH2.cjs.map +1 -0
  126. package/dist/chunk-SYYE3QAX.cjs +2 -0
  127. package/dist/chunk-SYYE3QAX.cjs.map +1 -0
  128. package/dist/chunk-SZGK6RIP.cjs +2 -0
  129. package/dist/chunk-SZGK6RIP.cjs.map +1 -0
  130. package/dist/chunk-TCZSPH4A.js +2 -0
  131. package/dist/chunk-TCZSPH4A.js.map +1 -0
  132. package/dist/chunk-TLG7VZRX.cjs +2 -0
  133. package/dist/chunk-TLG7VZRX.cjs.map +1 -0
  134. package/dist/chunk-TRBXW6HW.js +2 -0
  135. package/dist/{chunk-AQNHHJMJ.cjs.map → chunk-TRBXW6HW.js.map} +1 -1
  136. package/dist/chunk-TTFO4YDP.cjs +2 -0
  137. package/dist/chunk-TTFO4YDP.cjs.map +1 -0
  138. package/dist/chunk-TWC7K3ZX.js +2 -0
  139. package/dist/chunk-TWC7K3ZX.js.map +1 -0
  140. package/dist/chunk-UDQ57ZRX.cjs +2 -0
  141. package/dist/chunk-UDQ57ZRX.cjs.map +1 -0
  142. package/dist/chunk-UI6IFGBT.js +2 -0
  143. package/dist/chunk-UI6IFGBT.js.map +1 -0
  144. package/dist/chunk-UURM7P3P.cjs +4 -0
  145. package/dist/chunk-UURM7P3P.cjs.map +1 -0
  146. package/dist/chunk-W2JAR233.js +2 -0
  147. package/dist/chunk-W2JAR233.js.map +1 -0
  148. package/dist/chunk-WGZ3FNHI.js +2 -0
  149. package/dist/chunk-WGZ3FNHI.js.map +1 -0
  150. package/dist/chunk-WN5CMP4T.cjs +3 -0
  151. package/dist/chunk-WN5CMP4T.cjs.map +1 -0
  152. package/dist/chunk-XEIDV5JP.js +2 -0
  153. package/dist/chunk-XEIDV5JP.js.map +1 -0
  154. package/dist/chunk-XNIWQHXY.js +2 -0
  155. package/dist/chunk-XNIWQHXY.js.map +1 -0
  156. package/dist/chunk-XR7HEC7B.js +5 -0
  157. package/dist/chunk-XR7HEC7B.js.map +1 -0
  158. package/dist/chunk-Y7O4D3BJ.cjs +2 -0
  159. package/dist/chunk-Y7O4D3BJ.cjs.map +1 -0
  160. package/dist/chunk-YAYBVVG2.js +3 -0
  161. package/dist/chunk-YAYBVVG2.js.map +1 -0
  162. package/dist/chunk-YJ2OPULK.js +2 -0
  163. package/dist/chunk-YJ2OPULK.js.map +1 -0
  164. package/dist/chunk-YVKHEAFT.js +2 -0
  165. package/dist/chunk-YVKHEAFT.js.map +1 -0
  166. package/dist/chunk-ZCNBT44X.cjs +2 -0
  167. package/dist/chunk-ZCNBT44X.cjs.map +1 -0
  168. package/dist/chunk-ZLRJ7TDP.cjs +2 -0
  169. package/dist/chunk-ZLRJ7TDP.cjs.map +1 -0
  170. package/dist/constants.cjs +1 -21
  171. package/dist/constants.d.cts +1 -1
  172. package/dist/constants.d.ts +1 -1
  173. package/dist/constants.js +1 -4
  174. package/dist/engine.cjs +1 -94
  175. package/dist/engine.d.cts +29 -14
  176. package/dist/engine.d.ts +29 -14
  177. package/dist/engine.js +1 -37
  178. package/dist/errors.cjs +1 -105
  179. package/dist/errors.d.cts +3 -3
  180. package/dist/errors.d.ts +3 -3
  181. package/dist/errors.js +1 -4
  182. package/dist/format.cjs +1 -26
  183. package/dist/format.d.cts +2 -2
  184. package/dist/format.d.ts +2 -2
  185. package/dist/format.js +1 -9
  186. package/dist/index.cjs +1 -314
  187. package/dist/index.cjs.map +1 -1
  188. package/dist/index.d.cts +55 -23
  189. package/dist/index.d.ts +55 -23
  190. package/dist/index.js +1 -278
  191. package/dist/index.js.map +1 -1
  192. package/dist/language.cjs +1 -369
  193. package/dist/language.cjs.map +1 -1
  194. package/dist/language.d.cts +12 -13
  195. package/dist/language.d.ts +12 -13
  196. package/dist/language.js +1 -348
  197. package/dist/language.js.map +1 -1
  198. package/dist/lexer.cjs +1 -63
  199. package/dist/lexer.d.cts +3 -3
  200. package/dist/lexer.d.ts +3 -3
  201. package/dist/lexer.js +1 -10
  202. package/dist/normalizer.cjs +1 -39
  203. package/dist/normalizer.d.cts +3 -3
  204. package/dist/normalizer.d.ts +3 -3
  205. package/dist/normalizer.js +1 -10
  206. package/dist/packages.cjs +1 -128
  207. package/dist/packages.d.cts +39 -14
  208. package/dist/packages.d.ts +39 -14
  209. package/dist/packages.js +1 -23
  210. package/dist/parser.cjs +1 -54
  211. package/dist/parser.d.cts +9 -9
  212. package/dist/parser.d.ts +9 -9
  213. package/dist/parser.js +1 -9
  214. package/dist/{pipeline-CtfJtPQc.d.cts → pipeline-72QmQlGx.d.ts} +3 -3
  215. package/dist/{pipeline-DCd5M6Gk.d.ts → pipeline-DCQicwWX.d.cts} +3 -3
  216. package/dist/resolvers.cjs +1 -12
  217. package/dist/resolvers.d.cts +3 -3
  218. package/dist/resolvers.d.ts +3 -3
  219. package/dist/resolvers.js +1 -3
  220. package/dist/services.cjs +1 -20
  221. package/dist/services.js +1 -3
  222. package/dist/testing.cjs +3 -477
  223. package/dist/testing.cjs.map +1 -1
  224. package/dist/testing.d.cts +12 -13
  225. package/dist/testing.d.ts +12 -13
  226. package/dist/testing.js +3 -469
  227. package/dist/testing.js.map +1 -1
  228. package/dist/uom.cjs +1 -55
  229. package/dist/uom.d.cts +3 -3
  230. package/dist/uom.d.ts +3 -3
  231. package/dist/uom.js +1 -10
  232. package/dist/utilities.cjs +1 -36
  233. package/dist/utilities.js +1 -7
  234. package/dist/vm.cjs +1 -295
  235. package/dist/vm.cjs.map +1 -1
  236. package/dist/vm.d.cts +22 -10
  237. package/dist/vm.d.ts +22 -10
  238. package/dist/vm.js +1 -193
  239. package/dist/vm.js.map +1 -1
  240. package/dist/worker.cjs +2 -492
  241. package/dist/worker.cjs.map +1 -1
  242. package/dist/worker.d.cts +19 -20
  243. package/dist/worker.d.ts +19 -20
  244. package/dist/worker.js +2 -483
  245. package/dist/worker.js.map +1 -1
  246. package/package.json +1 -13
  247. package/dist/chunk-267JPOTF.js +0 -406
  248. package/dist/chunk-267JPOTF.js.map +0 -1
  249. package/dist/chunk-2TZKENDH.cjs +0 -448
  250. package/dist/chunk-2TZKENDH.cjs.map +0 -1
  251. package/dist/chunk-3BOK2LDK.js +0 -17
  252. package/dist/chunk-3BOK2LDK.js.map +0 -1
  253. package/dist/chunk-3OWCDIPN.js +0 -215
  254. package/dist/chunk-3OWCDIPN.js.map +0 -1
  255. package/dist/chunk-3VGDNEE3.js +0 -84
  256. package/dist/chunk-3VGDNEE3.js.map +0 -1
  257. package/dist/chunk-4D6NIHE2.js +0 -451
  258. package/dist/chunk-4D6NIHE2.js.map +0 -1
  259. package/dist/chunk-4HQKTMWG.js +0 -7985
  260. package/dist/chunk-4HQKTMWG.js.map +0 -1
  261. package/dist/chunk-536WPM2V.cjs +0 -283
  262. package/dist/chunk-536WPM2V.cjs.map +0 -1
  263. package/dist/chunk-5HRB36DK.js +0 -405
  264. package/dist/chunk-5HRB36DK.js.map +0 -1
  265. package/dist/chunk-5ON7PUAZ.js +0 -12
  266. package/dist/chunk-5ON7PUAZ.js.map +0 -1
  267. package/dist/chunk-7KYSUDQO.js +0 -109
  268. package/dist/chunk-7KYSUDQO.js.map +0 -1
  269. package/dist/chunk-7ZX6B7SY.cjs +0 -3222
  270. package/dist/chunk-7ZX6B7SY.cjs.map +0 -1
  271. package/dist/chunk-ADBA3XBE.cjs +0 -20
  272. package/dist/chunk-ADBA3XBE.cjs.map +0 -1
  273. package/dist/chunk-ALYRJ72W.cjs +0 -434
  274. package/dist/chunk-ALYRJ72W.cjs.map +0 -1
  275. package/dist/chunk-AMOJYLG2.cjs +0 -1692
  276. package/dist/chunk-AMOJYLG2.cjs.map +0 -1
  277. package/dist/chunk-AQNHHJMJ.cjs +0 -261
  278. package/dist/chunk-B4HBEFTB.cjs +0 -375
  279. package/dist/chunk-B4HBEFTB.cjs.map +0 -1
  280. package/dist/chunk-B7LXJ6LC.cjs +0 -36
  281. package/dist/chunk-B7LXJ6LC.cjs.map +0 -1
  282. package/dist/chunk-B7NLZMQ3.cjs +0 -74
  283. package/dist/chunk-B7NLZMQ3.cjs.map +0 -1
  284. package/dist/chunk-BLI4NIQY.js +0 -98
  285. package/dist/chunk-BLI4NIQY.js.map +0 -1
  286. package/dist/chunk-BYJBUL7U.js +0 -499
  287. package/dist/chunk-BYJBUL7U.js.map +0 -1
  288. package/dist/chunk-CCBZZQAE.js +0 -312
  289. package/dist/chunk-CCBZZQAE.js.map +0 -1
  290. package/dist/chunk-CKQMXMHR.cjs +0 -219
  291. package/dist/chunk-CKQMXMHR.cjs.map +0 -1
  292. package/dist/chunk-CUR2WLI4.cjs +0 -507
  293. package/dist/chunk-CUR2WLI4.cjs.map +0 -1
  294. package/dist/chunk-DLEBSLF4.js +0 -336
  295. package/dist/chunk-DLEBSLF4.js.map +0 -1
  296. package/dist/chunk-E23GZEWL.cjs +0 -209
  297. package/dist/chunk-E23GZEWL.cjs.map +0 -1
  298. package/dist/chunk-EJ3ILXX6.cjs +0 -223
  299. package/dist/chunk-EJ3ILXX6.cjs.map +0 -1
  300. package/dist/chunk-ENKKJYD3.js +0 -333
  301. package/dist/chunk-ENKKJYD3.js.map +0 -1
  302. package/dist/chunk-ENRIK36Q.cjs +0 -94
  303. package/dist/chunk-ENRIK36Q.cjs.map +0 -1
  304. package/dist/chunk-ERCOHGXD.js +0 -356
  305. package/dist/chunk-ERCOHGXD.js.map +0 -1
  306. package/dist/chunk-FD5ZZHEU.js +0 -92
  307. package/dist/chunk-FD5ZZHEU.js.map +0 -1
  308. package/dist/chunk-FEAIOR7N.cjs +0 -91
  309. package/dist/chunk-FEAIOR7N.cjs.map +0 -1
  310. package/dist/chunk-GCM5JHMX.js +0 -88
  311. package/dist/chunk-GCM5JHMX.js.map +0 -1
  312. package/dist/chunk-GLA4JXBO.js +0 -204
  313. package/dist/chunk-GLA4JXBO.js.map +0 -1
  314. package/dist/chunk-HIQ5HSZL.cjs +0 -1923
  315. package/dist/chunk-HIQ5HSZL.cjs.map +0 -1
  316. package/dist/chunk-HVRVSI2Z.cjs +0 -829
  317. package/dist/chunk-HVRVSI2Z.cjs.map +0 -1
  318. package/dist/chunk-I4GAWIPW.js +0 -825
  319. package/dist/chunk-I4GAWIPW.js.map +0 -1
  320. package/dist/chunk-J45BCEZ4.cjs +0 -339
  321. package/dist/chunk-J45BCEZ4.cjs.map +0 -1
  322. package/dist/chunk-JG6ZJ2WU.js +0 -1513
  323. package/dist/chunk-JG6ZJ2WU.js.map +0 -1
  324. package/dist/chunk-L2TE7PMO.cjs +0 -14
  325. package/dist/chunk-L2TE7PMO.cjs.map +0 -1
  326. package/dist/chunk-LHZ6VOA7.js +0 -1764
  327. package/dist/chunk-LHZ6VOA7.js.map +0 -1
  328. package/dist/chunk-MN3LHRGV.cjs +0 -8012
  329. package/dist/chunk-MN3LHRGV.cjs.map +0 -1
  330. package/dist/chunk-MVTOCRV2.js +0 -213
  331. package/dist/chunk-MVTOCRV2.js.map +0 -1
  332. package/dist/chunk-N5NNW4VG.cjs +0 -341
  333. package/dist/chunk-N5NNW4VG.cjs.map +0 -1
  334. package/dist/chunk-N7FNVFXW.cjs +0 -32
  335. package/dist/chunk-N7FNVFXW.cjs.map +0 -1
  336. package/dist/chunk-NKW7LKYU.js +0 -3185
  337. package/dist/chunk-NKW7LKYU.js.map +0 -1
  338. package/dist/chunk-NLNDMWZC.js +0 -31
  339. package/dist/chunk-NLNDMWZC.js.map +0 -1
  340. package/dist/chunk-NNQ2TYDF.js +0 -1848
  341. package/dist/chunk-NNQ2TYDF.js.map +0 -1
  342. package/dist/chunk-NNZAEUDW.js +0 -6792
  343. package/dist/chunk-NNZAEUDW.js.map +0 -1
  344. package/dist/chunk-OUHT5Z36.cjs +0 -393
  345. package/dist/chunk-OUHT5Z36.cjs.map +0 -1
  346. package/dist/chunk-QFTDTX6K.cjs +0 -457
  347. package/dist/chunk-QFTDTX6K.cjs.map +0 -1
  348. package/dist/chunk-SBUFNJVE.js +0 -258
  349. package/dist/chunk-SBUFNJVE.js.map +0 -1
  350. package/dist/chunk-SRGQ72IR.cjs +0 -2800
  351. package/dist/chunk-SRGQ72IR.cjs.map +0 -1
  352. package/dist/chunk-SSV46KFA.cjs +0 -112
  353. package/dist/chunk-SSV46KFA.cjs.map +0 -1
  354. package/dist/chunk-T6ZYQJ63.cjs +0 -6807
  355. package/dist/chunk-T6ZYQJ63.cjs.map +0 -1
  356. package/dist/chunk-UKQHXPGW.js +0 -30
  357. package/dist/chunk-UKQHXPGW.js.map +0 -1
  358. package/dist/chunk-UO6BUV6K.js +0 -278
  359. package/dist/chunk-UO6BUV6K.js.map +0 -1
  360. package/dist/chunk-V4XG5QF6.js +0 -1685
  361. package/dist/chunk-V4XG5QF6.js.map +0 -1
  362. package/dist/chunk-VEKIWQ3F.cjs +0 -39
  363. package/dist/chunk-VEKIWQ3F.cjs.map +0 -1
  364. package/dist/chunk-WWQEY7BV.js +0 -67
  365. package/dist/chunk-WWQEY7BV.js.map +0 -1
  366. package/dist/chunk-WXEHD6TT.js +0 -2795
  367. package/dist/chunk-WXEHD6TT.js.map +0 -1
  368. package/dist/chunk-X6K3HUOY.cjs +0 -86
  369. package/dist/chunk-X6K3HUOY.cjs.map +0 -1
  370. package/dist/chunk-XA4CKRML.cjs +0 -316
  371. package/dist/chunk-XA4CKRML.cjs.map +0 -1
  372. package/dist/chunk-XBTEO4OB.js +0 -391
  373. package/dist/chunk-XBTEO4OB.js.map +0 -1
  374. package/dist/chunk-XIYYHA65.cjs +0 -101
  375. package/dist/chunk-XIYYHA65.cjs.map +0 -1
  376. package/dist/chunk-YLJ4XMA6.js +0 -33
  377. package/dist/chunk-YLJ4XMA6.js.map +0 -1
  378. package/dist/chunk-YRIKITGF.cjs +0 -1768
  379. package/dist/chunk-YRIKITGF.cjs.map +0 -1
  380. package/dist/chunk-Z2XP767T.cjs +0 -35
  381. package/dist/chunk-Z2XP767T.cjs.map +0 -1
  382. package/dist/chunk-Z4X2RWOF.js +0 -37
  383. package/dist/chunk-Z4X2RWOF.js.map +0 -1
  384. package/dist/chunk-Z7XGGLI2.js +0 -455
  385. package/dist/chunk-Z7XGGLI2.js.map +0 -1
  386. package/dist/chunk-ZMW6NU2K.cjs +0 -1516
  387. package/dist/chunk-ZMW6NU2K.cjs.map +0 -1
  388. package/dist/chunk-ZVTWQLK4.cjs +0 -459
  389. package/dist/chunk-ZVTWQLK4.cjs.map +0 -1
  390. package/dist/variables.cjs +0 -17
  391. package/dist/variables.cjs.map +0 -1
  392. package/dist/variables.d.cts +0 -87
  393. package/dist/variables.d.ts +0 -87
  394. package/dist/variables.js +0 -4
  395. package/dist/variables.js.map +0 -1
@@ -1,825 +0,0 @@
1
- import { DiagnosticEventType } from './chunk-CCBZZQAE.js';
2
- import { buildBindingPowerTable, BindingPower, bigIntLiteralDigits, BytecodeBuilder } from './chunk-ENKKJYD3.js';
3
- import { tokenTypeId, TokenTypes } from './chunk-4D6NIHE2.js';
4
- import { getLocale } from './chunk-XBTEO4OB.js';
5
- import { ErrorFactory } from './chunk-ERCOHGXD.js';
6
-
7
- // src/parser/registry/ParseletRegistry.ts
8
- function bindingPowersOf(parselet) {
9
- return parselet;
10
- }
11
- var ParseletRegistry = class {
12
- constructor() {
13
- // String-keyed maps (kept for diagnostics + backwards compat)
14
- this.prefixParselets = /* @__PURE__ */ new Map();
15
- this.infixParselets = /* @__PURE__ */ new Map();
16
- // Integer-keyed maps for parser hot path
17
- this.prefixById = /* @__PURE__ */ new Map();
18
- this.infixById = /* @__PURE__ */ new Map();
19
- }
20
- /**
21
- * Register a prefix parselet for `tokenType`.
22
- *
23
- * If another parselet is already registered for this token type, it is
24
- * silently overwritten by default (`Map.set()` semantics), the old
25
- * parselet is simply unreachable from then on, with no error. This is
26
- * a real footgun for third-party packages: two packages independently
27
- * choosing the same custom token type will collide with zero signal
28
- * about which one "won". Mirrors ResolverRegistry.register()'s and
29
- * ExpressionEngine.registerPackage()'s existing "warn and replace"
30
- * pattern for the same class of problem at the resolver-namespace and
31
- * package-name levels.
32
- *
33
- * Note: this warns about registry-level collisions only. It does NOT
34
- * detect the separate case where `tokenType` is one of PrecedenceParser's
35
- * Tier-1 fast-path token types (NUMBER, STRING, IDENT, LPAREN, MINUS,
36
- * PLUS, and the Tier-1 infix operators), those are deliberately kept
37
- * registered here for introspection/diagnostics even though Tier-1
38
- * always intercepts them before this registry is consulted (see
39
- * PrecedenceParser.parsePrefix()'s docs), so warning there would
40
- * misfire on that intentional, already-documented pattern.
41
- */
42
- registerPrefix(tokenType, parselet) {
43
- const existing = this.prefixParselets.get(tokenType);
44
- if (existing && existing !== parselet) {
45
- console.warn(
46
- `[ParseletRegistry] Prefix parselet for token "${tokenType}" is already registered (category: "${existing.category ?? "unknown"}"). Overwriting with a new parselet (category: "${parselet.category ?? "unknown"}") \u2014 the previous parselet is now unreachable. Two packages may be claiming the same token type.`
47
- );
48
- }
49
- this.prefixParselets.set(tokenType, parselet);
50
- this.prefixById.set(tokenTypeId(tokenType), parselet);
51
- }
52
- /** Register an infix parselet for `tokenType`. See {@link registerPrefix} for the collision-warning behavior this mirrors. */
53
- registerInfix(tokenType, parselet) {
54
- const existing = this.infixParselets.get(tokenType);
55
- if (existing && existing !== parselet) {
56
- console.warn(
57
- `[ParseletRegistry] Infix parselet for token "${tokenType}" is already registered (category: "${existing.category ?? "unknown"}"). Overwriting with a new parselet (category: "${parselet.category ?? "unknown"}") \u2014 the previous parselet is now unreachable. Two packages may be claiming the same token type.`
58
- );
59
- }
60
- this.infixParselets.set(tokenType, parselet);
61
- this.infixById.set(tokenTypeId(tokenType), parselet);
62
- }
63
- /**
64
- * Iterate all registered prefix parselets for diagnostic display.
65
- *
66
- * `PrefixParselet` declares no binding power, and this used to read a field
67
- * of that name and report 0 for every one of them. 0 is not a neutral
68
- * wrong answer: it is the value that means "not an operator, stop the
69
- * expression", so a host drawing a table from this was told none of them
70
- * bind at all. A prefix parselet in this parser has no per-parselet power
71
- * to report, they all bind at the prefix level and each chooses for itself
72
- * at what power to parse its own operand, so that level is what is
73
- * reported. A parselet that does carry its own `bindingPower` still wins.
74
- */
75
- getAllPrefix() {
76
- const result = [];
77
- for (const [tokenType, parselet] of this.prefixParselets) {
78
- result.push({
79
- tokenType,
80
- bindingPower: bindingPowersOf(parselet).bindingPower ?? BindingPower.Prefix,
81
- category: parselet.category
82
- });
83
- }
84
- return result;
85
- }
86
- /**
87
- * Iterate all registered infix parselets for diagnostic display.
88
- *
89
- * The field an `InfixParselet` actually declares is `bindingPower`. This
90
- * used to read `leftBindingPower` and `rightBindingPower`, which no
91
- * parselet in this codebase declares, so both reads were `undefined`, both
92
- * fell to the `?? 0` default, and the public `getParseletRegistry()`
93
- * reported a binding power of 0 for every one of the ~60 infix operators.
94
- * A host building a precedence table from it was told `*` and `+` bind
95
- * equally, and that neither binds at all.
96
- *
97
- * The left/right split: `bindingPower` is the LEFT power, and the right is
98
- * one higher. That is the standard encoding for a left-associative
99
- * operator, and it is what the parser itself does, see
100
- * `PrecedenceParser.parseExpression()`'s `bp + 1` for the right operand.
101
- * Every operator is reported that way, `^` included. Associativity is not
102
- * something a parselet declares, it is a property of how each one calls
103
- * `parseExpression`, so this API cannot report it without a new field on
104
- * the interface. See {@link ParseletBindingPowers} for why scraping a
105
- * plausible-looking one off the parselet is worse than not reporting it.
106
- */
107
- getAllInfix() {
108
- const result = [];
109
- for (const [tokenType, parselet] of this.infixParselets) {
110
- const left = bindingPowersOf(parselet).bindingPower ?? 0;
111
- result.push({
112
- tokenType,
113
- leftBindingPower: left,
114
- rightBindingPower: left + 1,
115
- category: parselet.category
116
- });
117
- }
118
- return result;
119
- }
120
- /** Number of registered prefix parselets. */
121
- get prefixCount() {
122
- return this.prefixParselets.size;
123
- }
124
- /** Number of registered infix parselets. */
125
- get infixCount() {
126
- return this.infixParselets.size;
127
- }
128
- /**
129
- * Get prefix parselet by string token type OR integer typeId.
130
- * Fast path for integer IDs (Parser hot path), fallback for strings
131
- * (diagnostics, error messages, backwards compatibility).
132
- */
133
- getPrefix(tokenType) {
134
- if (typeof tokenType === "number") return this.prefixById.get(tokenType);
135
- return this.prefixParselets.get(tokenType);
136
- }
137
- /**
138
- * Get infix parselet by string token type OR integer typeId.
139
- * Fast path for integer IDs (Parser hot path), fallback for strings.
140
- */
141
- getInfix(tokenType) {
142
- if (typeof tokenType === "number") return this.infixById.get(tokenType);
143
- return this.infixParselets.get(tokenType);
144
- }
145
- hasPrefix(tokenType) {
146
- return this.prefixParselets.has(tokenType);
147
- }
148
- hasInfix(tokenType) {
149
- return this.infixParselets.has(tokenType);
150
- }
151
- clear() {
152
- this.prefixParselets.clear();
153
- this.infixParselets.clear();
154
- this.prefixById.clear();
155
- this.infixById.clear();
156
- }
157
- };
158
- var sharedParseletRegistry = new ParseletRegistry();
159
-
160
- // src/parser/PrecedenceParser.ts
161
- var CHAINED_DOT_THOUSANDS_GROUPS = /^\d{1,3}(\.\d{3}){2,}$/;
162
- var PLAIN_DECIMAL = /^\d*\.\d*$/;
163
- var _PrecedenceParser = class _PrecedenceParser {
164
- constructor(parseletRegistry, maxDepth = 50, localeCode = "en") {
165
- this.tokens = [];
166
- this.current = 0;
167
- this.depth = 0;
168
- this.currentExpression = "";
169
- /**
170
- * The binding power the current infix parselet is being invoked at, i.e. the
171
- * `minBp` of the expression it sits inside. Set immediately before each Tier-2
172
- * parselet runs. A parselet that decides whether to swallow a following
173
- * loose operator (UomLiteralParselet with a trailing `in`/`to`) reads this to
174
- * respect precedence it cannot otherwise see: `120 km / 2 hours in kph` must
175
- * group as `(120 km / 2 hours) in kph`, not `120 km / (2 hours in kph)`.
176
- */
177
- this.infixMinBindingPower = 0;
178
- this.registry = parseletRegistry;
179
- this.maxDepth = maxDepth;
180
- this.localeCode = localeCode;
181
- }
182
- /** Get locale code for NumberParselet to normalize separators */
183
- getLocaleCode() {
184
- return this.localeCode;
185
- }
186
- /**
187
- * Set the diagnostic pipeline for parselet matching events.
188
- * Cleared after each non-cached parse to avoid holding refs.
189
- */
190
- setDiagnosticPipeline(pipeline, expression) {
191
- this.diagnosticPipeline = pipeline;
192
- this.currentExpression = expression ?? "";
193
- }
194
- /**
195
- * Load tokens for parsing. Identical to Parser.load().
196
- *
197
- * @param hasParens - if false, skips the O(n) paren balance scan (~90% of expressions)
198
- */
199
- load(tokens, hasParens) {
200
- if (hasParens === false) {
201
- this.tokens = tokens;
202
- this.current = 0;
203
- this.depth = 0;
204
- return;
205
- }
206
- const LPAREN_ID = tokenTypeId(TokenTypes.LPAREN);
207
- const RPAREN_ID = tokenTypeId(TokenTypes.RPAREN);
208
- let openCount = 0;
209
- for (let i = 0; i < tokens.length; i++) {
210
- if (tokens[i].typeId === LPAREN_ID) openCount++;
211
- else if (tokens[i].typeId === RPAREN_ID) openCount--;
212
- }
213
- this.tokens = openCount === 0 ? tokens : this.balanceParens(tokens, openCount);
214
- this.current = 0;
215
- this.depth = 0;
216
- }
217
- /**
218
- * Auto-balance unmatched parentheses.
219
- */
220
- balanceParens(tokens, openCount) {
221
- const result = tokens.slice();
222
- if (openCount > 0) {
223
- const RPAREN_ID = tokenTypeId(TokenTypes.RPAREN);
224
- for (let i = 0; i < openCount; i++) {
225
- const lastToken = tokens[tokens.length - 1];
226
- result.push({
227
- type: TokenTypes.RPAREN,
228
- typeId: RPAREN_ID,
229
- value: ")",
230
- text: ")",
231
- offset: lastToken ? lastToken.offset + lastToken.text.length : 0,
232
- lineBreaks: 0,
233
- line: lastToken ? lastToken.line : 1,
234
- col: lastToken ? lastToken.col + lastToken.text.length : 1
235
- });
236
- }
237
- } else if (openCount < 0) {
238
- const LPAREN_ID = tokenTypeId(TokenTypes.LPAREN);
239
- for (let i = 0; i < -openCount; i++) {
240
- result.unshift({
241
- type: TokenTypes.LPAREN,
242
- typeId: LPAREN_ID,
243
- value: "(",
244
- text: "(",
245
- offset: 0,
246
- lineBreaks: 0,
247
- line: 1,
248
- col: 1
249
- });
250
- }
251
- }
252
- return result;
253
- }
254
- // ═══════════════════════════════════════════════════════════════════════════════
255
- // Main entry point: precedence climbing parse expression
256
- // ═══════════════════════════════════════════════════════════════════════════════
257
- /**
258
- * Parse a full expression starting at the current token position.
259
- *
260
- * @param minBp - minimum binding power (precedence climbing threshold).
261
- * For left-associative operators, the recursive call uses `bp + 1`.
262
- * For right-associative operators (^), it uses `bp - 1`.
263
- * @param _builder - accepted for parselet API compatibility; always uses `this.builder`.
264
- */
265
- parseExpression(minBp = 0, _builder) {
266
- if (_builder) {
267
- this.builder = _builder;
268
- }
269
- this.depth++;
270
- if (this.depth > this.maxDepth) {
271
- this.depth--;
272
- throw ErrorFactory.parsing(
273
- "NESTING_DEPTH_EXCEEDED",
274
- `Parse nesting depth ${this.depth} exceeds maximum of ${this.maxDepth}`,
275
- { maxDepth: this.maxDepth, currentDepth: this.depth }
276
- );
277
- }
278
- const token = this.consume();
279
- if (!token) {
280
- this.depth--;
281
- throw ErrorFactory.parsing("UNEXPECTED_END", "Unexpected end of expression");
282
- }
283
- this.parsePrefix(token);
284
- const tokens = this.tokens;
285
- const len = tokens.length;
286
- const bpTable = _PrecedenceParser.BP_TABLE;
287
- const registry = this.registry;
288
- const builder = this.builder;
289
- let idx = this.current;
290
- while (idx < len) {
291
- const lookahead = tokens[idx];
292
- if (!lookahead) break;
293
- const bp = bpTable[lookahead.typeId];
294
- if (bp > 0) {
295
- if (bp <= minBp) break;
296
- if (this.diagnosticPipeline) {
297
- const infixParselet = registry.getInfix(lookahead.typeId);
298
- if (infixParselet) {
299
- this.fireParseletMatched(infixParselet, lookahead, false, bp);
300
- }
301
- }
302
- this.current = ++idx;
303
- const typeId = lookahead.typeId;
304
- if (typeId === _PrecedenceParser.PERCENT_ID) {
305
- builder.emitOpcode(10 /* PUSH_NUMBER */);
306
- builder.emitNumber(100);
307
- builder.emitOpcode(23 /* DIV */);
308
- builder.emitOpcode(74 /* TO_PERCENTAGE */);
309
- } else if (typeId === _PrecedenceParser.CARET_ID && this.tryEmitMatrixCaretOp(builder)) ; else {
310
- const rightBp = typeId === _PrecedenceParser.CARET_ID ? bp - 1 : bp + 1;
311
- this.parseExpression(rightBp, builder);
312
- builder.emitOpcode(_PrecedenceParser.INFIX_OPCODE[typeId]);
313
- }
314
- } else {
315
- const infixParselet = registry.getInfix(lookahead.typeId);
316
- if (!infixParselet) break;
317
- if (infixParselet.bindingPower <= minBp) break;
318
- this.current = ++idx;
319
- if (this.diagnosticPipeline) {
320
- this.fireParseletMatched(infixParselet, lookahead, false, infixParselet.bindingPower);
321
- }
322
- this.infixMinBindingPower = minBp;
323
- infixParselet.parse(this, token, lookahead, builder);
324
- }
325
- idx = this.current;
326
- }
327
- this.current = idx;
328
- this.depth--;
329
- }
330
- // ═══════════════════════════════════════════════════════════════════════════════
331
- // Prefix dispatch: inline switch for built-ins, parselet registry for plugins
332
- // ═══════════════════════════════════════════════════════════════════════════════
333
- /**
334
- * Parse a prefix token. Built-in tokens (NUMBER, IDENT, LPAREN, etc.) are
335
- * handled inline with zero registry lookup. Everything else falls through
336
- * to the parselet registry (Tier 2).
337
- */
338
- parsePrefix(token) {
339
- const builder = this.builder;
340
- const typeId = token.typeId;
341
- if (this.diagnosticPipeline) {
342
- const parselet = this.registry.getPrefix(typeId);
343
- if (parselet) {
344
- this.fireParseletMatched(parselet, token, true);
345
- }
346
- }
347
- switch (typeId) {
348
- // ── Numeric literals ──────────────────────────────────────────────────
349
- case _PrecedenceParser.NUMBER_ID: {
350
- let v;
351
- let decimalText = null;
352
- const raw = token.value;
353
- if (raw.startsWith("0x") || raw.startsWith("0X")) {
354
- v = parseInt(raw, 16);
355
- if (Number.isNaN(v)) {
356
- throw ErrorFactory.parsing("INVALID_NUMBER_LITERAL", `Invalid hex literal: "${raw}"`, { raw });
357
- }
358
- } else if (raw.startsWith("0b") || raw.startsWith("0B")) {
359
- v = parseInt(raw.slice(2), 2);
360
- if (Number.isNaN(v)) {
361
- throw ErrorFactory.parsing("INVALID_NUMBER_LITERAL", `Invalid binary literal: "${raw}"`, { raw });
362
- }
363
- } else if (raw.startsWith("0o") || raw.startsWith("0O")) {
364
- v = parseInt(raw.slice(2), 8);
365
- if (Number.isNaN(v)) {
366
- throw ErrorFactory.parsing("INVALID_NUMBER_LITERAL", `Invalid octal literal: "${raw}"`, { raw });
367
- }
368
- } else if (CHAINED_DOT_THOUSANDS_GROUPS.test(raw)) {
369
- v = parseFloat(raw.split(".").join(""));
370
- } else {
371
- const locale = getLocale(this.localeCode);
372
- const decimalSep = locale.display.decimalSeparator;
373
- const thousandsSep = locale.display.thousandsSeparator;
374
- let normalized = raw;
375
- if (thousandsSep) {
376
- normalized = normalized.split(thousandsSep).join("");
377
- }
378
- if (decimalSep && decimalSep !== ".") {
379
- normalized = normalized.replace(decimalSep, ".");
380
- }
381
- v = parseFloat(normalized);
382
- if (PLAIN_DECIMAL.test(normalized)) decimalText = normalized;
383
- }
384
- if (decimalText !== null) {
385
- builder.emitOpcode(16 /* PUSH_DECIMAL */);
386
- builder.emitString(decimalText);
387
- return;
388
- }
389
- builder.emitOpcode(10 /* PUSH_NUMBER */);
390
- builder.emitNumber(v);
391
- return;
392
- }
393
- case _PrecedenceParser.BIGINT_ID: {
394
- builder.emitOpcode(11 /* PUSH_BIGINT */);
395
- builder.emitString(bigIntLiteralDigits(token.value, this.localeCode));
396
- return;
397
- }
398
- case _PrecedenceParser.STRING_ID: {
399
- builder.emitOpcode(13 /* PUSH_STRING */);
400
- builder.emitString(token.value);
401
- return;
402
- }
403
- // ── Identifiers (variables) ────────────────────────────────────────────
404
- case _PrecedenceParser.IDENT_ID: {
405
- if (this.peek()?.typeId === _PrecedenceParser.LPAREN_ID) {
406
- this.parseUserFunctionDefOrCall(token, builder);
407
- return;
408
- }
409
- builder.emitOpcode(60 /* LOAD_VAR */);
410
- builder.emitString(token.value);
411
- return;
412
- }
413
- // ── Grouping / bare-tuple vector literal ─────────────────────────────────
414
- // `(expr)` groups for precedence; `(x, y[, z[, w]])` is the bare-tuple
415
- // vector literal documented as an alternative to vec2/vec3/vec4(...)
416
- // (wiki: Arithmetic/Vector). This Tier-1 case is what actually runs for
417
- // every LPAREN in production parsing, GroupParselet.ts mirrors this
418
- // logic for registry-introspection/diagnostic-listing purposes, but a
419
- // package can never override LPAREN's dispatch here (Tier 1 always
420
- // wins over the ParseletRegistry fallback below), so both must be kept
421
- // in sync by hand.
422
- case _PrecedenceParser.LPAREN_ID: {
423
- this.parseExpression(0, builder);
424
- let count = 1;
425
- while (this.match(TokenTypes.COMMA)) {
426
- this.parseExpression(0, builder);
427
- count++;
428
- }
429
- this.consume(TokenTypes.RPAREN);
430
- if (count > 1) {
431
- builder.emitOpcode(152 /* MAT_NEW */);
432
- builder.emitIndex(1);
433
- builder.emitIndex(count);
434
- }
435
- return;
436
- }
437
- // ── Unary operators ───────────────────────────────────────────────────
438
- case _PrecedenceParser.MINUS_ID: {
439
- this.parseExpression(BindingPower.Prefix, builder);
440
- builder.emitOpcode(26 /* NEG */);
441
- return;
442
- }
443
- case _PrecedenceParser.PLUS_ID: {
444
- this.parseExpression(BindingPower.Prefix, builder);
445
- builder.emitOpcode(27 /* POS */);
446
- return;
447
- }
448
- // ── Keyword constants ─────────────────────────────────────────────────
449
- case _PrecedenceParser.KEYWORD_ID: }
450
- const prefixParselet = this.registry.getPrefix(typeId);
451
- if (!prefixParselet) {
452
- throw ErrorFactory.parsing(
453
- "NO_PREFIX_PARSELET",
454
- `No prefix parselet found for token: ${token.type} ("${token.value}")`,
455
- { tokenType: token.type, tokenValue: token.value }
456
- );
457
- }
458
- prefixParselet.parse(this, token, builder);
459
- }
460
- /**
461
- * After a `^` token (already consumed by the Tier-1 infix loop above),
462
- * checks {@link CARET_SUFFIX_RULES} in order for a shape that means
463
- * something other than ordinary exponentiation: `^T` (transpose) and `^-1`
464
- * (matrix inverse, LITERALLY the integer exponent `-1`; `^-2`, `^-1.5`
465
- * etc. still mean ordinary exponentiation). On a match, the rule's `emit`
466
- * consumes that shape's own tokens and this returns `true`. On no match,
467
- * consumes NOTHING, returning `false` so the caller falls through to
468
- * ordinary `EXP` parsing.
469
- *
470
- * Every rule dispatches purely on SHAPE, never on operand type (unknowable
471
- * at parse time): `inv()`'s own handler (`VMBuiltins.ts` index 65) returns
472
- * `1/x` for a plain Number, byte-identical to what `Math.pow(x, -1)`
473
- * already computed for `x^-1` before this feature existed, and a real
474
- * matrix inverse for a Matrix, so `5^-1` still means exactly what it always
475
- * has; only a Matrix operand actually inverts.
476
- *
477
- * Adding a future `^`-suffix shape is a new table entry here, not a new
478
- * if-block. See the "Tier-1 shape-exception" pattern write-up above for
479
- * why this table can't instead be a package-registered parselet.
480
- */
481
- tryEmitMatrixCaretOp(builder) {
482
- for (const rule of _PrecedenceParser.CARET_SUFFIX_RULES) {
483
- if (rule.matches(this)) {
484
- rule.emit(this, builder);
485
- return true;
486
- }
487
- }
488
- return false;
489
- }
490
- // ═══════════════════════════════════════════════════════════════════════════════
491
- // User-defined, parameterized, reusable functions (f(x) = 2*x + 1, then f(5))
492
- // ═══════════════════════════════════════════════════════════════════════════════
493
- /**
494
- * From an LPAREN token index, scan forward tracking paren depth and
495
- * return the index of the matching RPAREN, or `null` if the parens never
496
- * balance before the token stream ends. No emission, no position
497
- * advance. Same class of technique as {@link balanceParens}'s own
498
- * pre-scan, just exposed mid-parse instead of only at `load()` time.
499
- * `openIdx` must point AT the LPAREN itself.
500
- */
501
- findMatchingRParen(openIdx) {
502
- let depth = 0;
503
- for (let i = openIdx; i < this.tokens.length; i++) {
504
- const t = this.tokens[i];
505
- if (t.typeId === _PrecedenceParser.LPAREN_ID) depth++;
506
- else if (t.typeId === _PrecedenceParser.RPAREN_ID) {
507
- depth--;
508
- if (depth === 0) return i;
509
- }
510
- }
511
- return null;
512
- }
513
- /**
514
- * Disambiguates a bare `IDENT` immediately followed by `(` between three
515
- * things, using ONLY a bracket-depth scan (no backtracking, nothing is
516
- * consumed until the shape is known):
517
- * - `f(x) = expr`, a DEFINITION: the matching `)` is followed by `=`.
518
- * - `f(5)`, a CALL to a (possibly not-yet-defined) function: anything
519
- * else. This was never valid syntax before this feature (a bare
520
- * `IDENT` immediately before `(` has no pre-existing "plain variable
521
- * read + separately grouped `(...)`" meaning to preserve, confirmed
522
- * via `BuiltinNormalizerRules.ts`'s `implicitMultiplyRule()`, which
523
- * only inserts an implicit `*` for `NUMBER/RPAREN` immediately before
524
- * `IDENT/LPAREN`, never for a bare `IDENT` immediately before
525
- * `LPAREN`). Always commits to a CALL; an unregistered name produces a
526
- * clear `UNDEFINED_FUNCTION` error at VM-execution time, the same
527
- * forward-reference philosophy `LOAD_VAR`/`UNDEFINED_VARIABLE` already
528
- * uses, rather than any parse-time registry lookup.
529
- * If the parens never balance, this falls through to the ordinary
530
- * `LOAD_VAR` path (a malformed expression surfaces its own parse error
531
- * shortly after, from the normal expression grammar).
532
- */
533
- parseUserFunctionDefOrCall(nameToken, builder) {
534
- const closeIdx = this.findMatchingRParen(this.current);
535
- if (closeIdx === null) {
536
- builder.emitOpcode(60 /* LOAD_VAR */);
537
- builder.emitString(nameToken.value);
538
- return;
539
- }
540
- const afterClose = this.tokens[closeIdx + 1];
541
- if (afterClose?.type === TokenTypes.EQUALS) {
542
- this.parseUserFunctionDefinition(nameToken, builder);
543
- } else {
544
- this.parseUserFunctionCall(nameToken, builder);
545
- }
546
- }
547
- /**
548
- * A parameter name, accepted as either `IDENT` or `UNIT`, matches this
549
- * codebase's established `:name = value` variable-name policy
550
- * (`VariableParselet.ts` explicitly accepts `UNIT`-typed tokens too, e.g.
551
- * `:b = 5` for the "b" bits unit) since common short parameter names
552
- * like `h`/`l`/`b`/`t`/`s`/`m` collide with real unit abbreviations
553
- * (hour, liter, bits, ton, second, meter, ...) and lex as `UNIT`, not
554
- * `IDENT`.
555
- */
556
- consumeParamName() {
557
- const token = this.peek();
558
- if (token?.type === TokenTypes.IDENT || token?.type === TokenTypes.UNIT) {
559
- this.consume();
560
- return token.value;
561
- }
562
- throw ErrorFactory.parsing(
563
- "USER_FUNCTION_INVALID_PARAM_NAME",
564
- `Expected a parameter name but got "${token?.type ?? "end of input"}"${token ? ` ("${token.value}")` : ""}`,
565
- { actualType: token?.type }
566
- );
567
- }
568
- parseUserFunctionDefinition(nameToken, builder) {
569
- this.consume(TokenTypes.LPAREN);
570
- const params = [];
571
- if (this.peek()?.type !== TokenTypes.RPAREN) {
572
- params.push(this.consumeParamName());
573
- while (this.match(TokenTypes.COMMA)) {
574
- params.push(this.consumeParamName());
575
- }
576
- }
577
- this.consume(TokenTypes.RPAREN);
578
- this.consume(TokenTypes.EQUALS);
579
- if (params.length === 0) {
580
- throw ErrorFactory.parsing(
581
- "USER_FUNCTION_NO_PARAMS",
582
- `"${nameToken.value}()" has no parameters -- user-defined functions need at least one (a zero-argument definition is indistinguishable from a plain function CALL with no args, which this grammar doesn't otherwise support)`,
583
- { name: nameToken.value }
584
- );
585
- }
586
- const bodyBuilder = new BytecodeBuilder();
587
- this.parseExpression(BindingPower.Lowest, bodyBuilder);
588
- this.setBuilder(builder);
589
- const bodyProgram = bodyBuilder.build();
590
- if (bodyProgram.hasAsync) {
591
- throw ErrorFactory.parsing(
592
- "FUNCTION_BODY_MUST_BE_SYNCHRONOUS",
593
- `"${nameToken.value}(...)"'s body calls an async operation (weather, stocks, currency, ...) \u2014 user-defined function bodies must be synchronous`,
594
- { name: nameToken.value }
595
- );
596
- }
597
- const bodyIdx = builder.emitUserFunctionBody(nameToken.value, params, bodyProgram);
598
- builder.emitOpcode(150 /* DEFINE_USER_FUNCTION */);
599
- builder.emitIndex(bodyIdx);
600
- builder.emitOpcode(13 /* PUSH_STRING */);
601
- builder.emitString(`${nameToken.value}(${params.join(", ")}) defined`);
602
- }
603
- parseUserFunctionCall(nameToken, builder) {
604
- this.consume(TokenTypes.LPAREN);
605
- let argCount = 0;
606
- if (this.peek()?.type !== TokenTypes.RPAREN) {
607
- this.parseExpression(BindingPower.Lowest, builder);
608
- argCount++;
609
- while (this.match(TokenTypes.COMMA)) {
610
- this.parseExpression(BindingPower.Lowest, builder);
611
- argCount++;
612
- }
613
- }
614
- this.consume(TokenTypes.RPAREN);
615
- builder.emitOpcode(151 /* CALL_USER_FUNCTION */);
616
- builder.emitString(nameToken.value);
617
- builder.emitByte(argCount);
618
- }
619
- // ═══════════════════════════════════════════════════════════════════════════════
620
- // Token stream navigation (identical API to Parser)
621
- // ═══════════════════════════════════════════════════════════════════════════════
622
- consume(expectedType) {
623
- const token = this.tokens[this.current];
624
- if (!token) {
625
- throw ErrorFactory.parsing(
626
- "UNEXPECTED_END_OF_INPUT",
627
- "Unexpected end of input"
628
- );
629
- }
630
- if (expectedType !== void 0) {
631
- const expectedId = tokenTypeId(expectedType);
632
- if (token.typeId !== expectedId) {
633
- throw ErrorFactory.parsing(
634
- "UNEXPECTED_TOKEN_TYPE",
635
- `Expected token type "${expectedType}" but got "${token.type}" ("${token.value}")`,
636
- { expectedType, actualType: token.type, actualValue: token.value }
637
- );
638
- }
639
- }
640
- this.current++;
641
- return token;
642
- }
643
- match(expectedType) {
644
- const token = this.peek();
645
- if (token && token.typeId === tokenTypeId(expectedType)) {
646
- this.advance();
647
- return true;
648
- }
649
- return false;
650
- }
651
- peek() {
652
- return this.tokens[this.current];
653
- }
654
- /**
655
- * Read-only lookahead `offset` tokens past the current position, without
656
- * consuming anything, `peekAt(0)` is equivalent to {@link peek}.
657
- * `this.tokens` is a plain in-memory array (not a stream), so this is a
658
- * simple, safe index read; no rewind/checkpoint mechanism is needed since
659
- * nothing is consumed.
660
- */
661
- peekAt(offset) {
662
- return this.tokens[this.current + offset];
663
- }
664
- previous() {
665
- return this.current > 0 ? this.tokens[this.current - 1] : void 0;
666
- }
667
- advance() {
668
- this.current++;
669
- }
670
- // ═══════════════════════════════════════════════════════════════════════════════
671
- // Builder access, set before parse, read by inline prefix handlers
672
- // ═══════════════════════════════════════════════════════════════════════════════
673
- /** Set the builder to use for the current parse. Called by ExpressionEngine. */
674
- setBuilder(builder) {
675
- this.builder = builder;
676
- }
677
- // ═══════════════════════════════════════════════════════════════════════════════
678
- // Diagnostics
679
- // ═══════════════════════════════════════════════════════════════════════════════
680
- fireParseletMatched(parselet, token, isPrefix, bindingPower) {
681
- const pipeline = this.diagnosticPipeline;
682
- const event = {
683
- type: DiagnosticEventType.ParseletMatched,
684
- elapsedNs: 0,
685
- expression: this.currentExpression,
686
- tokenType: token.type,
687
- tokenValue: token.value,
688
- parseletCategory: parselet.category,
689
- parseletType: parselet.constructor?.name ?? "unknown",
690
- isPrefix,
691
- bindingPower,
692
- tokenOffset: token.offset || 0
693
- };
694
- pipeline.fireParseletMatched(event);
695
- }
696
- };
697
- /**
698
- * Static binding power table, built once at module load, shared across all instances.
699
- * Index = tokenTypeId, value = binding power (0 = not a built-in infix).
700
- */
701
- _PrecedenceParser.BP_TABLE = buildBindingPowerTable();
702
- // ── Pre-computed token type IDs for inline dispatch ────────────────────────
703
- // Prefix built-ins
704
- _PrecedenceParser.NUMBER_ID = tokenTypeId(TokenTypes.NUMBER);
705
- _PrecedenceParser.BIGINT_ID = tokenTypeId(TokenTypes.BIGINT);
706
- _PrecedenceParser.STRING_ID = tokenTypeId(TokenTypes.STRING);
707
- _PrecedenceParser.IDENT_ID = tokenTypeId(TokenTypes.IDENT);
708
- _PrecedenceParser.LPAREN_ID = tokenTypeId(TokenTypes.LPAREN);
709
- _PrecedenceParser.RPAREN_ID = tokenTypeId(TokenTypes.RPAREN);
710
- _PrecedenceParser.MINUS_ID = tokenTypeId(TokenTypes.MINUS);
711
- _PrecedenceParser.PLUS_ID = tokenTypeId(TokenTypes.PLUS);
712
- _PrecedenceParser.KEYWORD_ID = tokenTypeId(TokenTypes.KEYWORD);
713
- // Infix built-ins (Tier 1, full inline emission)
714
- _PrecedenceParser.STAR_ID = tokenTypeId(TokenTypes.STAR);
715
- _PrecedenceParser.SLASH_ID = tokenTypeId(TokenTypes.SLASH);
716
- _PrecedenceParser.MOD_ID = tokenTypeId(TokenTypes.MOD);
717
- _PrecedenceParser.CARET_ID = tokenTypeId(TokenTypes.CARET);
718
- _PrecedenceParser.LSHIFT_ID = tokenTypeId(TokenTypes.LSHIFT);
719
- _PrecedenceParser.RSHIFT_ID = tokenTypeId(TokenTypes.RSHIFT);
720
- _PrecedenceParser.URSHIFT_ID = tokenTypeId(TokenTypes.URSHIFT);
721
- _PrecedenceParser.BIT_AND_ID = tokenTypeId(TokenTypes.BIT_AND);
722
- _PrecedenceParser.BIT_OR_ID = tokenTypeId(TokenTypes.BIT_OR);
723
- _PrecedenceParser.BIT_XOR_ID = tokenTypeId(TokenTypes.BIT_XOR);
724
- _PrecedenceParser.PERCENT_ID = tokenTypeId(TokenTypes.PERCENT);
725
- _PrecedenceParser.OF_ID = tokenTypeId(TokenTypes.OF);
726
- /**
727
- * Inline opcode map for Tier 1 infix operators.
728
- * tokenTypeId → OpCode. PERCENT and CARET are handled specially (not in this map).
729
- */
730
- _PrecedenceParser.INFIX_OPCODE = {
731
- [tokenTypeId(TokenTypes.PLUS)]: 20 /* ADD */,
732
- [tokenTypeId(TokenTypes.MINUS)]: 21 /* SUB */,
733
- [tokenTypeId(TokenTypes.STAR)]: 22 /* MUL */,
734
- [tokenTypeId(TokenTypes.SLASH)]: 23 /* DIV */,
735
- [tokenTypeId(TokenTypes.MOD)]: 24 /* MOD */,
736
- [tokenTypeId(TokenTypes.CARET)]: 25 /* EXP */,
737
- [tokenTypeId(TokenTypes.LSHIFT)]: 30 /* LSHIFT */,
738
- [tokenTypeId(TokenTypes.RSHIFT)]: 31 /* RSHIFT */,
739
- [tokenTypeId(TokenTypes.URSHIFT)]: 32 /* URSHIFT */,
740
- [tokenTypeId(TokenTypes.BIT_AND)]: 33 /* BIT_AND */,
741
- [tokenTypeId(TokenTypes.BIT_OR)]: 34 /* BIT_OR */,
742
- [tokenTypeId(TokenTypes.BIT_XOR)]: 35 /* BIT_XOR */,
743
- [tokenTypeId(TokenTypes.OF)]: 22 /* MUL */
744
- };
745
- // ═══════════════════════════════════════════════════════════════════════════════
746
- // The "Tier-1 shape-exception" pattern
747
- // ═══════════════════════════════════════════════════════════════════════════════
748
- //
749
- // Tier 1 exists purely for performance, avoid a Map lookup + parselet call
750
- // on ~95% of tokens (see this file's own module doc comment above). A
751
- // recurring consequence: any grammar shape tied to a Tier-1 token type can
752
- // ONLY be implemented by hand-editing this switch, since a package-
753
- // registered ParseletRegistry parselet for that same token type would
754
- // simply never run in production (Tier 1 always wins over the registry
755
- // fallback). Five confirmed instances of this tension exist in this file
756
- // (plus one that had to move OUTSIDE it entirely):
757
- // 1. NUMBER_ID, the full locale-aware number-literal parsing (hex/
758
- // binary/octal, chained-dot thousands grouping, decimal-separator
759
- // normalization) is inlined in parsePrefix() above; NumberParselet.ts's
760
- // own copy is dead code for real evaluation, kept registered only for
761
- // the "matched parselets" diagnostic view.
762
- // 2. IDENT_ID, parseUserFunctionDefOrCall's lookahead (below) disambig-
763
- // uates a function DEFINITION from a CALL from a plain variable load.
764
- // 3. LPAREN_ID, the bare-tuple vector-literal sugar ("(x,y[,z[,w]])" ->
765
- // MAT_NEW) is inlined in parsePrefix() above; GroupParselet.ts mirrors
766
- // it for introspection only and must be kept in sync by hand.
767
- // 4. CARET_ID, the transpose/inverse suffix table just below.
768
- // 5. PLUS_ID, the locale word "and" lexes as PLUS (Tier-1, fixed Sum
769
- // binding power), so a registry parselet can never intercept it the
770
- // way LogicalParselet.ts intercepts "or"/&&/||; unlike the other four,
771
- // there's no SHAPE to special-case on here (the token itself IS the
772
- // operator), so the workaround lives entirely outside this file, as a
773
- // runtime Boolean/Boolean type-check inside vm/VM.ts's OpCode.ADD
774
- // handler instead.
775
- //
776
- // Deliberate non-goal: none of this is exposed as an IEnginePackage
777
- // extension point (unlike prefixParselets/infixParselets). Letting
778
- // third-party packages register their own Tier-1 shape-matchers would put
779
- // per-package matcher iteration on a genuinely hot path (every CARET/
780
- // NUMBER/IDENT/LPAREN/PLUS token, matched or not), a materially bigger
781
- // separate product decision than "make this one table more concise," and
782
- // not one this pattern write-up makes.
783
- /**
784
- * A single `^`-suffix shape: `matches` peeks ahead (consuming nothing) to
785
- * check whether this shape starts at the current position; `emit` is only
786
- * called immediately after `matches` returned true for that SAME position,
787
- * and is responsible for consuming that shape's own trailing tokens and
788
- * emitting its bytecode.
789
- */
790
- _PrecedenceParser.CARET_SUFFIX_RULES = [
791
- {
792
- name: "transpose (^T)",
793
- matches: (p) => {
794
- const next = p.peek();
795
- return next?.type === TokenTypes.IDENT && next.value === "T";
796
- },
797
- emit: (p, builder) => {
798
- p.advance();
799
- builder.emitOpcode(51 /* CALL_BUILTIN */);
800
- builder.emitIndex(63);
801
- builder.emitIndex(1);
802
- }
803
- },
804
- {
805
- name: "inverse (^-1)",
806
- matches: (p) => {
807
- const next = p.peek();
808
- if (next?.typeId !== _PrecedenceParser.MINUS_ID) return false;
809
- const afterMinus = p.peekAt(1);
810
- return afterMinus?.type === TokenTypes.NUMBER && afterMinus.value === "1";
811
- },
812
- emit: (p, builder) => {
813
- p.advance();
814
- p.advance();
815
- builder.emitOpcode(51 /* CALL_BUILTIN */);
816
- builder.emitIndex(65);
817
- builder.emitIndex(1);
818
- }
819
- }
820
- ];
821
- var PrecedenceParser = _PrecedenceParser;
822
-
823
- export { ParseletRegistry, PrecedenceParser, sharedParseletRegistry };
824
- //# sourceMappingURL=chunk-I4GAWIPW.js.map
825
- //# sourceMappingURL=chunk-I4GAWIPW.js.map