solve-engine 1.2.0 → 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 (384) 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-CNA_rHY-.d.cts → EngineError-Ce1lPkjZ.d.cts} +2 -0
  7. package/dist/{EngineError-CNA_rHY-.d.ts → EngineError-Ce1lPkjZ.d.ts} +2 -0
  8. package/dist/{PackageCompatibility-B6NX9IaN.d.cts → PackageCompatibility-Bn5jnBtA.d.cts} +2 -2
  9. package/dist/{PackageCompatibility-Ceg5XdAp.d.ts → PackageCompatibility-CIvq2MP5.d.ts} +2 -2
  10. package/dist/{PackageRegistry-DrCPQNyy.d.ts → PackageRegistry-DzeiWcv4.d.ts} +93 -172
  11. package/dist/{PackageRegistry-DnJYVw9G.d.cts → PackageRegistry-dpdurBVO.d.cts} +93 -172
  12. package/dist/{Parselet-Bhf7d0_W.d.ts → Parselet-B-zoPrTa.d.ts} +8 -5
  13. package/dist/{Parselet-Cv7S7KRt.d.cts → Parselet-C4Wu055_.d.cts} +8 -5
  14. package/dist/{ScopeManager-Bzq87GfA.d.ts → ScopeManager-C2LDOrDx.d.ts} +7 -16
  15. package/dist/{ScopeManager-DRDBVfan.d.cts → ScopeManager-D7uMXbhS.d.cts} +7 -16
  16. package/dist/{VMCheckpoints-C6c17Hbo.d.ts → VMCheckpoints-CGyFhivM.d.ts} +3 -3
  17. package/dist/{VMCheckpoints-dZxSMGHG.d.cts → VMCheckpoints-I9jg3jWR.d.cts} +3 -3
  18. package/dist/{Value-DZNQ_PU7.d.cts → Value-CCi_Eecs.d.cts} +40 -0
  19. package/dist/{Value-DZNQ_PU7.d.ts → Value-CCi_Eecs.d.ts} +40 -0
  20. package/dist/{WorkerError-Djd7GGGa.d.cts → WorkerError-B4p6PNfx.d.cts} +1 -1
  21. package/dist/{WorkerError-B7t7R2-m.d.ts → WorkerError-Dhj9BQ_A.d.ts} +1 -1
  22. package/dist/chunk-2JMFUQZH.js +2 -0
  23. package/dist/chunk-2JMFUQZH.js.map +1 -0
  24. package/dist/chunk-2RWAXT6O.js +0 -1
  25. package/dist/chunk-4BZIYU7S.cjs +3 -0
  26. package/dist/chunk-4BZIYU7S.cjs.map +1 -0
  27. package/dist/chunk-4J7XZSZJ.cjs +5 -0
  28. package/dist/chunk-4J7XZSZJ.cjs.map +1 -0
  29. package/dist/chunk-4QVBSG6B.cjs +2 -0
  30. package/dist/chunk-4QVBSG6B.cjs.map +1 -0
  31. package/dist/chunk-5IJD5L3O.cjs +2 -0
  32. package/dist/chunk-5IJD5L3O.cjs.map +1 -0
  33. package/dist/chunk-62LMTO4F.js +2 -0
  34. package/dist/chunk-62LMTO4F.js.map +1 -0
  35. package/dist/chunk-6CY44ZPG.js +2 -0
  36. package/dist/chunk-6CY44ZPG.js.map +1 -0
  37. package/dist/chunk-6G3PMEPA.js +2 -0
  38. package/dist/chunk-6G3PMEPA.js.map +1 -0
  39. package/dist/chunk-6INX773F.cjs +2 -0
  40. package/dist/chunk-6INX773F.cjs.map +1 -0
  41. package/dist/chunk-6KFVG6UY.cjs +2 -0
  42. package/dist/{chunk-YJHY7CMN.cjs.map → chunk-6KFVG6UY.cjs.map} +1 -1
  43. package/dist/chunk-76F3LCIL.js +4 -0
  44. package/dist/chunk-76F3LCIL.js.map +1 -0
  45. package/dist/chunk-7GK3XEZF.js +2 -0
  46. package/dist/chunk-7GK3XEZF.js.map +1 -0
  47. package/dist/chunk-APN442VD.cjs +2 -0
  48. package/dist/chunk-APN442VD.cjs.map +1 -0
  49. package/dist/chunk-AXMQG5TS.cjs +2 -0
  50. package/dist/chunk-AXMQG5TS.cjs.map +1 -0
  51. package/dist/chunk-CIQOK7Q4.cjs +2 -0
  52. package/dist/chunk-CIQOK7Q4.cjs.map +1 -0
  53. package/dist/chunk-E6Z4NQAS.js +2 -0
  54. package/dist/chunk-E6Z4NQAS.js.map +1 -0
  55. package/dist/chunk-EFJCC6FJ.cjs +2 -0
  56. package/dist/chunk-EFJCC6FJ.cjs.map +1 -0
  57. package/dist/chunk-ESUN2THE.cjs +2 -0
  58. package/dist/chunk-ESUN2THE.cjs.map +1 -0
  59. package/dist/chunk-EVAOPEO4.js +2 -0
  60. package/dist/chunk-EVAOPEO4.js.map +1 -0
  61. package/dist/chunk-EYRBENHC.js +3 -0
  62. package/dist/chunk-EYRBENHC.js.map +1 -0
  63. package/dist/chunk-FDE5HWDI.cjs +2 -0
  64. package/dist/chunk-FDE5HWDI.cjs.map +1 -0
  65. package/dist/chunk-FWW3M36J.cjs +2 -0
  66. package/dist/chunk-FWW3M36J.cjs.map +1 -0
  67. package/dist/chunk-GOIQYUWV.js +2 -0
  68. package/dist/chunk-GOIQYUWV.js.map +1 -0
  69. package/dist/chunk-HFKDWQUL.js +2 -0
  70. package/dist/chunk-HFKDWQUL.js.map +1 -0
  71. package/dist/chunk-HLBYHXQD.cjs +3 -0
  72. package/dist/chunk-HLBYHXQD.cjs.map +1 -0
  73. package/dist/chunk-IANAMBJQ.cjs +2 -0
  74. package/dist/chunk-IANAMBJQ.cjs.map +1 -0
  75. package/dist/chunk-IJMNVBIS.js +2 -0
  76. package/dist/chunk-IJMNVBIS.js.map +1 -0
  77. package/dist/chunk-J4LZD4ZY.js +3 -0
  78. package/dist/chunk-J4LZD4ZY.js.map +1 -0
  79. package/dist/chunk-JAK3RAFA.cjs +2 -0
  80. package/dist/chunk-JAK3RAFA.cjs.map +1 -0
  81. package/dist/chunk-JFAJN3C2.cjs +2 -0
  82. package/dist/chunk-JFAJN3C2.cjs.map +1 -0
  83. package/dist/chunk-JPFCXLJV.js +2 -0
  84. package/dist/chunk-JPFCXLJV.js.map +1 -0
  85. package/dist/chunk-JSPKKNPQ.js +3 -0
  86. package/dist/chunk-JSPKKNPQ.js.map +1 -0
  87. package/dist/chunk-L3FPQSGN.js +2 -0
  88. package/dist/chunk-L3FPQSGN.js.map +1 -0
  89. package/dist/chunk-LR4E4A4W.cjs +2 -0
  90. package/dist/chunk-LR4E4A4W.cjs.map +1 -0
  91. package/dist/chunk-MIQBJGGR.js +2 -0
  92. package/dist/chunk-MIQBJGGR.js.map +1 -0
  93. package/dist/chunk-MPB7KUN5.js +3 -0
  94. package/dist/chunk-MPB7KUN5.js.map +1 -0
  95. package/dist/chunk-MSYX32PF.cjs +2 -0
  96. package/dist/chunk-MSYX32PF.cjs.map +1 -0
  97. package/dist/chunk-MVZUTETT.js +2 -0
  98. package/dist/chunk-MVZUTETT.js.map +1 -0
  99. package/dist/chunk-N7N7MPMK.cjs +2 -0
  100. package/dist/chunk-N7N7MPMK.cjs.map +1 -0
  101. package/dist/chunk-NGBBNL4K.cjs +1 -3
  102. package/dist/chunk-P6WPEUAJ.cjs +2 -0
  103. package/dist/chunk-P6WPEUAJ.cjs.map +1 -0
  104. package/dist/chunk-PS272DZJ.cjs +2 -0
  105. package/dist/chunk-PS272DZJ.cjs.map +1 -0
  106. package/dist/chunk-QXQE7X4S.js +2 -0
  107. package/dist/chunk-QXQE7X4S.js.map +1 -0
  108. package/dist/chunk-R2ENWQ76.js +2 -0
  109. package/dist/chunk-R2ENWQ76.js.map +1 -0
  110. package/dist/chunk-R2SZFJTT.cjs +2 -0
  111. package/dist/chunk-R2SZFJTT.cjs.map +1 -0
  112. package/dist/chunk-RAF57WYO.js +2 -0
  113. package/dist/chunk-RAF57WYO.js.map +1 -0
  114. package/dist/chunk-RSF25YSJ.js +2 -0
  115. package/dist/chunk-RSF25YSJ.js.map +1 -0
  116. package/dist/chunk-SOMGSIO4.cjs +3 -0
  117. package/dist/chunk-SOMGSIO4.cjs.map +1 -0
  118. package/dist/chunk-SUXRZWH2.cjs +3 -0
  119. package/dist/chunk-SUXRZWH2.cjs.map +1 -0
  120. package/dist/chunk-SYYE3QAX.cjs +2 -0
  121. package/dist/chunk-SYYE3QAX.cjs.map +1 -0
  122. package/dist/chunk-SZGK6RIP.cjs +2 -0
  123. package/dist/chunk-SZGK6RIP.cjs.map +1 -0
  124. package/dist/chunk-TCZSPH4A.js +2 -0
  125. package/dist/chunk-TCZSPH4A.js.map +1 -0
  126. package/dist/chunk-TLG7VZRX.cjs +2 -0
  127. package/dist/chunk-TLG7VZRX.cjs.map +1 -0
  128. package/dist/chunk-TRBXW6HW.js +2 -0
  129. package/dist/{chunk-AQNHHJMJ.cjs.map → chunk-TRBXW6HW.js.map} +1 -1
  130. package/dist/chunk-TTFO4YDP.cjs +2 -0
  131. package/dist/chunk-TTFO4YDP.cjs.map +1 -0
  132. package/dist/chunk-TWC7K3ZX.js +2 -0
  133. package/dist/chunk-TWC7K3ZX.js.map +1 -0
  134. package/dist/chunk-UDQ57ZRX.cjs +2 -0
  135. package/dist/chunk-UDQ57ZRX.cjs.map +1 -0
  136. package/dist/chunk-UI6IFGBT.js +2 -0
  137. package/dist/chunk-UI6IFGBT.js.map +1 -0
  138. package/dist/chunk-UURM7P3P.cjs +4 -0
  139. package/dist/chunk-UURM7P3P.cjs.map +1 -0
  140. package/dist/chunk-W2JAR233.js +2 -0
  141. package/dist/chunk-W2JAR233.js.map +1 -0
  142. package/dist/chunk-WGZ3FNHI.js +2 -0
  143. package/dist/chunk-WGZ3FNHI.js.map +1 -0
  144. package/dist/chunk-WN5CMP4T.cjs +3 -0
  145. package/dist/chunk-WN5CMP4T.cjs.map +1 -0
  146. package/dist/chunk-XEIDV5JP.js +2 -0
  147. package/dist/chunk-XEIDV5JP.js.map +1 -0
  148. package/dist/chunk-XNIWQHXY.js +2 -0
  149. package/dist/chunk-XNIWQHXY.js.map +1 -0
  150. package/dist/chunk-XR7HEC7B.js +5 -0
  151. package/dist/chunk-XR7HEC7B.js.map +1 -0
  152. package/dist/chunk-Y7O4D3BJ.cjs +2 -0
  153. package/dist/chunk-Y7O4D3BJ.cjs.map +1 -0
  154. package/dist/chunk-YAYBVVG2.js +3 -0
  155. package/dist/chunk-YAYBVVG2.js.map +1 -0
  156. package/dist/chunk-YJ2OPULK.js +2 -0
  157. package/dist/chunk-YJ2OPULK.js.map +1 -0
  158. package/dist/chunk-YVKHEAFT.js +2 -0
  159. package/dist/chunk-YVKHEAFT.js.map +1 -0
  160. package/dist/chunk-ZCNBT44X.cjs +2 -0
  161. package/dist/chunk-ZCNBT44X.cjs.map +1 -0
  162. package/dist/chunk-ZLRJ7TDP.cjs +2 -0
  163. package/dist/chunk-ZLRJ7TDP.cjs.map +1 -0
  164. package/dist/constants.cjs +1 -21
  165. package/dist/constants.d.cts +1 -1
  166. package/dist/constants.d.ts +1 -1
  167. package/dist/constants.js +1 -4
  168. package/dist/engine.cjs +1 -94
  169. package/dist/engine.d.cts +10 -11
  170. package/dist/engine.d.ts +10 -11
  171. package/dist/engine.js +1 -37
  172. package/dist/errors.cjs +1 -105
  173. package/dist/errors.d.cts +3 -3
  174. package/dist/errors.d.ts +3 -3
  175. package/dist/errors.js +1 -4
  176. package/dist/format.cjs +1 -26
  177. package/dist/format.d.cts +2 -2
  178. package/dist/format.d.ts +2 -2
  179. package/dist/format.js +1 -9
  180. package/dist/index.cjs +1 -314
  181. package/dist/index.cjs.map +1 -1
  182. package/dist/index.d.cts +52 -20
  183. package/dist/index.d.ts +52 -20
  184. package/dist/index.js +1 -278
  185. package/dist/index.js.map +1 -1
  186. package/dist/language.cjs +1 -369
  187. package/dist/language.cjs.map +1 -1
  188. package/dist/language.d.cts +9 -10
  189. package/dist/language.d.ts +9 -10
  190. package/dist/language.js +1 -348
  191. package/dist/language.js.map +1 -1
  192. package/dist/lexer.cjs +1 -63
  193. package/dist/lexer.js +1 -10
  194. package/dist/normalizer.cjs +1 -39
  195. package/dist/normalizer.js +1 -10
  196. package/dist/packages.cjs +1 -132
  197. package/dist/packages.d.cts +8 -9
  198. package/dist/packages.d.ts +8 -9
  199. package/dist/packages.js +1 -23
  200. package/dist/parser.cjs +1 -54
  201. package/dist/parser.d.cts +8 -8
  202. package/dist/parser.d.ts +8 -8
  203. package/dist/parser.js +1 -9
  204. package/dist/{pipeline-D-PS9gVw.d.ts → pipeline-72QmQlGx.d.ts} +1 -1
  205. package/dist/{pipeline-DtSBJ8TS.d.cts → pipeline-DCQicwWX.d.cts} +1 -1
  206. package/dist/resolvers.cjs +1 -12
  207. package/dist/resolvers.d.cts +2 -2
  208. package/dist/resolvers.d.ts +2 -2
  209. package/dist/resolvers.js +1 -3
  210. package/dist/services.cjs +1 -20
  211. package/dist/services.js +1 -3
  212. package/dist/testing.cjs +3 -477
  213. package/dist/testing.cjs.map +1 -1
  214. package/dist/testing.d.cts +9 -10
  215. package/dist/testing.d.ts +9 -10
  216. package/dist/testing.js +3 -469
  217. package/dist/testing.js.map +1 -1
  218. package/dist/uom.cjs +1 -55
  219. package/dist/uom.d.cts +2 -2
  220. package/dist/uom.d.ts +2 -2
  221. package/dist/uom.js +1 -10
  222. package/dist/utilities.cjs +1 -36
  223. package/dist/utilities.js +1 -7
  224. package/dist/vm.cjs +1 -295
  225. package/dist/vm.cjs.map +1 -1
  226. package/dist/vm.d.cts +22 -10
  227. package/dist/vm.d.ts +22 -10
  228. package/dist/vm.js +1 -193
  229. package/dist/vm.js.map +1 -1
  230. package/dist/worker.cjs +2 -492
  231. package/dist/worker.cjs.map +1 -1
  232. package/dist/worker.d.cts +16 -17
  233. package/dist/worker.d.ts +16 -17
  234. package/dist/worker.js +2 -483
  235. package/dist/worker.js.map +1 -1
  236. package/package.json +1 -13
  237. package/dist/chunk-3BOK2LDK.js +0 -17
  238. package/dist/chunk-3BOK2LDK.js.map +0 -1
  239. package/dist/chunk-3VGDNEE3.js +0 -84
  240. package/dist/chunk-3VGDNEE3.js.map +0 -1
  241. package/dist/chunk-4K5W7EH2.cjs +0 -112
  242. package/dist/chunk-4K5W7EH2.cjs.map +0 -1
  243. package/dist/chunk-5EFKSKMA.js +0 -413
  244. package/dist/chunk-5EFKSKMA.js.map +0 -1
  245. package/dist/chunk-5HRB36DK.js +0 -405
  246. package/dist/chunk-5HRB36DK.js.map +0 -1
  247. package/dist/chunk-5ON7PUAZ.js +0 -12
  248. package/dist/chunk-5ON7PUAZ.js.map +0 -1
  249. package/dist/chunk-7AXJNQMF.cjs +0 -297
  250. package/dist/chunk-7AXJNQMF.cjs.map +0 -1
  251. package/dist/chunk-7JM3F4KL.js +0 -1795
  252. package/dist/chunk-7JM3F4KL.js.map +0 -1
  253. package/dist/chunk-7USV76HV.cjs +0 -341
  254. package/dist/chunk-7USV76HV.cjs.map +0 -1
  255. package/dist/chunk-A2DZ5BEJ.cjs +0 -1930
  256. package/dist/chunk-A2DZ5BEJ.cjs.map +0 -1
  257. package/dist/chunk-ADBA3XBE.cjs +0 -20
  258. package/dist/chunk-ADBA3XBE.cjs.map +0 -1
  259. package/dist/chunk-AKNGX4TZ.cjs +0 -236
  260. package/dist/chunk-AKNGX4TZ.cjs.map +0 -1
  261. package/dist/chunk-ALYRJ72W.cjs +0 -434
  262. package/dist/chunk-ALYRJ72W.cjs.map +0 -1
  263. package/dist/chunk-AMOJYLG2.cjs +0 -1692
  264. package/dist/chunk-AMOJYLG2.cjs.map +0 -1
  265. package/dist/chunk-AOH6UR2L.js +0 -825
  266. package/dist/chunk-AOH6UR2L.js.map +0 -1
  267. package/dist/chunk-AQNHHJMJ.cjs +0 -261
  268. package/dist/chunk-B7LXJ6LC.cjs +0 -36
  269. package/dist/chunk-B7LXJ6LC.cjs.map +0 -1
  270. package/dist/chunk-BESTLPRK.cjs +0 -6919
  271. package/dist/chunk-BESTLPRK.cjs.map +0 -1
  272. package/dist/chunk-BLI4NIQY.js +0 -98
  273. package/dist/chunk-BLI4NIQY.js.map +0 -1
  274. package/dist/chunk-BSPXMGIS.js +0 -455
  275. package/dist/chunk-BSPXMGIS.js.map +0 -1
  276. package/dist/chunk-C2OMO3WN.cjs +0 -2806
  277. package/dist/chunk-C2OMO3WN.cjs.map +0 -1
  278. package/dist/chunk-CSDQMDU2.js +0 -204
  279. package/dist/chunk-CSDQMDU2.js.map +0 -1
  280. package/dist/chunk-EJ3ILXX6.cjs +0 -223
  281. package/dist/chunk-EJ3ILXX6.cjs.map +0 -1
  282. package/dist/chunk-ENRIK36Q.cjs +0 -94
  283. package/dist/chunk-ENRIK36Q.cjs.map +0 -1
  284. package/dist/chunk-F4UB4XIL.js +0 -109
  285. package/dist/chunk-F4UB4XIL.js.map +0 -1
  286. package/dist/chunk-FD5ZZHEU.js +0 -92
  287. package/dist/chunk-FD5ZZHEU.js.map +0 -1
  288. package/dist/chunk-FE4RC37D.js +0 -2801
  289. package/dist/chunk-FE4RC37D.js.map +0 -1
  290. package/dist/chunk-FEAIOR7N.cjs +0 -91
  291. package/dist/chunk-FEAIOR7N.cjs.map +0 -1
  292. package/dist/chunk-FR7RNOPT.cjs +0 -3303
  293. package/dist/chunk-FR7RNOPT.cjs.map +0 -1
  294. package/dist/chunk-G2YPPLGX.cjs +0 -484
  295. package/dist/chunk-G2YPPLGX.cjs.map +0 -1
  296. package/dist/chunk-GCM5JHMX.js +0 -88
  297. package/dist/chunk-GCM5JHMX.js.map +0 -1
  298. package/dist/chunk-GDEU72RG.cjs +0 -829
  299. package/dist/chunk-GDEU72RG.cjs.map +0 -1
  300. package/dist/chunk-HKTQCQ4Z.cjs +0 -8383
  301. package/dist/chunk-HKTQCQ4Z.cjs.map +0 -1
  302. package/dist/chunk-HWHU642X.cjs +0 -316
  303. package/dist/chunk-HWHU642X.cjs.map +0 -1
  304. package/dist/chunk-ICEKS6YC.cjs +0 -507
  305. package/dist/chunk-ICEKS6YC.cjs.map +0 -1
  306. package/dist/chunk-IJGOFP2J.js +0 -6904
  307. package/dist/chunk-IJGOFP2J.js.map +0 -1
  308. package/dist/chunk-IQJGDZOP.js +0 -333
  309. package/dist/chunk-IQJGDZOP.js.map +0 -1
  310. package/dist/chunk-IT74O4BE.cjs +0 -456
  311. package/dist/chunk-IT74O4BE.cjs.map +0 -1
  312. package/dist/chunk-KXDQKVNX.cjs +0 -459
  313. package/dist/chunk-KXDQKVNX.cjs.map +0 -1
  314. package/dist/chunk-L2TE7PMO.cjs +0 -14
  315. package/dist/chunk-L2TE7PMO.cjs.map +0 -1
  316. package/dist/chunk-L5YHV6BQ.js +0 -499
  317. package/dist/chunk-L5YHV6BQ.js.map +0 -1
  318. package/dist/chunk-LO7HU5WB.cjs +0 -209
  319. package/dist/chunk-LO7HU5WB.cjs.map +0 -1
  320. package/dist/chunk-LSALB3IN.js +0 -292
  321. package/dist/chunk-LSALB3IN.js.map +0 -1
  322. package/dist/chunk-MI7OTUHL.cjs +0 -339
  323. package/dist/chunk-MI7OTUHL.cjs.map +0 -1
  324. package/dist/chunk-MIGXCBXT.cjs +0 -381
  325. package/dist/chunk-MIGXCBXT.cjs.map +0 -1
  326. package/dist/chunk-MVTOCRV2.js +0 -213
  327. package/dist/chunk-MVTOCRV2.js.map +0 -1
  328. package/dist/chunk-N7FNVFXW.cjs +0 -32
  329. package/dist/chunk-N7FNVFXW.cjs.map +0 -1
  330. package/dist/chunk-N7OA4WPJ.js +0 -362
  331. package/dist/chunk-N7OA4WPJ.js.map +0 -1
  332. package/dist/chunk-NAWZATKT.js +0 -478
  333. package/dist/chunk-NAWZATKT.js.map +0 -1
  334. package/dist/chunk-NLNDMWZC.js +0 -31
  335. package/dist/chunk-NLNDMWZC.js.map +0 -1
  336. package/dist/chunk-ORM7CHYZ.js +0 -1531
  337. package/dist/chunk-ORM7CHYZ.js.map +0 -1
  338. package/dist/chunk-OUHT5Z36.cjs +0 -393
  339. package/dist/chunk-OUHT5Z36.cjs.map +0 -1
  340. package/dist/chunk-PCZVMMWU.cjs +0 -74
  341. package/dist/chunk-PCZVMMWU.cjs.map +0 -1
  342. package/dist/chunk-RNKDIXDV.js +0 -336
  343. package/dist/chunk-RNKDIXDV.js.map +0 -1
  344. package/dist/chunk-SBUFNJVE.js +0 -258
  345. package/dist/chunk-SBUFNJVE.js.map +0 -1
  346. package/dist/chunk-TC6BTUSU.cjs +0 -1799
  347. package/dist/chunk-TC6BTUSU.cjs.map +0 -1
  348. package/dist/chunk-TPOK3UNI.js +0 -8355
  349. package/dist/chunk-TPOK3UNI.js.map +0 -1
  350. package/dist/chunk-UF6JG5SG.js +0 -312
  351. package/dist/chunk-UF6JG5SG.js.map +0 -1
  352. package/dist/chunk-UKQHXPGW.js +0 -30
  353. package/dist/chunk-UKQHXPGW.js.map +0 -1
  354. package/dist/chunk-V4XG5QF6.js +0 -1685
  355. package/dist/chunk-V4XG5QF6.js.map +0 -1
  356. package/dist/chunk-VEKIWQ3F.cjs +0 -39
  357. package/dist/chunk-VEKIWQ3F.cjs.map +0 -1
  358. package/dist/chunk-WMQRJTAO.js +0 -3266
  359. package/dist/chunk-WMQRJTAO.js.map +0 -1
  360. package/dist/chunk-X6K3HUOY.cjs +0 -86
  361. package/dist/chunk-X6K3HUOY.cjs.map +0 -1
  362. package/dist/chunk-XBTEO4OB.js +0 -391
  363. package/dist/chunk-XBTEO4OB.js.map +0 -1
  364. package/dist/chunk-XIYYHA65.cjs +0 -101
  365. package/dist/chunk-XIYYHA65.cjs.map +0 -1
  366. package/dist/chunk-YJHY7CMN.cjs +0 -1534
  367. package/dist/chunk-YLJ4XMA6.js +0 -33
  368. package/dist/chunk-YLJ4XMA6.js.map +0 -1
  369. package/dist/chunk-YNIWOYW6.js +0 -232
  370. package/dist/chunk-YNIWOYW6.js.map +0 -1
  371. package/dist/chunk-Z2XP767T.cjs +0 -35
  372. package/dist/chunk-Z2XP767T.cjs.map +0 -1
  373. package/dist/chunk-Z4X2RWOF.js +0 -37
  374. package/dist/chunk-Z4X2RWOF.js.map +0 -1
  375. package/dist/chunk-ZN6YYPIW.js +0 -67
  376. package/dist/chunk-ZN6YYPIW.js.map +0 -1
  377. package/dist/chunk-ZNFFTYWH.js +0 -1854
  378. package/dist/chunk-ZNFFTYWH.js.map +0 -1
  379. package/dist/variables.cjs +0 -17
  380. package/dist/variables.cjs.map +0 -1
  381. package/dist/variables.d.cts +0 -87
  382. package/dist/variables.d.ts +0 -87
  383. package/dist/variables.js +0 -4
  384. package/dist/variables.js.map +0 -1
@@ -1,825 +0,0 @@
1
- import { DiagnosticEventType } from './chunk-UF6JG5SG.js';
2
- import { buildBindingPowerTable, BindingPower, bigIntLiteralDigits, BytecodeBuilder } from './chunk-IQJGDZOP.js';
3
- import { tokenTypeId, TokenTypes } from './chunk-NAWZATKT.js';
4
- import { getLocale } from './chunk-XBTEO4OB.js';
5
- import { ErrorFactory } from './chunk-N7OA4WPJ.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-AOH6UR2L.js.map
825
- //# sourceMappingURL=chunk-AOH6UR2L.js.map