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,1513 +0,0 @@
1
- import { registerAllTokenTypes, tokenTypeId } from './chunk-4D6NIHE2.js';
2
- import { getLocale } from './chunk-XBTEO4OB.js';
3
- import { knownUnits } from './chunk-SBUFNJVE.js';
4
- import { ErrorFactory } from './chunk-ERCOHGXD.js';
5
-
6
- // src/lexer/ExpressionLexer.ts
7
- registerAllTokenTypes();
8
- function buildCharClassTable() {
9
- const table = new Uint8Array(128);
10
- for (let i = 48; i <= 57; i++) table[i] = 2 /* DIGIT */;
11
- for (let i = 65; i <= 90; i++) table[i] = 3 /* ALPHA */;
12
- for (let i = 97; i <= 122; i++) table[i] = 3 /* ALPHA */;
13
- table[95] = 3 /* ALPHA */;
14
- table[46] = 4 /* DOT */;
15
- table[32] = 1 /* WHITESPACE */;
16
- table[9] = 1 /* WHITESPACE */;
17
- table[10] = 1 /* WHITESPACE */;
18
- table[13] = 1 /* WHITESPACE */;
19
- table[33] = 5 /* OPERATOR */;
20
- table[37] = 5 /* OPERATOR */;
21
- table[38] = 5 /* OPERATOR */;
22
- table[40] = 5 /* OPERATOR */;
23
- table[41] = 5 /* OPERATOR */;
24
- table[42] = 5 /* OPERATOR */;
25
- table[43] = 5 /* OPERATOR */;
26
- table[44] = 5 /* OPERATOR */;
27
- table[45] = 5 /* OPERATOR */;
28
- table[47] = 5 /* OPERATOR */;
29
- table[58] = 5 /* OPERATOR */;
30
- table[59] = 5 /* OPERATOR */;
31
- table[60] = 5 /* OPERATOR */;
32
- table[61] = 5 /* OPERATOR */;
33
- table[62] = 5 /* OPERATOR */;
34
- table[63] = 5 /* OPERATOR */;
35
- table[91] = 5 /* OPERATOR */;
36
- table[93] = 5 /* OPERATOR */;
37
- table[94] = 5 /* OPERATOR */;
38
- table[123] = 5 /* OPERATOR */;
39
- table[124] = 5 /* OPERATOR */;
40
- table[125] = 5 /* OPERATOR */;
41
- table[126] = 5 /* OPERATOR */;
42
- table[64] = 5 /* OPERATOR */;
43
- table[34] = 6 /* QUOTE */;
44
- table[35] = 7 /* HASH */;
45
- table[36] = 8 /* DOLLAR */;
46
- table[96] = 11 /* BACKTICK */;
47
- return table;
48
- }
49
- function isUnicodeSpace(cc) {
50
- return cc === 133 || // NEL, next line
51
- cc === 160 || // no-break space
52
- cc === 5760 || // ogham space mark
53
- cc >= 8192 && cc <= 8202 || // en quad through hair space, incl. figure/thin space
54
- cc === 8203 || // zero-width space
55
- cc === 8232 || // line separator
56
- cc === 8233 || // paragraph separator
57
- cc === 8239 || // narrow no-break space
58
- cc === 8287 || // medium mathematical space
59
- cc === 12288 || // ideographic space
60
- cc === 65279;
61
- }
62
- var LexerToken = class {
63
- constructor(type, typeId, value, text, offset, lineBreaks, line, col, sourceEnd) {
64
- this.type = type;
65
- this.typeId = typeId;
66
- this.value = value;
67
- this.text = text;
68
- this.offset = offset;
69
- this.lineBreaks = lineBreaks;
70
- this.line = line;
71
- this.col = col;
72
- this.sourceEnd = sourceEnd;
73
- }
74
- };
75
- var TWO_CHAR_OPS = {
76
- 61: { 61: "EQUALITY", 62: "THEREFORE" },
77
- // ==, => (opposite char order from >='s GTE below — no collision)
78
- 33: { 61: "NEQ" },
79
- // !=
80
- 62: { 61: "GTE" },
81
- // >=
82
- 60: { 61: "LTE" },
83
- // <=
84
- 38: { 38: "LOGICAL_AND" },
85
- // &&
86
- 124: { 124: "LOGICAL_OR" }
87
- // ||
88
- // Note: ** is NOT a single token, the existing moo lexer emits two
89
- // separate STAR tokens, and the parser consumes them that way.
90
- // 42: { 42: 'EXPONENT' }, // **, disabled for moo compatibility
91
- };
92
- var OP_MAP = {
93
- 43: "PLUS",
94
- // +
95
- 45: "MINUS",
96
- // -
97
- 42: "STAR",
98
- // *
99
- 47: "SLASH",
100
- // /
101
- 94: "CARET",
102
- // ^
103
- 37: "PERCENT",
104
- // %
105
- 40: "LPAREN",
106
- // (
107
- 41: "RPAREN",
108
- // )
109
- 91: "LBRACKET",
110
- // [
111
- 93: "RBRACKET",
112
- // ]
113
- 123: "LBRACE",
114
- // {
115
- 125: "RBRACE",
116
- // }
117
- 44: "COMMA",
118
- // ,
119
- 58: "COLON",
120
- // :
121
- 59: "SEMICOLON",
122
- // ;
123
- 61: "EQUALS",
124
- // =
125
- 63: "QUESTION",
126
- // ?
127
- 33: "BANG",
128
- // !
129
- 38: "BIT_AND",
130
- // &
131
- 124: "BIT_OR",
132
- // |
133
- 60: "LT",
134
- // <
135
- 62: "GT",
136
- // >
137
- 126: "BIT_NOT",
138
- // ~
139
- // "@", activates the token type name already dormant-reserved for this
140
- // exact purpose (see Token.ts's OVER/RATE_AT doc comment and
141
- // normalizer/TokenNormalizer.ts's NON_WORD_NAMES, both of which already
142
- // anticipated "AT" as a future "@" symbol token before this addition).
143
- // Backs the time package's video-timecode literal's alternate fps
144
- // separator (`01:02:03:04 @ 30fps`, equivalent to `... at 30fps`). See
145
- // packages/time/parselets/VideoTimecodeParselet.ts.
146
- 64: "AT"
147
- // @
148
- };
149
- var EXPRESSION_INDICATOR_CODES = (() => {
150
- const set = /* @__PURE__ */ new Set();
151
- for (let i = 48; i <= 57; i++) set.add(i);
152
- const opCodes = [43, 45, 42, 47, 94, 37, 40, 41, 91, 93, 123, 125, 61, 60, 62, 33, 38, 124, 126, 59, 63];
153
- for (const c of opCodes) set.add(c);
154
- set.add(36);
155
- set.add(163);
156
- set.add(8364);
157
- set.add(165);
158
- set.add(8381);
159
- set.add(8361);
160
- set.add(96);
161
- set.add(46);
162
- set.add(35);
163
- return set;
164
- })();
165
- var _ExpressionLexer = class _ExpressionLexer {
166
- constructor(localeCode = "en", lookup) {
167
- /**
168
- * Configured TokenLookup from TokenClassRegistry. When set, replaces
169
- * the internal keyword map and unit set with registry-built equivalents.
170
- * Enables data-driven keyword/unit registration across locale keywords,
171
- * provider keywords, and plugins.
172
- *
173
- * Set at construction time via the constructor parameter. Plugin-registered
174
- * keywords/units (via registerVocabulary()) are checked alongside
175
- * the configuredLookup, neither source is bypassed.
176
- */
177
- this.configuredLookup = null;
178
- // Instance state
179
- this.input = "";
180
- this.pos = 0;
181
- this.len = 0;
182
- // Line / column tracking (1-indexed)
183
- this.line = 1;
184
- this.lineStartPos = 0;
185
- // Open-bracket context stack for the current line, one entry per unclosed
186
- // `(`/`[`, `true` when a comma inside it is a separator rather than a
187
- // thousands group. A `[` (vector/matrix) and a CALL `(` (`rgb(255,255,255)`,
188
- // preceded by an identifier) are separator contexts; a bare GROUPING `(`
189
- // (`(1,000)`, preceded by an operator or the line start) is not, so a
190
- // parenthesised thousands number still reads as one scalar. The number scanner
191
- // consults the innermost entry. Tracked here because the flat token stream
192
- // carries no nesting otherwise; reset per line, so an unbalanced bracket
193
- // cannot bleed the decision into the next.
194
- this.groupingStack = [];
195
- // Plugin-extensible keyword map (merged with locale keywordMap)
196
- this.pluginKeywordMap = /* @__PURE__ */ new Map();
197
- // Plugin-extensible two-char operators: firstChar → (secondChar → tokenType)
198
- this.pluginOperators = /* @__PURE__ */ new Map();
199
- // Plugin-extensible units (merged with knownUnits)
200
- this.pluginUnits = /* @__PURE__ */ new Set();
201
- // Fast-path guards: skip plugin lookups entirely when no plugins registered
202
- this.hasPluginOps = false;
203
- /**
204
- * Inline solve spans collected during the most recent tokenization pass.
205
- * Populated by [Symbol.iterator]() and consumed by scanDocument().
206
- */
207
- this._inlineSolveSpans = [];
208
- // Plugin-extensible raw-line patterns. See LexerVocabulary.rawLinePatterns.
209
- this.pluginRawLinePatterns = [];
210
- /**
211
- * If a `rawLinePatterns` rule matches the FULL text most recently passed
212
- * to {@link reset}, this holds the single synthetic token that
213
- * {@link tokenizeAll} should return instead of running the
214
- * character-by-character scanner. Cleared (re-evaluated) on every
215
- * {@link reset} call. `null` when no plugin registered any raw-line
216
- * patterns, or none matched, the overwhelmingly common case, checked
217
- * with a `length === 0` guard before ever touching this field so a
218
- * plugin-free lexer pays zero cost for the feature.
219
- */
220
- this.pendingRawLineToken = null;
221
- this.localeCode = localeCode;
222
- this.locale = getLocale(localeCode);
223
- this.configuredLookup = lookup ?? null;
224
- this.keywordMap = /* @__PURE__ */ new Map();
225
- for (const [k, v] of Object.entries(this.locale.keywordMap)) {
226
- this.keywordMap.set(k.toLowerCase(), v);
227
- }
228
- this.mergedKeywords = new Map(this.keywordMap);
229
- this.mergedUnits = new Set(knownUnits);
230
- }
231
- /**
232
- * Test `text` against every registered `rawLinePatterns` rule, in
233
- * registration order. Returns a synthetic token for the first rule
234
- * whose `pattern` matches AND whose capture group 1 is non-empty after
235
- * trimming; returns `null` if no rule matches (the normal
236
- * character-by-character scanner should run instead).
237
- */
238
- matchRawLine(text) {
239
- for (const rule of this.pluginRawLinePatterns) {
240
- const m = rule.pattern.exec(text);
241
- if (m && typeof m[1] === "string") {
242
- const value = m[1].trim();
243
- if (value.length > 0) {
244
- return new LexerToken(rule.tokenType, tokenTypeId(rule.tokenType), value, value, 0, 0, this.line, 1);
245
- }
246
- }
247
- }
248
- return null;
249
- }
250
- /** Rebuild merged keyword and unit collections after plugin registration. */
251
- rebuildMergedCollections() {
252
- this.mergedKeywords = new Map([...this.keywordMap, ...this.pluginKeywordMap]);
253
- this.mergedUnits = /* @__PURE__ */ new Set([...knownUnits, ...this.pluginUnits]);
254
- }
255
- /**
256
- * Register a plugin to extend the lexer with custom tokens.
257
- *
258
- * All registrations are additive, built-in patterns still work.
259
- * Keywords, operators, and units from the plugin are merged
260
- * with existing ones. Calling multiple times adds more entries.
261
- *
262
- * Note: multi-word phrases are now handled by the TokenNormalizer
263
- * (see `IEnginePackage.normalizerRules`), not the lexer.
264
- *
265
- * Built-in tokens CANNOT be overridden. Throws a EngineError if the
266
- * plugin attempts to register a keyword, operator, or unit
267
- * that conflicts with a built-in one.
268
- */
269
- registerVocabulary(plugin) {
270
- if (plugin.keywords) {
271
- for (const [keyword, tokenType] of Object.entries(plugin.keywords)) {
272
- const lower = keyword.toLowerCase();
273
- if (this.keywordMap.has(lower)) {
274
- throw ErrorFactory.config(
275
- "PLUGIN_KEYWORD_COLLISION",
276
- `Plugin keyword "${keyword}" conflicts with built-in keyword (type: ${this.keywordMap.get(lower)}). Built-in keywords cannot be overridden.`,
277
- { keyword, builtinType: this.keywordMap.get(lower) }
278
- );
279
- }
280
- this.pluginKeywordMap.set(lower, tokenType);
281
- }
282
- this.rebuildMergedCollections();
283
- }
284
- if (plugin.operators) {
285
- this.hasPluginOps = true;
286
- for (const [chars, tokenType] of Object.entries(plugin.operators)) {
287
- if (chars.length === 2) {
288
- const first = chars.charCodeAt(0);
289
- const second = chars.charCodeAt(1);
290
- const builtInSecondMap = TWO_CHAR_OPS[first];
291
- if (builtInSecondMap && builtInSecondMap[second] !== void 0) {
292
- throw ErrorFactory.config(
293
- "PLUGIN_OPERATOR_COLLISION",
294
- `Plugin operator "${chars}" conflicts with built-in operator (type: ${builtInSecondMap[second]}). Built-in operators cannot be overridden.`,
295
- { operator: chars, builtinType: builtInSecondMap[second] }
296
- );
297
- }
298
- if (first === 60 && second === 60) {
299
- throw ErrorFactory.config(
300
- "PLUGIN_OPERATOR_COLLISION",
301
- `Plugin operator "${chars}" conflicts with built-in operator (type: LSHIFT). Built-in operators cannot be overridden.`,
302
- { operator: chars, builtinType: "LSHIFT" }
303
- );
304
- }
305
- if (first === 62 && second === 62) {
306
- throw ErrorFactory.config(
307
- "PLUGIN_OPERATOR_COLLISION",
308
- `Plugin operator "${chars}" conflicts with built-in operator (type: RSHIFT). Built-in operators cannot be overridden.`,
309
- { operator: chars, builtinType: "RSHIFT" }
310
- );
311
- }
312
- if (first === 47 && second === 47) {
313
- throw ErrorFactory.config(
314
- "PLUGIN_OPERATOR_COLLISION",
315
- `Plugin operator "${chars}" conflicts with built-in comment sequence. Comment sequences cannot be overridden.`,
316
- { operator: chars, builtinType: "COMMENT" }
317
- );
318
- }
319
- let inner = this.pluginOperators.get(first);
320
- if (!inner) {
321
- inner = /* @__PURE__ */ new Map();
322
- this.pluginOperators.set(first, inner);
323
- }
324
- inner.set(second, tokenType);
325
- }
326
- }
327
- }
328
- if (plugin.units) {
329
- for (const unit of plugin.units) {
330
- if (knownUnits.has(unit)) {
331
- throw ErrorFactory.config(
332
- "PLUGIN_UNIT_COLLISION",
333
- `Plugin unit "${unit}" conflicts with a built-in unit. Built-in units cannot be overridden.`,
334
- { unit }
335
- );
336
- }
337
- this.pluginUnits.add(unit);
338
- }
339
- this.rebuildMergedCollections();
340
- }
341
- if (plugin.rawLinePatterns) {
342
- this.pluginRawLinePatterns.push(...plugin.rawLinePatterns);
343
- }
344
- }
345
- /**
346
- * Unregister a plugin, removing its custom tokens from the lexer.
347
- *
348
- * This is the inverse of registerVocabulary(). All keywords, operators,
349
- * and units registered by the plugin are removed. After
350
- * unregistration, those tokens will revert to their default behavior
351
- * (e.g., keywords become IDENT, operators become ERROR).
352
- *
353
- * Calling unregisterVocabulary with a plugin that was never registered
354
- * is safe, it simply has no effect.
355
- */
356
- unregisterVocabulary(plugin) {
357
- if (plugin.keywords) {
358
- for (const keyword of Object.keys(plugin.keywords)) {
359
- this.pluginKeywordMap.delete(keyword.toLowerCase());
360
- }
361
- this.rebuildMergedCollections();
362
- }
363
- if (plugin.operators) {
364
- for (const chars of Object.keys(plugin.operators)) {
365
- if (chars.length === 2) {
366
- const first = chars.charCodeAt(0);
367
- const second = chars.charCodeAt(1);
368
- const inner = this.pluginOperators.get(first);
369
- if (inner) {
370
- inner.delete(second);
371
- if (inner.size === 0) {
372
- this.pluginOperators.delete(first);
373
- }
374
- }
375
- }
376
- }
377
- this.hasPluginOps = this.pluginOperators.size > 0;
378
- }
379
- if (plugin.units) {
380
- for (const unit of plugin.units) {
381
- this.pluginUnits.delete(unit);
382
- }
383
- this.rebuildMergedCollections();
384
- }
385
- if (plugin.rawLinePatterns) {
386
- const toRemove = new Set(plugin.rawLinePatterns);
387
- this.pluginRawLinePatterns = this.pluginRawLinePatterns.filter((r) => !toRemove.has(r));
388
- }
389
- }
390
- reset(input) {
391
- this.input = input;
392
- this.pos = 0;
393
- this.len = input.length;
394
- this.line = 1;
395
- this.lineStartPos = 0;
396
- this.pendingRawLineToken = this.pluginRawLinePatterns.length > 0 ? this.matchRawLine(input) : null;
397
- }
398
- /**
399
- * Scan a full document text in a single pass, classifying each line and
400
- * tokenizing non-skipped lines.
401
- *
402
- * Replaces the separate classifyLine() + findInlineSolves() + per-line
403
- * reset() + tokenizeAll() pattern with a single character-by-character
404
- * walk through the entire document. Key benefits:
405
- *
406
- * - **Single reset()**: `this.pos`, `this.len`, `this.line`, and
407
- * `this.lineStartPos` are set once for the whole document, not per-line.
408
- * - **Single classification**: classifyLine() runs once per line inline;
409
- * skipped lines are jumped over without tokenization.
410
- * - **Shared tokenization**: Non-skipped lines are tokenized using the
411
- * existing state machine, yielding Token[] without per-line reset().
412
- * - **Inline solve detection**: findInlineSolves() is called only for
413
- * lines that classifyLine() marks as having inline solves.
414
- *
415
- * Tokenization is scoped to each line by temporarily restricting
416
- * `this.len` to the line end position, so the [Symbol.iterator]
417
- * generator naturally stops at the line boundary. After tokenization,
418
- * `this.len` is restored and `this.pos` advances past the newline.
419
- *
420
- * @param text The full document text (with newlines).
421
- * @returns Array of ScanLineResult, one per line, in document order.
422
- */
423
- scanDocument(text) {
424
- this.input = text;
425
- this.pos = 0;
426
- this.len = text.length;
427
- this.line = 1;
428
- this.lineStartPos = 0;
429
- const results = [];
430
- const input = this.input;
431
- const docLen = this.len;
432
- while (this.pos < docLen) {
433
- const lineStart = this.pos;
434
- let lineEnd = this.pos;
435
- while (lineEnd < docLen) {
436
- const cc = input.charCodeAt(lineEnd);
437
- if (cc === 10 || cc === 13) break;
438
- lineEnd++;
439
- }
440
- const lineNumber = this.line;
441
- const classification = this.classifyFromPositions(lineStart, lineEnd);
442
- const lineText = input.slice(lineStart, lineEnd);
443
- let tokens = [];
444
- if (!classification.skip) {
445
- const rawToken = this.pluginRawLinePatterns.length > 0 ? this.matchRawLine(lineText) : null;
446
- if (rawToken) {
447
- tokens = [rawToken];
448
- } else {
449
- const savedLen = this.len;
450
- this.len = lineEnd;
451
- if (classification.contentOffset !== void 0) this.pos = classification.contentOffset;
452
- tokens = Array.from(this);
453
- this.len = savedLen;
454
- }
455
- }
456
- let inlineSolves = [];
457
- if (classification.hasInlineSolve) {
458
- if (!classification.skip && tokens.length > 0) {
459
- const charSpans = this.findInlineSolves(lineText);
460
- inlineSolves = this._inlineSolveSpans.map((span, i) => ({
461
- start: charSpans[i]?.start ?? 0,
462
- end: charSpans[i]?.end ?? 0,
463
- expression: charSpans[i]?.expression ?? "",
464
- columnNumber: charSpans[i]?.columnNumber ?? span.columnNumber,
465
- startTokenIndex: span.startTokenIndex,
466
- endTokenIndex: span.endTokenIndex
467
- }));
468
- } else {
469
- inlineSolves = this.findInlineSolves(lineText);
470
- }
471
- }
472
- results.push({
473
- text: lineText,
474
- lineNumber,
475
- startOffset: lineStart,
476
- endOffset: lineEnd,
477
- classification,
478
- tokens,
479
- inlineSolves
480
- });
481
- this.pos = lineEnd;
482
- if (this.pos < docLen) {
483
- const nlChar = input.charCodeAt(this.pos);
484
- if (nlChar === 13) {
485
- this.pos++;
486
- if (this.pos < docLen && input.charCodeAt(this.pos) === 10) {
487
- this.pos++;
488
- }
489
- } else if (nlChar === 10) {
490
- this.pos++;
491
- }
492
- }
493
- this.line++;
494
- this.lineStartPos = this.pos;
495
- }
496
- return results;
497
- }
498
- /**
499
- * Tokenize an expression string into an array of Tokens.
500
- *
501
- * Delegates to the lazy [Symbol.iterator]() generator and collects all
502
- * yielded tokens via Array.from(). For memory-sensitive use cases, prefer
503
- * iterating the lexer directly with for...of to avoid array allocation.
504
- *
505
- * Optimizations:
506
- * - CHAR_CLASS jump table (Uint8Array) → switch on small integers
507
- * - Direct character-code dispatch (c0 cached pattern)
508
- * - Mathematical digit parsing (integer math, not slice+parseFloat)
509
- * - Inline operator tokenizer with two-char peek-ahead
510
- * - Whitespace eliminated in-lexer (never emitted)
511
- * - 0-char and 1-char fast paths
512
- */
513
- tokenizeAll() {
514
- if (this.pendingRawLineToken) {
515
- this._inlineSolveSpans = [];
516
- return [this.pendingRawLineToken];
517
- }
518
- return Array.from(this);
519
- }
520
- // ── Lazy iterator ─────────────────────────────────────────────────────
521
- /**
522
- * Lazy token-by-token generator. Yields each token without allocating an
523
- * intermediate Token[] array. Supports for...of and spread usage.
524
- *
525
- * Usage:
526
- * for (const t of lexer) { ... } // lazy, no array allocation
527
- * const tokens = [...lexer]; // materializes via spread
528
- * const tokens = lexer.tokenizeAll(); // materializes via Array.from()
529
- *
530
- * IMPORTANT: This generator captures `this.len` ONCE at creation time
531
- * (const len = this.len). `scanDocument()` relies on this behavior to
532
- * scope tokenization to a single line by temporarily restricting
533
- * `this.len` to the line end position before creating the iterator.
534
- * Do NOT refactor to re-read `this.len` mid-loop without also updating
535
- * `scanDocument()`.
536
- */
537
- *[Symbol.iterator]() {
538
- const len = this.len;
539
- if (len === 0) {
540
- this._inlineSolveSpans = [];
541
- return;
542
- }
543
- let tokenIndex = 0;
544
- let openSpan = null;
545
- const collectedSpans = [];
546
- if (len === 1) {
547
- const c0 = this.input.charCodeAt(0);
548
- const cc = _ExpressionLexer.CHAR_CLASS[c0] ?? 0 /* SKIP */;
549
- switch (cc) {
550
- case 2 /* DIGIT */:
551
- case 4 /* DOT */:
552
- yield new LexerToken("NUMBER", tokenTypeId("NUMBER"), this.input, this.input, 0, 0, 1, 1);
553
- tokenIndex++;
554
- break;
555
- case 3 /* ALPHA */: {
556
- const input2 = this.input;
557
- const identLower = input2.toLowerCase();
558
- if (this.mergedUnits.has(input2)) {
559
- yield new LexerToken("UNIT", tokenTypeId("UNIT"), input2, input2, 0, 0, 1, 1);
560
- } else {
561
- const kwType = this.mergedKeywords.get(identLower);
562
- if (kwType) {
563
- yield new LexerToken(kwType, tokenTypeId(kwType), input2, input2, 0, 0, 1, 1);
564
- } else {
565
- yield new LexerToken("IDENT", tokenTypeId("IDENT"), input2, input2, 0, 0, 1, 1);
566
- }
567
- }
568
- tokenIndex++;
569
- break;
570
- }
571
- case 5 /* OPERATOR */: {
572
- const opType = OP_MAP[c0];
573
- if (opType) {
574
- yield new LexerToken(opType, tokenTypeId(opType), this.input, this.input, 0, 0, 1, 1);
575
- tokenIndex++;
576
- }
577
- break;
578
- }
579
- case 6 /* QUOTE */:
580
- this.pos = 0;
581
- yield this.tokenizeString();
582
- tokenIndex++;
583
- break;
584
- case 7 /* HASH */:
585
- this.pos = 0;
586
- yield this.tokenizeComment();
587
- tokenIndex++;
588
- break;
589
- case 8 /* DOLLAR */:
590
- yield new LexerToken("DOLLAR", tokenTypeId("DOLLAR"), "$", "$", 0, 0, 1, 1);
591
- tokenIndex++;
592
- break;
593
- case 11 /* BACKTICK */:
594
- yield new LexerToken("BACKTICK_OPEN", tokenTypeId("BACKTICK_OPEN"), "`", "`", 0, 0, 1, 1);
595
- tokenIndex++;
596
- break;
597
- default: {
598
- if (isUnicodeSpace(c0)) ; else if (c0 === 215) {
599
- yield new LexerToken("STAR", tokenTypeId("STAR"), "\xD7", "\xD7", 0, 0, 1, 1);
600
- tokenIndex++;
601
- } else if (c0 === 247) {
602
- yield new LexerToken("SLASH", tokenTypeId("SLASH"), "\xF7", "\xF7", 0, 0, 1, 1);
603
- tokenIndex++;
604
- } else if (c0 === 177) {
605
- yield new LexerToken("PLUS_MINUS", tokenTypeId("PLUS_MINUS"), "\xB1", "\xB1", 0, 0, 1, 1);
606
- tokenIndex++;
607
- } else if (c0 === 8800) {
608
- yield new LexerToken("NEQ", tokenTypeId("NEQ"), "\u2260", "\u2260", 0, 0, 1, 1);
609
- tokenIndex++;
610
- } else if (c0 === 163) {
611
- yield new LexerToken("POUND", tokenTypeId("POUND"), "\xA3", "\xA3", 0, 0, 1, 1);
612
- tokenIndex++;
613
- } else if (c0 === 8364) {
614
- yield new LexerToken("EURO", tokenTypeId("EURO"), "\u20AC", "\u20AC", 0, 0, 1, 1);
615
- tokenIndex++;
616
- } else if (c0 === 165) {
617
- yield new LexerToken("YEN", tokenTypeId("YEN"), "\xA5", "\xA5", 0, 0, 1, 1);
618
- tokenIndex++;
619
- } else if (c0 === 8381) {
620
- yield new LexerToken("RUBLE", tokenTypeId("RUBLE"), "\u20BD", "\u20BD", 0, 0, 1, 1);
621
- tokenIndex++;
622
- } else if (c0 === 8361) {
623
- yield new LexerToken("WON", tokenTypeId("WON"), "\u20A9", "\u20A9", 0, 0, 1, 1);
624
- tokenIndex++;
625
- } else if (c0 === 8377) {
626
- yield new LexerToken("CURRENCY_SYMBOL", tokenTypeId("CURRENCY_SYMBOL"), "\u20B9", "\u20B9", 0, 0, 1, 1);
627
- tokenIndex++;
628
- } else if (c0 === 8378) {
629
- yield new LexerToken("CURRENCY_SYMBOL", tokenTypeId("CURRENCY_SYMBOL"), "\u20BA", "\u20BA", 0, 0, 1, 1);
630
- tokenIndex++;
631
- } else if (c0 === 8372) {
632
- yield new LexerToken("CURRENCY_SYMBOL", tokenTypeId("CURRENCY_SYMBOL"), "\u20B4", "\u20B4", 0, 0, 1, 1);
633
- tokenIndex++;
634
- } else if (c0 === 8362) {
635
- yield new LexerToken("CURRENCY_SYMBOL", tokenTypeId("CURRENCY_SYMBOL"), "\u20AA", "\u20AA", 0, 0, 1, 1);
636
- tokenIndex++;
637
- } else if (c0 === 8363) {
638
- yield new LexerToken("CURRENCY_SYMBOL", tokenTypeId("CURRENCY_SYMBOL"), "\u20AB", "\u20AB", 0, 0, 1, 1);
639
- tokenIndex++;
640
- } else if (c0 === 8358) {
641
- yield new LexerToken("CURRENCY_SYMBOL", tokenTypeId("CURRENCY_SYMBOL"), "\u20A6", "\u20A6", 0, 0, 1, 1);
642
- tokenIndex++;
643
- } else if (c0 === 8369) {
644
- yield new LexerToken("CURRENCY_SYMBOL", tokenTypeId("CURRENCY_SYMBOL"), "\u20B1", "\u20B1", 0, 0, 1, 1);
645
- tokenIndex++;
646
- } else if (c0 >= 128) {
647
- yield new LexerToken("IDENT", tokenTypeId("IDENT"), this.input, this.input, 0, 0, 1, 1);
648
- tokenIndex++;
649
- }
650
- break;
651
- }
652
- }
653
- this._inlineSolveSpans = collectedSpans;
654
- return;
655
- }
656
- const input = this.input;
657
- this.groupingStack.length = 0;
658
- while (this.pos < len) {
659
- const c0 = input.charCodeAt(this.pos);
660
- const cc = _ExpressionLexer.CHAR_CLASS[c0] ?? 0 /* SKIP */;
661
- if (openSpan && c0 === 92 && this.pos + 1 < len && input.charCodeAt(this.pos + 1) === 96) {
662
- this.pos += 2;
663
- continue;
664
- }
665
- switch (cc) {
666
- // ── Whitespace, skip entirely, track newlines ────────────────
667
- case 1 /* WHITESPACE */:
668
- this.pos++;
669
- if (c0 === 10) {
670
- this.line++;
671
- this.lineStartPos = this.pos;
672
- this.groupingStack.length = 0;
673
- } else if (c0 === 13) {
674
- this.line++;
675
- if (this.pos < len && input.charCodeAt(this.pos) === 10) {
676
- this.pos++;
677
- }
678
- this.lineStartPos = this.pos;
679
- this.groupingStack.length = 0;
680
- }
681
- break;
682
- // ── Digit, inline number tokenizer ───────────────────────────
683
- case 2 /* DIGIT */:
684
- yield this.tokenizeNumber();
685
- tokenIndex++;
686
- break;
687
- // ── Alpha / underscore, identifier or keyword ────────────────
688
- case 3 /* ALPHA */: {
689
- const token = this.tokenizeIdentifier();
690
- if (token.type === "INLINE_SOLVE_START") {
691
- openSpan = { startTokenIndex: tokenIndex, startColumn: token.col };
692
- }
693
- yield token;
694
- tokenIndex++;
695
- break;
696
- }
697
- // ── Dot, could be decimal (.5) or DOT token ─────────────────
698
- case 4 /* DOT */:
699
- if (this.pos + 1 < len) {
700
- const nextCc = _ExpressionLexer.CHAR_CLASS[input.charCodeAt(this.pos + 1)] ?? 0 /* SKIP */;
701
- if (nextCc === 2 /* DIGIT */) {
702
- yield this.tokenizeNumber();
703
- } else {
704
- const col = this.pos - this.lineStartPos + 1;
705
- yield new LexerToken("DOT", tokenTypeId("DOT"), ".", ".", this.pos, 0, this.line, col);
706
- this.pos++;
707
- }
708
- } else {
709
- const col = this.pos - this.lineStartPos + 1;
710
- yield new LexerToken("DOT", tokenTypeId("DOT"), ".", ".", this.pos, 0, this.line, col);
711
- this.pos++;
712
- }
713
- tokenIndex++;
714
- break;
715
- // ── Operator / punctuation ────────────────────────────────────
716
- case 5 /* OPERATOR */:
717
- yield this.tokenizeOperator();
718
- tokenIndex++;
719
- break;
720
- // ── String literal ────────────────────────────────────────────
721
- case 6 /* QUOTE */:
722
- yield this.tokenizeString();
723
- tokenIndex++;
724
- break;
725
- // ── Comment (# or //) ─────────────────────────────────────────
726
- case 7 /* HASH */:
727
- yield this.tokenizeComment();
728
- tokenIndex++;
729
- break;
730
- // ── Dollar sign $ ─────────────────────────────────────────────
731
- case 8 /* DOLLAR */: {
732
- const col = this.pos - this.lineStartPos + 1;
733
- yield new LexerToken("DOLLAR", tokenTypeId("DOLLAR"), "$", "$", this.pos, 0, this.line, col);
734
- this.pos++;
735
- tokenIndex++;
736
- break;
737
- }
738
- // ── Backtick ` ───────────────────────────────────────────────
739
- case 11 /* BACKTICK */: {
740
- const col = this.pos - this.lineStartPos + 1;
741
- yield new LexerToken("BACKTICK_OPEN", tokenTypeId("BACKTICK_OPEN"), "`", "`", this.pos, 0, this.line, col);
742
- this.pos++;
743
- if (openSpan) {
744
- const span = openSpan;
745
- collectedSpans.push({
746
- start: 0,
747
- end: 0,
748
- expression: "",
749
- columnNumber: span.startColumn,
750
- startTokenIndex: span.startTokenIndex,
751
- endTokenIndex: tokenIndex
752
- });
753
- openSpan = null;
754
- }
755
- tokenIndex++;
756
- break;
757
- }
758
- // ── Non-ASCII characters ─────────────────────────────────────
759
- default: {
760
- const col = this.pos - this.lineStartPos + 1;
761
- if (isUnicodeSpace(c0)) {
762
- this.pos++;
763
- if (c0 === 8232 || c0 === 8233 || c0 === 133) {
764
- this.line++;
765
- this.lineStartPos = this.pos;
766
- }
767
- } else if (c0 === 215) {
768
- yield new LexerToken("STAR", tokenTypeId("STAR"), "\xD7", "\xD7", this.pos, 0, this.line, col);
769
- this.pos++;
770
- tokenIndex++;
771
- } else if (c0 === 247) {
772
- yield new LexerToken("SLASH", tokenTypeId("SLASH"), "\xF7", "\xF7", this.pos, 0, this.line, col);
773
- this.pos++;
774
- tokenIndex++;
775
- } else if (c0 === 177) {
776
- yield new LexerToken("PLUS_MINUS", tokenTypeId("PLUS_MINUS"), "\xB1", "\xB1", this.pos, 0, this.line, col);
777
- this.pos++;
778
- tokenIndex++;
779
- } else if (c0 === 8800) {
780
- yield new LexerToken("NEQ", tokenTypeId("NEQ"), "\u2260", "\u2260", this.pos, 0, this.line, col);
781
- this.pos++;
782
- tokenIndex++;
783
- } else if (c0 === 163) {
784
- yield new LexerToken("POUND", tokenTypeId("POUND"), "\xA3", "\xA3", this.pos, 0, this.line, col);
785
- this.pos++;
786
- tokenIndex++;
787
- } else if (c0 === 8364) {
788
- yield new LexerToken("EURO", tokenTypeId("EURO"), "\u20AC", "\u20AC", this.pos, 0, this.line, col);
789
- this.pos++;
790
- tokenIndex++;
791
- } else if (c0 === 165) {
792
- yield new LexerToken("YEN", tokenTypeId("YEN"), "\xA5", "\xA5", this.pos, 0, this.line, col);
793
- this.pos++;
794
- tokenIndex++;
795
- } else if (c0 === 8381) {
796
- yield new LexerToken("RUBLE", tokenTypeId("RUBLE"), "\u20BD", "\u20BD", this.pos, 0, this.line, col);
797
- this.pos++;
798
- tokenIndex++;
799
- } else if (c0 === 8361) {
800
- yield new LexerToken("WON", tokenTypeId("WON"), "\u20A9", "\u20A9", this.pos, 0, this.line, col);
801
- this.pos++;
802
- tokenIndex++;
803
- } else if (c0 === 8377) {
804
- yield new LexerToken("CURRENCY_SYMBOL", tokenTypeId("CURRENCY_SYMBOL"), "\u20B9", "\u20B9", this.pos, 0, this.line, col);
805
- this.pos++;
806
- tokenIndex++;
807
- } else if (c0 === 8378) {
808
- yield new LexerToken("CURRENCY_SYMBOL", tokenTypeId("CURRENCY_SYMBOL"), "\u20BA", "\u20BA", this.pos, 0, this.line, col);
809
- this.pos++;
810
- tokenIndex++;
811
- } else if (c0 === 8372) {
812
- yield new LexerToken("CURRENCY_SYMBOL", tokenTypeId("CURRENCY_SYMBOL"), "\u20B4", "\u20B4", this.pos, 0, this.line, col);
813
- this.pos++;
814
- tokenIndex++;
815
- } else if (c0 === 8362) {
816
- yield new LexerToken("CURRENCY_SYMBOL", tokenTypeId("CURRENCY_SYMBOL"), "\u20AA", "\u20AA", this.pos, 0, this.line, col);
817
- this.pos++;
818
- tokenIndex++;
819
- } else if (c0 === 8363) {
820
- yield new LexerToken("CURRENCY_SYMBOL", tokenTypeId("CURRENCY_SYMBOL"), "\u20AB", "\u20AB", this.pos, 0, this.line, col);
821
- this.pos++;
822
- tokenIndex++;
823
- } else if (c0 === 8358) {
824
- yield new LexerToken("CURRENCY_SYMBOL", tokenTypeId("CURRENCY_SYMBOL"), "\u20A6", "\u20A6", this.pos, 0, this.line, col);
825
- this.pos++;
826
- tokenIndex++;
827
- } else if (c0 === 8369) {
828
- yield new LexerToken("CURRENCY_SYMBOL", tokenTypeId("CURRENCY_SYMBOL"), "\u20B1", "\u20B1", this.pos, 0, this.line, col);
829
- this.pos++;
830
- tokenIndex++;
831
- } else if (c0 >= 128) {
832
- yield this.tokenizeIdentifier();
833
- tokenIndex++;
834
- } else {
835
- this.pos++;
836
- }
837
- break;
838
- }
839
- }
840
- }
841
- this._inlineSolveSpans = collectedSpans;
842
- }
843
- // ── Inline number tokenizer ────────────────────────────────────────────
844
- /**
845
- * Character-by-character number parsing.
846
- *
847
- * Supports: integers, floats, scientific notation (1.5e10, 1.5e-10),
848
- * hex (0xFF), binary (0b1010), octal (0o17), BigInt suffix (123n),
849
- * thousands separators (1,234 or 1.234.567).
850
- *
851
- * Returns a LexerToken and advances `this.pos` past the number.
852
- */
853
- tokenizeNumber() {
854
- const input = this.input;
855
- const len = this.len;
856
- let pos = this.pos;
857
- const start = pos;
858
- const startCol = pos - this.lineStartPos + 1;
859
- let cc;
860
- if (input.charCodeAt(pos) === 48 && pos + 1 < len) {
861
- const next = input.charCodeAt(pos + 1);
862
- if (next === 120 || next === 88) {
863
- pos += 2;
864
- while (pos < len && (cc = input.charCodeAt(pos), cc >= 48 && cc <= 57 || cc >= 65 && cc <= 70 || cc >= 97 && cc <= 102)) {
865
- pos++;
866
- }
867
- const text2 = input.slice(start, pos);
868
- this.pos = pos;
869
- return new LexerToken("NUMBER", tokenTypeId("NUMBER"), text2, text2, start, 0, this.line, startCol);
870
- }
871
- if (next === 98 || next === 66) {
872
- pos += 2;
873
- while (pos < len && (cc = input.charCodeAt(pos), cc === 48 || cc === 49)) {
874
- pos++;
875
- }
876
- const text2 = input.slice(start, pos);
877
- this.pos = pos;
878
- return new LexerToken("NUMBER", tokenTypeId("NUMBER"), text2, text2, start, 0, this.line, startCol);
879
- }
880
- if (next === 111 || next === 79) {
881
- pos += 2;
882
- while (pos < len && (cc = input.charCodeAt(pos), cc >= 48 && cc <= 55)) {
883
- pos++;
884
- }
885
- const text2 = input.slice(start, pos);
886
- this.pos = pos;
887
- return new LexerToken("NUMBER", tokenTypeId("NUMBER"), text2, text2, start, 0, this.line, startCol);
888
- }
889
- }
890
- let hasIntPart = false;
891
- while (pos < len && (cc = input.charCodeAt(pos), cc >= 48 && cc <= 57)) {
892
- hasIntPart = true;
893
- pos++;
894
- }
895
- while (hasIntPart && pos < len && (input.charCodeAt(pos) === 44 || input.charCodeAt(pos) === 46)) {
896
- if (input.charCodeAt(pos) === 44 && this.groupingStack.length > 0 && this.groupingStack[this.groupingStack.length - 1]) {
897
- break;
898
- }
899
- if (pos + 4 <= len) {
900
- const d1 = input.charCodeAt(pos + 1);
901
- const d2 = input.charCodeAt(pos + 2);
902
- const d3 = input.charCodeAt(pos + 3);
903
- const d4 = pos + 4 < len ? input.charCodeAt(pos + 4) : -1;
904
- const isGroupOfExactlyThree = !(d4 >= 48 && d4 <= 57);
905
- if (d1 >= 48 && d1 <= 57 && d2 >= 48 && d2 <= 57 && d3 >= 48 && d3 <= 57 && isGroupOfExactlyThree) {
906
- pos += 4;
907
- hasIntPart = true;
908
- continue;
909
- }
910
- }
911
- break;
912
- }
913
- let hasDecimal = false;
914
- if (pos < len && input.charCodeAt(pos) === 46) {
915
- if (pos + 1 < len) {
916
- const nextCc = input.charCodeAt(pos + 1);
917
- if (nextCc >= 48 && nextCc <= 57) {
918
- hasDecimal = true;
919
- pos++;
920
- while (pos < len && (cc = input.charCodeAt(pos), cc >= 48 && cc <= 57)) {
921
- pos++;
922
- }
923
- }
924
- }
925
- }
926
- let hasExponent = false;
927
- if (pos < len) {
928
- const ec = input.charCodeAt(pos);
929
- if (ec === 101 || ec === 69) {
930
- if (pos + 1 < len) {
931
- const next = input.charCodeAt(pos + 1);
932
- if (next >= 48 && next <= 57 || next === 43 || next === 45) {
933
- hasExponent = true;
934
- pos++;
935
- if (next === 43 || next === 45) pos++;
936
- while (pos < len && (cc = input.charCodeAt(pos), cc >= 48 && cc <= 57)) {
937
- pos++;
938
- }
939
- }
940
- }
941
- }
942
- }
943
- if (pos < len && input.charCodeAt(pos) === 110) {
944
- if (hasIntPart && !hasDecimal && !hasExponent) {
945
- pos++;
946
- const text2 = input.slice(start, pos);
947
- this.pos = pos;
948
- return new LexerToken("BIGINT", tokenTypeId("BIGINT"), text2, text2, start, 0, this.line, startCol);
949
- }
950
- }
951
- const text = input.slice(start, pos);
952
- this.pos = pos;
953
- return new LexerToken("NUMBER", tokenTypeId("NUMBER"), text, text, start, 0, this.line, startCol);
954
- }
955
- // ── Inline identifier / keyword tokenizer ──────────────────────────────
956
- /**
957
- * Reads [a-zA-Z_][a-zA-Z0-9_]* and resolves to:
958
- * - A unit type (via knownUnits, case-sensitive)
959
- * - A keyword type (via locale keywordMap, case-insensitive)
960
- * - IDENT if none of the above
961
- *
962
- * Multi-word phrases (e.g., "to the power of") are handled by the
963
- * TokenNormalizer post-lexer pass, not the lexer.
964
- */
965
- tokenizeIdentifier() {
966
- const input = this.input;
967
- const len = this.len;
968
- let pos = this.pos;
969
- const start = pos;
970
- const startCol = pos - this.lineStartPos + 1;
971
- let cc;
972
- while (pos < len && (cc = input.charCodeAt(pos), cc >= 48 && cc <= 57 || // 0-9
973
- cc >= 65 && cc <= 90 || // A-Z
974
- cc >= 97 && cc <= 122 || // a-z
975
- cc === 95 || // _
976
- cc >= 128 && !isUnicodeSpace(cc))) {
977
- pos++;
978
- }
979
- const identText = input.slice(start, pos);
980
- const identLower = identText.toLowerCase();
981
- if (identLower === "s" && pos < len && input.charCodeAt(pos) === 96) {
982
- pos++;
983
- this.pos = pos;
984
- const fullText = input.slice(start, pos);
985
- return new LexerToken("INLINE_SOLVE_START", tokenTypeId("INLINE_SOLVE_START"), fullText, fullText, start, 0, this.line, startCol);
986
- }
987
- const isKnownUnit = this.mergedUnits.has(identText);
988
- if (isKnownUnit) {
989
- if (!this.isFollowedByLParen(pos)) {
990
- this.pos = pos;
991
- return new LexerToken("UNIT", tokenTypeId("UNIT"), identText, identText, start, 0, this.line, startCol);
992
- }
993
- }
994
- const localeKwType = this.mergedKeywords.get(identLower);
995
- if (localeKwType) {
996
- this.pos = pos;
997
- return new LexerToken(localeKwType, tokenTypeId(localeKwType), identText, identText, start, 0, this.line, startCol);
998
- }
999
- this.pos = pos;
1000
- return new LexerToken("IDENT", tokenTypeId("IDENT"), identText, identText, start, 0, this.line, startCol);
1001
- }
1002
- /**
1003
- * Peek past in-expression whitespace (space, tab) from `pos` to check
1004
- * if the next significant character is '('.
1005
- */
1006
- isFollowedByLParen(pos) {
1007
- const len = this.len;
1008
- let lookPos = pos;
1009
- while (lookPos < len) {
1010
- const cc = this.input.charCodeAt(lookPos);
1011
- if (cc === 40) return true;
1012
- if (cc !== 32 && cc !== 9) break;
1013
- lookPos++;
1014
- }
1015
- return false;
1016
- }
1017
- // ── Inline operator tokenizer ─────────────────────────────────────────
1018
- /**
1019
- * Whether the `(` at `parenPos` opens a function call rather than a bare
1020
- * grouping, deciding whether a comma inside it is a separator or a thousands
1021
- * group (see {@link groupingStack}).
1022
- *
1023
- * It is a call when the nearest non-whitespace character before it belongs to
1024
- * the value the call applies to: a closing `)`/`]` (a call on a result), or an
1025
- * IDENTIFIER (`rgb(`, `vec2(`). A run of digits alone is a number, not an
1026
- * identifier, so `2(1,000)` is implicit multiplication over the grouping
1027
- * `(1,000)`, not a call, while `vec2(` and `atan2(` (identifiers that end in a
1028
- * digit) are calls. A `(` after an operator, a comma, or the line start is a
1029
- * grouping.
1030
- */
1031
- precededByCallTarget(parenPos) {
1032
- const input = this.input;
1033
- const start = this.lineStartPos;
1034
- let i = parenPos - 1;
1035
- while (i >= start && (input.charCodeAt(i) === 32 || input.charCodeAt(i) === 9)) i--;
1036
- if (i < start) return false;
1037
- const c = input.charCodeAt(i);
1038
- const isWord = (ch) => ch >= 48 && ch <= 57 || ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch === 95;
1039
- const isAlpha = (ch) => ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch === 95;
1040
- if (!isWord(c)) return false;
1041
- const wordEnd = i + 1;
1042
- let hasAlpha = false;
1043
- while (i >= start) {
1044
- const ch = input.charCodeAt(i);
1045
- if (!isWord(ch)) break;
1046
- if (isAlpha(ch)) hasAlpha = true;
1047
- i--;
1048
- }
1049
- if (!hasAlpha) return false;
1050
- const word = input.slice(i + 1, wordEnd).toLowerCase();
1051
- const keywordType = this.mergedKeywords.get(word);
1052
- return keywordType === void 0 || keywordType === "FUNC";
1053
- }
1054
- /**
1055
- * Reads an operator/punctuation token.
1056
- * Handles two-char operators (==, !=, >=, <=, **) and the special
1057
- * cases << (LSHIFT) and >> (RSHIFT).
1058
- */
1059
- tokenizeOperator() {
1060
- const input = this.input;
1061
- const pos = this.pos;
1062
- const col = pos - this.lineStartPos + 1;
1063
- const c0 = input.charCodeAt(pos);
1064
- const len = this.len;
1065
- if (pos + 1 < len) {
1066
- const c1 = input.charCodeAt(pos + 1);
1067
- const secondMap = TWO_CHAR_OPS[c0];
1068
- if (secondMap) {
1069
- const twoCharType = secondMap[c1];
1070
- if (twoCharType) {
1071
- const text2 = input.slice(pos, pos + 2);
1072
- this.pos = pos + 2;
1073
- return new LexerToken(twoCharType, tokenTypeId(twoCharType), text2, text2, pos, 0, this.line, col);
1074
- }
1075
- }
1076
- if (c0 === 47 && c1 === 47) {
1077
- let commentPos = pos + 2;
1078
- while (commentPos < len) {
1079
- const cc = input.charCodeAt(commentPos);
1080
- if (cc === 10 || cc === 13) break;
1081
- commentPos++;
1082
- }
1083
- const text2 = input.slice(pos, commentPos);
1084
- this.pos = commentPos;
1085
- return new LexerToken("COMMENT", tokenTypeId("COMMENT"), text2, text2, pos, 0, this.line, col);
1086
- }
1087
- if (c0 === 60 && c1 === 60) {
1088
- this.pos = pos + 2;
1089
- return new LexerToken("LSHIFT", tokenTypeId("LSHIFT"), "<<", "<<", pos, 0, this.line, col);
1090
- }
1091
- if (c0 === 62 && c1 === 62) {
1092
- if (input.charCodeAt(pos + 2) === 62) {
1093
- this.pos = pos + 3;
1094
- return new LexerToken("URSHIFT", tokenTypeId("URSHIFT"), ">>>", ">>>", pos, 0, this.line, col);
1095
- }
1096
- this.pos = pos + 2;
1097
- return new LexerToken("RSHIFT", tokenTypeId("RSHIFT"), ">>", ">>", pos, 0, this.line, col);
1098
- }
1099
- if (this.hasPluginOps) {
1100
- const pluginInner = this.pluginOperators.get(c0);
1101
- if (pluginInner) {
1102
- const pluginType = pluginInner.get(c1);
1103
- if (pluginType) {
1104
- const text2 = input.slice(pos, pos + 2);
1105
- this.pos = pos + 2;
1106
- return new LexerToken(pluginType, tokenTypeId(pluginType), text2, text2, pos, 0, this.line, col);
1107
- }
1108
- }
1109
- }
1110
- }
1111
- this.pos = pos + 1;
1112
- if (c0 === 91) {
1113
- this.groupingStack.push(true);
1114
- } else if (c0 === 40) {
1115
- this.groupingStack.push(this.precededByCallTarget(pos));
1116
- } else if (c0 === 41 || c0 === 93) {
1117
- if (this.groupingStack.length > 0) this.groupingStack.pop();
1118
- }
1119
- const opType = OP_MAP[c0];
1120
- const text = input.charAt(pos);
1121
- return new LexerToken(opType || "ERROR", tokenTypeId(opType || "ERROR"), text, text, pos, 0, this.line, col);
1122
- }
1123
- // ── String literal tokenizer ──────────────────────────────────────────
1124
- /**
1125
- * Reads a double-quoted string literal. Supports backslash escapes.
1126
- *
1127
- * `text` is the raw source slice, quotes included, because that is what
1128
- * `offset` + `text.length` has to span for a host to underline the literal.
1129
- * `value` is the PAYLOAD, quotes excluded, because that is what
1130
- * `PUSH_STRING` puts into the Value.
1131
- *
1132
- * The two used to be the same string. `"abc"` carried the five characters
1133
- * `"abc"` as its value, which was invisible on screen (the formatter prints
1134
- * the payload raw and the retained quotes landed where a display would have
1135
- * put them back) and not invisible anywhere else: `parseFloat('"5"')` is NaN
1136
- * whatever the digits say, so `"5" + 5` answered 5.
1137
- *
1138
- * An unterminated literal is an error rather than a string that happens to
1139
- * reach the end of the line. It used to return what it had, so `"abc` and
1140
- * `"abc"` were indistinguishable by payload once the quotes were stripped,
1141
- * which is the other half of why they are stripped here rather than later.
1142
- */
1143
- tokenizeString() {
1144
- const input = this.input;
1145
- const len = this.len;
1146
- const start = this.pos;
1147
- const startCol = start - this.lineStartPos + 1;
1148
- let pos = start + 1;
1149
- let lineBreaks = 0;
1150
- while (pos < len) {
1151
- const c0 = input.charCodeAt(pos);
1152
- if (c0 === 34) {
1153
- pos++;
1154
- const text = input.slice(start, pos);
1155
- const value = input.slice(start + 1, pos - 1);
1156
- this.pos = pos;
1157
- return new LexerToken("STRING", tokenTypeId("STRING"), value, text, start, lineBreaks, this.line, startCol);
1158
- }
1159
- if (c0 === 92 && pos + 1 < len) {
1160
- pos += 2;
1161
- continue;
1162
- }
1163
- if (c0 === 10) {
1164
- this.line++;
1165
- this.lineStartPos = pos + 1;
1166
- lineBreaks++;
1167
- }
1168
- pos++;
1169
- }
1170
- this.pos = pos;
1171
- throw ErrorFactory.parsing(
1172
- "UNTERMINATED_STRING",
1173
- `Unterminated string literal: ${input.slice(start, pos)}`,
1174
- { literal: input.slice(start, pos), offset: start }
1175
- );
1176
- }
1177
- // ── Markdown line scanner (Phase B) ───────────────────────────────────
1178
- /**
1179
- * L1 expression gating: quickly determine if a line contains any
1180
- * characters that indicate an expression (digits, operators, currency,
1181
- * backticks, parentheses, etc.).
1182
- *
1183
- * Pure prose lines (e.g., "The quick brown fox jumps over the lazy dog")
1184
- * return false and can be skipped without full tokenization (L2).
1185
- *
1186
- * This is a fast character-by-character scan that stops at the first
1187
- * expression indicator. Called once per line in classifyFromPositions().
1188
- */
1189
- static hasExpressionIndicators(input, start, end) {
1190
- const indicatorCodes = EXPRESSION_INDICATOR_CODES;
1191
- for (let i = start; i < end; i++) {
1192
- const cc = input.charCodeAt(i);
1193
- if (indicatorCodes.has(cc)) return true;
1194
- if (cc >= 128) {
1195
- if (cc === 215 || cc === 247 || cc === 8800 || cc === 163 || cc === 8364 || cc === 165 || cc === 8381 || cc === 8361) {
1196
- return true;
1197
- }
1198
- }
1199
- }
1200
- return false;
1201
- }
1202
- /**
1203
- * Classify a line by its character positions within this.input.
1204
- * Reads directly from this.input using start/end boundaries.
1205
- * DOES NOT modify this.pos, purely a read-only classifier.
1206
- */
1207
- /**
1208
- * Advance past the whitespace after a list marker, and past a task-item
1209
- * checkbox if one follows.
1210
- *
1211
- * The checkbox is included because it is markup by the same argument the
1212
- * marker is, and because leaving it stopped the line dead: `- [ ] 100 + 20`
1213
- * lexed `[ ]` as a matrix literal and reported that a matrix cannot be
1214
- * empty, which tells a user writing a to-do list nothing they can act on.
1215
- *
1216
- * @param from - Offset just past the marker character.
1217
- * @param end - Line end, never read past.
1218
- * @returns Offset of the first evaluable character.
1219
- */
1220
- skipMarkerGap(from, end) {
1221
- const input = this.input;
1222
- let pos = from;
1223
- while (pos < end && (input.charCodeAt(pos) === 32 || input.charCodeAt(pos) === 9)) pos++;
1224
- if (pos + 2 < end && input.charCodeAt(pos) === 91 && input.charCodeAt(pos + 2) === 93) {
1225
- let after = pos + 3;
1226
- while (after < end && (input.charCodeAt(after) === 32 || input.charCodeAt(after) === 9)) after++;
1227
- if (after > pos + 3) return after;
1228
- }
1229
- return pos;
1230
- }
1231
- /**
1232
- * The end offset (exclusive) of a `#hex` colour literal starting at `hashPos`,
1233
- * or -1 if the run there is not one. A colour is `#` followed by EXACTLY 3, 4,
1234
- * 6 or 8 hex digits (the CSS forms `#rgb`/`#rgba`/`#rrggbb`/`#rrggbbaa`) and
1235
- * then a boundary, not a longer word or number. This is the one predicate that
1236
- * carves colours out of the two things `#` otherwise means, a markdown heading
1237
- * at line start and a comment mid-line, and it is pure character logic so line
1238
- * classification stays vocabulary-independent. Examples: `#f00`, `#ff0000`,
1239
- * `#deadbeef` match; `# Heading` (space), `#tag`/`#todo` (non-hex letter),
1240
- * `#12345` (length 5), `#ff0000zz` (trailing word) do not.
1241
- */
1242
- matchHexColourEnd(hashPos, end) {
1243
- const input = this.input;
1244
- let p = hashPos + 1;
1245
- let n = 0;
1246
- while (p < end) {
1247
- const c = input.charCodeAt(p);
1248
- const isHex = c >= 48 && c <= 57 || c >= 65 && c <= 70 || c >= 97 && c <= 102;
1249
- if (!isHex) break;
1250
- n++;
1251
- p++;
1252
- }
1253
- if (n !== 3 && n !== 4 && n !== 6 && n !== 8) return -1;
1254
- if (p < end) {
1255
- const c = input.charCodeAt(p);
1256
- const isWord = c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 97 && c <= 122 || c === 95;
1257
- if (isWord) return -1;
1258
- }
1259
- return p;
1260
- }
1261
- classifyFromPositions(start, end) {
1262
- const len = end;
1263
- if (start >= len) {
1264
- return { type: "empty", skip: true, hasInlineSolve: false };
1265
- }
1266
- const input = this.input;
1267
- let pos = start;
1268
- while (pos < len) {
1269
- const cc = input.charCodeAt(pos);
1270
- if (cc !== 32 && cc !== 9) break;
1271
- pos++;
1272
- }
1273
- if (pos >= len) {
1274
- return { type: "empty", skip: true, hasInlineSolve: false };
1275
- }
1276
- const c0 = input.charCodeAt(pos);
1277
- let hasInline;
1278
- if (c0 === 35) {
1279
- if (this.matchHexColourEnd(pos, len) !== -1) {
1280
- if (hasInline === void 0) {
1281
- const idx = input.indexOf("s`", pos);
1282
- hasInline = idx !== -1 && idx < len;
1283
- }
1284
- return { type: "expression", skip: false, hasInlineSolve: hasInline };
1285
- }
1286
- let hashCount = 1;
1287
- while (pos + hashCount < len && input.charCodeAt(pos + hashCount) === 35) {
1288
- hashCount++;
1289
- }
1290
- if (hashCount <= 6 && pos + hashCount < len && input.charCodeAt(pos + hashCount) === 32) {
1291
- return { type: "heading", skip: true, hasInlineSolve: false };
1292
- }
1293
- return { type: "heading", skip: true, hasInlineSolve: false };
1294
- }
1295
- if (c0 === 62) {
1296
- if (pos + 1 < len && input.charCodeAt(pos + 1) === 32) {
1297
- return { type: "blockquote", skip: true, hasInlineSolve: false };
1298
- }
1299
- }
1300
- if (c0 === 96 && pos + 2 < len && input.charCodeAt(pos + 1) === 96 && input.charCodeAt(pos + 2) === 96) {
1301
- return { type: "code_fence", skip: true, hasInlineSolve: false };
1302
- }
1303
- if (c0 === 126 && pos + 2 < len && input.charCodeAt(pos + 1) === 126 && input.charCodeAt(pos + 2) === 126) {
1304
- return { type: "code_fence", skip: true, hasInlineSolve: false };
1305
- }
1306
- if (c0 === 36 && pos + 1 < len && input.charCodeAt(pos + 1) === 36) {
1307
- return { type: "math_fence", skip: true, hasInlineSolve: false };
1308
- }
1309
- if (c0 === 45 || c0 === 42 || c0 === 95) {
1310
- let count = 1;
1311
- while (pos + count < len && input.charCodeAt(pos + count) === c0) {
1312
- count++;
1313
- }
1314
- if (count >= 3) {
1315
- let trailPos = pos + count;
1316
- while (trailPos < len && (input.charCodeAt(trailPos) === 32 || input.charCodeAt(trailPos) === 9)) {
1317
- trailPos++;
1318
- }
1319
- if (trailPos >= len) {
1320
- return { type: "hr", skip: true, hasInlineSolve: false };
1321
- }
1322
- }
1323
- }
1324
- if ((c0 === 45 || c0 === 42 || c0 === 43) && pos + 1 < len && input.charCodeAt(pos + 1) === 32) {
1325
- if (hasInline === void 0) {
1326
- const idx = input.indexOf("s`", pos);
1327
- hasInline = idx !== -1 && idx < len;
1328
- }
1329
- return { type: "list", skip: false, hasInlineSolve: hasInline, contentOffset: this.skipMarkerGap(pos + 1, len) };
1330
- }
1331
- if (c0 >= 48 && c0 <= 57) {
1332
- let digitPos = pos;
1333
- while (digitPos < len && input.charCodeAt(digitPos) >= 48 && input.charCodeAt(digitPos) <= 57) {
1334
- digitPos++;
1335
- }
1336
- if (digitPos < len && input.charCodeAt(digitPos) === 46) {
1337
- if (digitPos + 1 < len && input.charCodeAt(digitPos + 1) === 32) {
1338
- if (hasInline === void 0) {
1339
- const idx = input.indexOf("s`", pos);
1340
- hasInline = idx !== -1 && idx < len;
1341
- }
1342
- return { type: "list", skip: false, hasInlineSolve: hasInline, contentOffset: this.skipMarkerGap(digitPos + 1, len) };
1343
- }
1344
- }
1345
- }
1346
- if (c0 === 124) {
1347
- let tPos = pos + 1;
1348
- while (tPos < len) {
1349
- const tc = input.charCodeAt(tPos);
1350
- if (tc !== 45 && tc !== 58 && tc !== 124 && tc !== 32 && tc !== 9 && tc !== 13) break;
1351
- tPos++;
1352
- }
1353
- if (tPos >= len) {
1354
- return { type: "table_separator", skip: true, hasInlineSolve: false };
1355
- }
1356
- }
1357
- if (c0 === 91 && pos + 1 < len && input.charCodeAt(pos + 1) === 91) {
1358
- const closePos = input.indexOf("]]", pos + 2);
1359
- if (closePos !== -1 && closePos < len) {
1360
- let trailPos = closePos + 2;
1361
- while (trailPos < len && (input.charCodeAt(trailPos) === 32 || input.charCodeAt(trailPos) === 9)) {
1362
- trailPos++;
1363
- }
1364
- if (trailPos >= len) {
1365
- return { type: "wikilink", skip: true, hasInlineSolve: false };
1366
- }
1367
- }
1368
- }
1369
- if (c0 === 33 && pos + 2 < len && input.charCodeAt(pos + 1) === 91 && input.charCodeAt(pos + 2) === 91) {
1370
- const closePos = input.indexOf("]]", pos + 3);
1371
- if (closePos !== -1 && closePos < len) {
1372
- let trailPos = closePos + 2;
1373
- while (trailPos < len && (input.charCodeAt(trailPos) === 32 || input.charCodeAt(trailPos) === 9)) {
1374
- trailPos++;
1375
- }
1376
- if (trailPos >= len) {
1377
- return { type: "wikilink", skip: true, hasInlineSolve: false };
1378
- }
1379
- }
1380
- }
1381
- if (c0 === 47 && pos + 1 < len && input.charCodeAt(pos + 1) === 47) {
1382
- return { type: "comment", skip: true, hasInlineSolve: false };
1383
- }
1384
- if (c0 === 62) {
1385
- let trail = pos + 1;
1386
- while (trail < len && (input.charCodeAt(trail) === 32 || input.charCodeAt(trail) === 9)) trail++;
1387
- if (trail >= len) return { type: "blockquote", skip: true, hasInlineSolve: false };
1388
- }
1389
- if (c0 === 45 || c0 === 42 || c0 === 43) {
1390
- let trail = pos + 1;
1391
- while (trail < len && (input.charCodeAt(trail) === 32 || input.charCodeAt(trail) === 9)) trail++;
1392
- if (trail >= len) return { type: "list", skip: false, hasInlineSolve: false };
1393
- }
1394
- if (hasInline === void 0) {
1395
- const idx = input.indexOf("s`", pos);
1396
- hasInline = idx !== -1 && idx < len;
1397
- }
1398
- if (!hasInline) {
1399
- let onlySkippable = true;
1400
- for (let i = pos; i < len; i++) {
1401
- const code = input.charCodeAt(i);
1402
- if (code >= 128 || _ExpressionLexer.CHAR_CLASS[code] > 1 /* WHITESPACE */) {
1403
- onlySkippable = false;
1404
- break;
1405
- }
1406
- }
1407
- if (onlySkippable) {
1408
- return { type: "empty", skip: true, hasInlineSolve: false };
1409
- }
1410
- }
1411
- return { type: "expression", skip: false, hasInlineSolve: hasInline };
1412
- }
1413
- /**
1414
- * Classify a single line of markdown text.
1415
- */
1416
- classifyLine(lineText) {
1417
- const savedInput = this.input;
1418
- const savedLen = this.len;
1419
- const savedPos = this.pos;
1420
- this.input = lineText;
1421
- this.len = lineText.length;
1422
- this.pos = 0;
1423
- const result = this.classifyFromPositions(0, lineText.length);
1424
- this.input = savedInput;
1425
- this.len = savedLen;
1426
- this.pos = savedPos;
1427
- return result;
1428
- }
1429
- /**
1430
- * Every keyword this lexer currently recognizes, locale keywords
1431
- * (`pi`, `sqrt`, `convert`, ...) merged with any plugin-contributed ones
1432
- * from `registerVocabulary()` (e.g. a package's custom keywords), mapped to
1433
- * the token type they lex to. A snapshot copy, not a live reference
1434
- * mutating the return value has no effect on the lexer.
1435
- */
1436
- getKeywords() {
1437
- return Object.fromEntries(this.mergedKeywords);
1438
- }
1439
- /**
1440
- * Find all inline solve markers in a line with precise coordinate mapping.
1441
- */
1442
- findInlineSolves(lineText) {
1443
- const results = [];
1444
- const len = lineText.length;
1445
- let pos = 0;
1446
- while (pos < len) {
1447
- const sPos = lineText.indexOf("s`", pos);
1448
- if (sPos === -1) break;
1449
- const exprStart = sPos + 2;
1450
- let exprEnd = exprStart;
1451
- while (exprEnd < len) {
1452
- const cc = lineText.charCodeAt(exprEnd);
1453
- if (cc === 92 && exprEnd + 1 < len) {
1454
- exprEnd += 2;
1455
- continue;
1456
- }
1457
- if (cc === 96) break;
1458
- exprEnd++;
1459
- }
1460
- if (exprEnd >= len) {
1461
- exprEnd = len;
1462
- }
1463
- const expression = lineText.slice(exprStart, exprEnd);
1464
- const end = exprEnd < len ? exprEnd + 1 : exprEnd;
1465
- results.push({
1466
- start: sPos,
1467
- end,
1468
- expression,
1469
- columnNumber: sPos + 1
1470
- });
1471
- pos = end;
1472
- }
1473
- return results;
1474
- }
1475
- // ── Comment tokenizer ─────────────────────────────────────────────────
1476
- /**
1477
- * Reads a comment: # to end of line, or // to end of line.
1478
- */
1479
- tokenizeComment() {
1480
- const input = this.input;
1481
- const len = this.len;
1482
- const start = this.pos;
1483
- const startCol = start - this.lineStartPos + 1;
1484
- if (input.charCodeAt(start) === 35) {
1485
- const hexEnd = this.matchHexColourEnd(start, len);
1486
- if (hexEnd !== -1) {
1487
- const text2 = input.slice(start, hexEnd);
1488
- this.pos = hexEnd;
1489
- return new LexerToken("HEX_COLOUR", tokenTypeId("HEX_COLOUR"), text2, text2, start, 0, this.line, startCol);
1490
- }
1491
- }
1492
- let pos = this.pos;
1493
- if (pos + 1 < len && input.charCodeAt(pos + 1) === 47) {
1494
- pos += 2;
1495
- } else {
1496
- pos++;
1497
- }
1498
- while (pos < len) {
1499
- const c0 = input.charCodeAt(pos);
1500
- if (c0 === 10 || c0 === 13) break;
1501
- pos++;
1502
- }
1503
- const text = input.slice(start, pos);
1504
- this.pos = pos;
1505
- return new LexerToken("COMMENT", tokenTypeId("COMMENT"), text, text, start, 0, this.line, startCol);
1506
- }
1507
- };
1508
- _ExpressionLexer.CHAR_CLASS = buildCharClassTable();
1509
- var ExpressionLexer = _ExpressionLexer;
1510
-
1511
- export { ExpressionLexer, LexerToken };
1512
- //# sourceMappingURL=chunk-JG6ZJ2WU.js.map
1513
- //# sourceMappingURL=chunk-JG6ZJ2WU.js.map