solve-engine 1.0.2 → 1.1.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 (237) hide show
  1. package/dist/{BytecodeBuilder-B0xskcv5.d.cts → BytecodeBuilder-Bp9xeTmX.d.cts} +4 -0
  2. package/dist/{BytecodeBuilder-B0xskcv5.d.ts → BytecodeBuilder-Bp9xeTmX.d.ts} +4 -0
  3. package/dist/{Configuration-B-G5gTRn.d.cts → Configuration-C9W8tJv_.d.cts} +53 -1
  4. package/dist/{Configuration-B-G5gTRn.d.ts → Configuration-C9W8tJv_.d.ts} +53 -1
  5. package/dist/{EngineError-LU7W7AgI.d.cts → EngineError-B61GS1jp.d.cts} +14 -0
  6. package/dist/{EngineError-LU7W7AgI.d.ts → EngineError-B61GS1jp.d.ts} +14 -0
  7. package/dist/FormattingSettings-CJHyxcYu.d.cts +27 -0
  8. package/dist/FormattingSettings-CJHyxcYu.d.ts +27 -0
  9. package/dist/{Lexer-DpjdaQ98.d.cts → Lexer-BOs7euZe.d.cts} +28 -1
  10. package/dist/{Lexer-CNmWxabg.d.ts → Lexer-CSI_lwbW.d.ts} +28 -1
  11. package/dist/PackageCompatibility-B-7rK1TD.d.cts +76 -0
  12. package/dist/PackageCompatibility-Dh59eF-X.d.ts +76 -0
  13. package/dist/{PackageRegistry-zuzqt51V.d.cts → PackageRegistry-BHWJP83F.d.cts} +449 -11
  14. package/dist/{PackageRegistry-ClIFXxAe.d.ts → PackageRegistry-_8rDlvxI.d.ts} +449 -11
  15. package/dist/{Parselet-BaySkMV3.d.ts → Parselet-BBT8riYh.d.ts} +12 -3
  16. package/dist/{Parselet-DuI1Pjiq.d.cts → Parselet-BHcgK9S7.d.cts} +12 -3
  17. package/dist/{ScopeManager-B6GzdhVG.d.cts → ScopeManager-8vf02dwj.d.cts} +56 -5
  18. package/dist/{ScopeManager-udv4Twwq.d.ts → ScopeManager-CxA24W5n.d.ts} +56 -5
  19. package/dist/{Token-BzG5G4ja.d.cts → Token-B1hdkedD.d.cts} +9 -0
  20. package/dist/{Token-BzG5G4ja.d.ts → Token-B1hdkedD.d.ts} +9 -0
  21. package/dist/{TokenNormalizer-t_GotBxr.d.ts → TokenNormalizer-C6VzZgHa.d.ts} +1 -1
  22. package/dist/{TokenNormalizer-DGVa24Q-.d.cts → TokenNormalizer-DRc1Js1V.d.cts} +1 -1
  23. package/dist/{VMCheckpoints-DwLjivM7.d.cts → VMCheckpoints-ELYqITdF.d.cts} +3 -3
  24. package/dist/{VMCheckpoints-BiaIlOOY.d.ts → VMCheckpoints-MK--EBH2.d.ts} +3 -3
  25. package/dist/{Value-CXJqDH9J.d.cts → Value-BUi1RA3S.d.cts} +124 -5
  26. package/dist/{Value-CXJqDH9J.d.ts → Value-BUi1RA3S.d.ts} +124 -5
  27. package/dist/WorkerError-_-RkoQ5P.d.ts +75 -0
  28. package/dist/WorkerError-gzmaopj2.d.cts +75 -0
  29. package/dist/{chunk-GQCOSXMG.js → chunk-267JPOTF.js} +43 -5
  30. package/dist/chunk-267JPOTF.js.map +1 -0
  31. package/dist/{chunk-JMXUNXQS.cjs → chunk-2TZKENDH.cjs} +51 -8
  32. package/dist/chunk-2TZKENDH.cjs.map +1 -0
  33. package/dist/chunk-3OWCDIPN.js +215 -0
  34. package/dist/chunk-3OWCDIPN.js.map +1 -0
  35. package/dist/{chunk-VB37OC6I.js → chunk-4D6NIHE2.js} +40 -3
  36. package/dist/chunk-4D6NIHE2.js.map +1 -0
  37. package/dist/{chunk-TY3TLZAW.cjs → chunk-536WPM2V.cjs} +18 -2
  38. package/dist/chunk-536WPM2V.cjs.map +1 -0
  39. package/dist/chunk-5HRB36DK.js +405 -0
  40. package/dist/chunk-5HRB36DK.js.map +1 -0
  41. package/dist/chunk-5ON7PUAZ.js +12 -0
  42. package/dist/chunk-5ON7PUAZ.js.map +1 -0
  43. package/dist/{chunk-KV7UW6T6.js → chunk-7KYSUDQO.js} +12 -5
  44. package/dist/chunk-7KYSUDQO.js.map +1 -0
  45. package/dist/{chunk-6WFMPTGB.cjs → chunk-7ZX6B7SY.cjs} +774 -528
  46. package/dist/chunk-7ZX6B7SY.cjs.map +1 -0
  47. package/dist/chunk-ALYRJ72W.cjs +434 -0
  48. package/dist/chunk-ALYRJ72W.cjs.map +1 -0
  49. package/dist/{chunk-5KMIY374.cjs → chunk-B4HBEFTB.cjs} +17 -2
  50. package/dist/chunk-B4HBEFTB.cjs.map +1 -0
  51. package/dist/chunk-B7NLZMQ3.cjs +74 -0
  52. package/dist/chunk-B7NLZMQ3.cjs.map +1 -0
  53. package/dist/{chunk-UQ3UIZJC.js → chunk-BLI4NIQY.js} +6 -2
  54. package/dist/chunk-BLI4NIQY.js.map +1 -0
  55. package/dist/{chunk-T556MJDZ.cjs → chunk-C75AFGVD.cjs} +11 -11
  56. package/dist/{chunk-T556MJDZ.cjs.map → chunk-C75AFGVD.cjs.map} +1 -1
  57. package/dist/{chunk-G535KJEG.js → chunk-CCBZZQAE.js} +2 -2
  58. package/dist/{chunk-G535KJEG.js.map → chunk-CCBZZQAE.js.map} +1 -1
  59. package/dist/chunk-CKQMXMHR.cjs +219 -0
  60. package/dist/chunk-CKQMXMHR.cjs.map +1 -0
  61. package/dist/{chunk-PFUESQTW.cjs → chunk-EJ3ILXX6.cjs} +48 -2
  62. package/dist/chunk-EJ3ILXX6.cjs.map +1 -0
  63. package/dist/{chunk-526PMQOA.js → chunk-ENKKJYD3.js} +10 -4
  64. package/dist/chunk-ENKKJYD3.js.map +1 -0
  65. package/dist/{chunk-5X2PTP6F.cjs → chunk-ENRIK36Q.cjs} +2 -12
  66. package/dist/chunk-ENRIK36Q.cjs.map +1 -0
  67. package/dist/{chunk-3D7V24DG.js → chunk-ERCOHGXD.js} +17 -2
  68. package/dist/chunk-ERCOHGXD.js.map +1 -0
  69. package/dist/{chunk-IF532O7C.js → chunk-FD5ZZHEU.js} +3 -12
  70. package/dist/chunk-FD5ZZHEU.js.map +1 -0
  71. package/dist/{chunk-7FSDNNNC.js → chunk-G7Z4HJQA.js} +11 -5
  72. package/dist/chunk-G7Z4HJQA.js.map +1 -0
  73. package/dist/{chunk-FQGX2PA2.js → chunk-GQMUHVE3.js} +115 -4
  74. package/dist/chunk-GQMUHVE3.js.map +1 -0
  75. package/dist/chunk-GUG7SNSV.js +1764 -0
  76. package/dist/chunk-GUG7SNSV.js.map +1 -0
  77. package/dist/{chunk-UM6BVY2S.cjs → chunk-HIQ5HSZL.cjs} +175 -43
  78. package/dist/chunk-HIQ5HSZL.cjs.map +1 -0
  79. package/dist/{chunk-HVQFNJKE.cjs → chunk-HVRVSI2Z.cjs} +104 -86
  80. package/dist/chunk-HVRVSI2Z.cjs.map +1 -0
  81. package/dist/{chunk-3LAEG75D.js → chunk-I4GAWIPW.js} +24 -6
  82. package/dist/chunk-I4GAWIPW.js.map +1 -0
  83. package/dist/{chunk-PA4VC73I.cjs → chunk-J45BCEZ4.cjs} +33 -27
  84. package/dist/chunk-J45BCEZ4.cjs.map +1 -0
  85. package/dist/{chunk-NG2JHZHE.js → chunk-JIPATHVY.js} +1853 -2640
  86. package/dist/chunk-JIPATHVY.js.map +1 -0
  87. package/dist/{chunk-IP7ASJEW.js → chunk-JJIXHXFQ.js} +5 -5
  88. package/dist/{chunk-IP7ASJEW.js.map → chunk-JJIXHXFQ.js.map} +1 -1
  89. package/dist/chunk-L2TE7PMO.cjs +14 -0
  90. package/dist/chunk-L2TE7PMO.cjs.map +1 -0
  91. package/dist/{chunk-HBVFFBRR.cjs → chunk-MG6Q3DUO.cjs} +1962 -2748
  92. package/dist/chunk-MG6Q3DUO.cjs.map +1 -0
  93. package/dist/{chunk-R3PY4G7J.js → chunk-MVTOCRV2.js} +48 -3
  94. package/dist/chunk-MVTOCRV2.js.map +1 -0
  95. package/dist/{chunk-Y7FT4IQT.js → chunk-NKW7LKYU.js} +266 -28
  96. package/dist/chunk-NKW7LKYU.js.map +1 -0
  97. package/dist/{chunk-O3ANBHSA.js → chunk-NNQ2TYDF.js} +123 -5
  98. package/dist/chunk-NNQ2TYDF.js.map +1 -0
  99. package/dist/{chunk-AA3KTWTX.js → chunk-OADDUPT3.js} +4 -4
  100. package/dist/{chunk-AA3KTWTX.js.map → chunk-OADDUPT3.js.map} +1 -1
  101. package/dist/{chunk-SESSWASV.cjs → chunk-OTN6SZOD.cjs} +1868 -393
  102. package/dist/chunk-OTN6SZOD.cjs.map +1 -0
  103. package/dist/{chunk-5LI5EPGJ.cjs → chunk-QFTDTX6K.cjs} +40 -3
  104. package/dist/chunk-QFTDTX6K.cjs.map +1 -0
  105. package/dist/{chunk-YXCTLWOH.js → chunk-RRLHC37V.js} +1530 -57
  106. package/dist/chunk-RRLHC37V.js.map +1 -0
  107. package/dist/chunk-SNHVVOJK.cjs +1768 -0
  108. package/dist/chunk-SNHVVOJK.cjs.map +1 -0
  109. package/dist/{chunk-HDP7VK3C.cjs → chunk-SRGQ72IR.cjs} +649 -349
  110. package/dist/chunk-SRGQ72IR.cjs.map +1 -0
  111. package/dist/{chunk-4B2CNWQU.cjs → chunk-SSV46KFA.cjs} +14 -7
  112. package/dist/chunk-SSV46KFA.cjs.map +1 -0
  113. package/dist/{chunk-AJA6LUI7.js → chunk-UO6BUV6K.js} +18 -2
  114. package/dist/chunk-UO6BUV6K.js.map +1 -0
  115. package/dist/chunk-WWQEY7BV.js +67 -0
  116. package/dist/chunk-WWQEY7BV.js.map +1 -0
  117. package/dist/{chunk-5WVP4YHP.js → chunk-WXEHD6TT.js} +333 -33
  118. package/dist/chunk-WXEHD6TT.js.map +1 -0
  119. package/dist/{chunk-47LRVGOT.cjs → chunk-XA4CKRML.cjs} +2 -2
  120. package/dist/{chunk-47LRVGOT.cjs.map → chunk-XA4CKRML.cjs.map} +1 -1
  121. package/dist/{chunk-6KFYJ6TD.cjs → chunk-XIYYHA65.cjs} +6 -2
  122. package/dist/chunk-XIYYHA65.cjs.map +1 -0
  123. package/dist/{chunk-FE23VSSA.cjs → chunk-XJGJCF2R.cjs} +6 -6
  124. package/dist/{chunk-FE23VSSA.cjs.map → chunk-XJGJCF2R.cjs.map} +1 -1
  125. package/dist/{chunk-R7YVBHCV.cjs → chunk-YTIYVHL7.cjs} +184 -73
  126. package/dist/chunk-YTIYVHL7.cjs.map +1 -0
  127. package/dist/{chunk-TMA4RCEN.js → chunk-Z7XGGLI2.js} +3 -3
  128. package/dist/{chunk-TMA4RCEN.js.map → chunk-Z7XGGLI2.js.map} +1 -1
  129. package/dist/{chunk-A2N2GFCG.cjs → chunk-ZVTWQLK4.cjs} +10 -10
  130. package/dist/{chunk-A2N2GFCG.cjs.map → chunk-ZVTWQLK4.cjs.map} +1 -1
  131. package/dist/{chunk-524F3ATQ.cjs → chunk-ZXCESUJS.cjs} +15 -9
  132. package/dist/chunk-ZXCESUJS.cjs.map +1 -0
  133. package/dist/constants.cjs +5 -5
  134. package/dist/constants.d.cts +1 -1
  135. package/dist/constants.d.ts +1 -1
  136. package/dist/constants.js +2 -2
  137. package/dist/engine.cjs +52 -35
  138. package/dist/engine.d.cts +13 -13
  139. package/dist/engine.d.ts +13 -13
  140. package/dist/engine.js +26 -21
  141. package/dist/errors.cjs +44 -19
  142. package/dist/errors.d.cts +3 -2
  143. package/dist/errors.d.ts +3 -2
  144. package/dist/errors.js +2 -1
  145. package/dist/format.cjs +19 -169
  146. package/dist/format.cjs.map +1 -1
  147. package/dist/format.d.cts +18 -26
  148. package/dist/format.d.ts +18 -26
  149. package/dist/format.js +7 -171
  150. package/dist/format.js.map +1 -1
  151. package/dist/index.cjs +250 -31
  152. package/dist/index.cjs.map +1 -1
  153. package/dist/index.d.cts +110 -74
  154. package/dist/index.d.ts +110 -74
  155. package/dist/index.js +228 -23
  156. package/dist/index.js.map +1 -1
  157. package/dist/language.cjs +9 -9
  158. package/dist/language.d.cts +12 -12
  159. package/dist/language.d.ts +12 -12
  160. package/dist/language.js +3 -3
  161. package/dist/lexer.cjs +16 -16
  162. package/dist/lexer.d.cts +3 -3
  163. package/dist/lexer.d.ts +3 -3
  164. package/dist/lexer.js +5 -5
  165. package/dist/normalizer.cjs +10 -10
  166. package/dist/normalizer.d.cts +3 -3
  167. package/dist/normalizer.d.ts +3 -3
  168. package/dist/normalizer.js +4 -4
  169. package/dist/packages.cjs +45 -36
  170. package/dist/packages.d.cts +135 -31
  171. package/dist/packages.d.ts +135 -31
  172. package/dist/packages.js +14 -13
  173. package/dist/parser.cjs +16 -16
  174. package/dist/parser.d.cts +6 -5
  175. package/dist/parser.d.ts +6 -5
  176. package/dist/parser.js +6 -6
  177. package/dist/{pipeline-BEb3hujr.d.cts → pipeline-CtfJtPQc.d.cts} +3 -3
  178. package/dist/{pipeline-B6k5lCB7.d.ts → pipeline-DCd5M6Gk.d.ts} +3 -3
  179. package/dist/resolvers.d.cts +3 -3
  180. package/dist/resolvers.d.ts +3 -3
  181. package/dist/testing.cjs +478 -0
  182. package/dist/testing.cjs.map +1 -0
  183. package/dist/testing.d.cts +271 -0
  184. package/dist/testing.d.ts +271 -0
  185. package/dist/testing.js +470 -0
  186. package/dist/testing.js.map +1 -0
  187. package/dist/uom.cjs +16 -16
  188. package/dist/uom.d.cts +3 -3
  189. package/dist/uom.d.ts +3 -3
  190. package/dist/uom.js +6 -6
  191. package/dist/utilities.cjs +6 -5
  192. package/dist/utilities.js +2 -1
  193. package/dist/vm.cjs +34 -34
  194. package/dist/vm.d.cts +8 -8
  195. package/dist/vm.d.ts +8 -8
  196. package/dist/vm.js +9 -9
  197. package/dist/worker.cjs +493 -0
  198. package/dist/worker.cjs.map +1 -0
  199. package/dist/worker.d.cts +509 -0
  200. package/dist/worker.d.ts +509 -0
  201. package/dist/worker.js +484 -0
  202. package/dist/worker.js.map +1 -0
  203. package/package.json +21 -1
  204. package/dist/chunk-3D7V24DG.js.map +0 -1
  205. package/dist/chunk-3LAEG75D.js.map +0 -1
  206. package/dist/chunk-4B2CNWQU.cjs.map +0 -1
  207. package/dist/chunk-524F3ATQ.cjs.map +0 -1
  208. package/dist/chunk-526PMQOA.js.map +0 -1
  209. package/dist/chunk-5KMIY374.cjs.map +0 -1
  210. package/dist/chunk-5LI5EPGJ.cjs.map +0 -1
  211. package/dist/chunk-5WVP4YHP.js.map +0 -1
  212. package/dist/chunk-5X2PTP6F.cjs.map +0 -1
  213. package/dist/chunk-6KFYJ6TD.cjs.map +0 -1
  214. package/dist/chunk-6WFMPTGB.cjs.map +0 -1
  215. package/dist/chunk-7FSDNNNC.js.map +0 -1
  216. package/dist/chunk-AJA6LUI7.js.map +0 -1
  217. package/dist/chunk-FQGX2PA2.js.map +0 -1
  218. package/dist/chunk-GQCOSXMG.js.map +0 -1
  219. package/dist/chunk-HBVFFBRR.cjs.map +0 -1
  220. package/dist/chunk-HDP7VK3C.cjs.map +0 -1
  221. package/dist/chunk-HVQFNJKE.cjs.map +0 -1
  222. package/dist/chunk-IF532O7C.js.map +0 -1
  223. package/dist/chunk-JMXUNXQS.cjs.map +0 -1
  224. package/dist/chunk-KV7UW6T6.js.map +0 -1
  225. package/dist/chunk-NG2JHZHE.js.map +0 -1
  226. package/dist/chunk-O3ANBHSA.js.map +0 -1
  227. package/dist/chunk-PA4VC73I.cjs.map +0 -1
  228. package/dist/chunk-PFUESQTW.cjs.map +0 -1
  229. package/dist/chunk-R3PY4G7J.js.map +0 -1
  230. package/dist/chunk-R7YVBHCV.cjs.map +0 -1
  231. package/dist/chunk-SESSWASV.cjs.map +0 -1
  232. package/dist/chunk-TY3TLZAW.cjs.map +0 -1
  233. package/dist/chunk-UM6BVY2S.cjs.map +0 -1
  234. package/dist/chunk-UQ3UIZJC.js.map +0 -1
  235. package/dist/chunk-VB37OC6I.js.map +0 -1
  236. package/dist/chunk-Y7FT4IQT.js.map +0 -1
  237. package/dist/chunk-YXCTLWOH.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/parser/BindingPower.ts","../src/parser/BytecodeBuilder.ts","../src/parser/BigIntLiteral.ts"],"names":["TokenTypes","tokenTypeId","ErrorFactory","getLocale"],"mappings":";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,CAAY,IAAA,CAAK,aAAa,CAAA,EAAG,OAAO,aAAA;AAE5C,EAAA,MAAM,MAAA,GAAS,4BAAA,CAA6B,IAAA,CAAK,aAAa,IAC3D,aAAA,CAAc,KAAA,CAAM,GAAG,CAAA,CAAE,IAAA,CAAK,EAAE,CAAA,GAChC,mBAAA,CAAoB,eAAe,UAAU,CAAA;AAEhD,EAAA,IAAI,CAAC,WAAA,CAAY,IAAA,CAAK,MAAM,CAAA,EAAG;AAC9B,IAAA,MAAM,SAAA,GAAY,aAAA,CAAc,QAAA,CAAS,GAAG,CAAA,GAAI,MAAM,aAAA,CAAc,QAAA,CAAS,GAAG,CAAA,GAAI,GAAA,GAAM,aAAA;AAC1F,IAAA,MAAMA,8BAAA,CAAa,OAAA;AAAA,MAClB,wBAAA;AAAA,MACA,CAAA,CAAA,EAAI,GAAG,CAAA,0BAAA,EAA6B,SAAS,+BAA+B,UAAU,CAAA,0DAAA,CAAA;AAAA,MACtF,EAAE,GAAA,EAAK,UAAA,EAAY,SAAA;AAAU,KAC9B;AAAA,EACD;AACA,EAAA,OAAO,MAAA;AACR;AASA,SAAS,mBAAA,CAAoB,MAAc,UAAA,EAA4B;AACtE,EAAA,MAAM,kBAAA,GAAqBC,2BAAA,CAAU,UAAU,CAAA,CAAE,OAAA,CAAQ,kBAAA;AACzD,EAAA,OAAO,qBAAqB,IAAA,CAAK,KAAA,CAAM,kBAAkB,CAAA,CAAE,IAAA,CAAK,EAAE,CAAA,GAAI,IAAA;AACvE","file":"chunk-PA4VC73I.cjs","sourcesContent":["/**\n * Named precedence levels for the Pratt parser, from loosest (`Lowest`) to\n * tightest (`Call`) binding. A custom infix parselet compares its own\n * binding power against the current expression's to decide whether to\n * consume the next operator (higher power binds tighter, e.g. `*` over `+`).\n *\n * Package authors reference these when registering an infix parselet via\n * `IPackageRegistry.registerInfixParselet`. See the built-in packages for\n * examples of picking an appropriate level (e.g. arithmetic `+`/`-` use\n * `Sum`, `*`/`/` use `Product`).\n */\nexport const BindingPower = {\n Lowest: 0,\n Assignment: 10,\n LogicalOr: 12, // `or`, `||` — loosest of the boolean-logic operators\n LogicalAnd: 14, // `&&` — binds tighter than `or` (\"a or b and c\" = \"a or (b and c)\")\n // The word \"and\" (`AND_CONJ`), which is both arithmetic addition (\"5 and 3\"\n // is 8) and boolean conjunction (\"true and false\"). A phrase parselet\n // collecting a list (\"average of X, Y and Z\") parses each argument at this\n // level, and an argument stops at any operator whose power is <= the level it\n // was parsed at, so putting \"and\" here is what makes it end an argument\n // rather than be consumed as the addition it also is. Everything an argument\n // should keep binds tighter, including a genuine \"+\" (`Sum`).\n //\n // It sits BELOW `Conditional` because the boolean reading needs comparisons\n // to be its operands: at 28, \"5 > 3 and 2 > 1\" parsed as \"5 > (3 and 2) > 1\"\n // and answered false. Above `LogicalAnd` so that \"and\" is still the tighter\n // of the two conjunctions, and two steps off each neighbour to leave room.\n Conjunction: 16,\n // The bitwise trio and the shifts, ordered exactly as C and JavaScript order\n // them, which is the order every language that borrowed these operators from\n // C uses: `|` looser than `xor`, `xor` looser than `&`, all three looser than\n // comparison, and the shifts tighter than comparison but looser than `+`.\n // They used to share one level (35) between `Sum` and `Product`, so\n // \"1 + 2 << 3\" answered 17 where JavaScript answers 24 and \"4 & 3 + 1\"\n // answered 1 where JavaScript answers 4. Each has its own level now because\n // a shared level makes \"4 | 6 & 3\" group left instead of letting `&` win.\n //\n // They stay TIGHTER than `Conjunction` so that a phrase argument parsed at\n // that level (\"average of 5 | 3, 2 and 4\") keeps its bitwise operators\n // instead of stopping at the first one.\n BitwiseOr: 18, // `|`\n BitwiseXor: 20, // the `xor` keyword (`BIT_XOR`), not the `^` exponent token\n BitwiseAnd: 22, // `&`\n Conditional: 24, // comparisons (`==`, `<`, `>=`, ...), tighter than the bitwise trio, looser than the shifts\n Shift: 27, // `<<`, `>>`, `>>>`\n Sum: 30,\n Product: 40,\n // `^`, RIGHT-associative: \"2 ^ 3 ^ 2\" is 2^(3^2) = 512, as in mathematics,\n // Python, Ruby and JavaScript's `**`. See PrecedenceParser.parseExpression\n // and BinaryOpParselet for the two places that associativity is implemented.\n Exponent: 50,\n Prefix: 60,\n Postfix: 70,\n Call: 80,\n} as const;\n\n/**\n * Set the binding power of a named operator.\n *\n * Binding power is what decides precedence in the Pratt parser: a higher number\n * binds tighter, so `*` outranks `+`. Changing one changes how every existing\n * expression using that operator parses, which is why packages should allocate\n * a new name rather than adjust a built-in.\n *\n * @param name - Operator name.\n * @param power - Higher binds tighter.\n */\nexport function setBindingPower(name: string, power: number): void {\n (BindingPower as Record<string, number>)[name] = power;\n}\n\n/**\n * Read the binding power of a named operator.\n *\n * @param name - Operator name.\n * @returns Its binding power, or 0 when the name is unknown, which makes an\n * unregistered operator terminate an expression rather than swallow the rest\n * of it.\n */\nexport function getBindingPower(name: string): number {\n return (BindingPower as Record<string, number>)[name] ?? 0;\n}\n\n// ── Built-in Infix Operator Binding Power Table ──────────────────────────────\n// Pre-computed Uint8Array lookup indexed by token typeId.\n// value > 0 → built-in infix operator with that binding power\n// value = 0 → not a built-in infix, fall through to Tier 2 parselet registry\n//\n// Built at module load via buildBindingPowerTable(). The table is sparse\n// most entries are 0 since only ~15 of 80+ token types are infix operators.\n//\n// Performance: Uint8Array[typeId] is a single typed array load, no Map.get()\n// no string hashing, no property chain. V8 eliminates bounds checks when typeId\n// is known to be within array length.\n\nimport { TokenTypes } from \"@solve-js/lexer/Token\";\nimport { tokenTypeId } from \"@solve-js/lexer/Token\";\n\n/**\n * Mapping of token type names → binding powers for built-in infix operators.\n * Only operators listed here get the Tier 1 fast path in PrecedenceParser.\n * All other infix tokens use the Tier 2 parselet registry fallback.\n */\nconst BUILTIN_INFIX_BP: Record<string, number> = {\n // Arithmetic (infix, left-associative)\n [TokenTypes.PLUS]: BindingPower.Sum,\n [TokenTypes.MINUS]: BindingPower.Sum,\n [TokenTypes.STAR]: BindingPower.Product,\n [TokenTypes.SLASH]: BindingPower.Product,\n [TokenTypes.MOD]: BindingPower.Product,\n\n // Arithmetic (infix, RIGHT-associative, PrecedenceParser handles this specially)\n [TokenTypes.CARET]: BindingPower.Exponent,\n\n // Bitwise and shift (infix, left-associative), one level each, ordered as C\n // and JavaScript order them. `>>>` used to be missing from this table\n // entirely, which left it running at its Tier 2 parselet level while `>>`\n // ran at the Tier 1 one, so \"16 >> 3 & 1\" and \"16 >>> 3 & 1\" grouped\n // differently and answered 0 and 8.\n [TokenTypes.BIT_OR]: BindingPower.BitwiseOr,\n [TokenTypes.BIT_XOR]: BindingPower.BitwiseXor,\n [TokenTypes.BIT_AND]: BindingPower.BitwiseAnd,\n [TokenTypes.LSHIFT]: BindingPower.Shift,\n [TokenTypes.RSHIFT]: BindingPower.Shift,\n [TokenTypes.URSHIFT]: BindingPower.Shift,\n\n // Postfix (no right operand, PrecedenceParser handles this specially)\n [TokenTypes.PERCENT]: BindingPower.Postfix,\n\n // Percentage keyword (infix, left-associative: \"50% of 200\" → MUL)\n [TokenTypes.OF]: BindingPower.Product,\n};\n\n// Note: These token types are intentionally NOT in the BP_TABLE, they stay in\n// the Tier 2 parselet registry because they require complex handling:\n// IN, TO → UoM conversion parselets (peek at target unit token, complex logic)\n// DOT → Property access (chained OBJ_GET, needs left-token tracking)\n// EQUALS → Assignment (VariableParselet handles :var = expr pattern)\n// EQUALITY, NEQ, GTE, LTE → Comparison ops (need dedicated VM opcodes, task 2.15a)\n// COMMA → Argument separator (function calls, array/object literals)\n\n/** Cached BP_TABLE, built once at module load, immutable thereafter. */\nlet _bpTable: Uint8Array | null = null;\n\n/**\n * Build the Uint8Array binding power table indexed by token typeId.\n * Idempotent, returns cached table on subsequent calls.\n *\n * Must be called after all token types are registered (via registerAllTokenTypes())\n * and after plugin providers have registered their token types.\n */\nexport function buildBindingPowerTable(): Uint8Array {\n if (_bpTable) return _bpTable;\n\n // Size to the largest registered typeId + 1\n let maxId = 0;\n for (const name of Object.keys(BUILTIN_INFIX_BP)) {\n const id = tokenTypeId(name);\n if (id > maxId) maxId = id;\n }\n // Also scan all TokenTypes to ensure table covers all registered IDs\n for (const name of Object.values(TokenTypes)) {\n const id = tokenTypeId(name);\n if (id > maxId) maxId = id;\n }\n\n const table = new Uint8Array(maxId + 1);\n for (const [name, bp] of Object.entries(BUILTIN_INFIX_BP)) {\n const id = tokenTypeId(name);\n table[id] = bp;\n }\n\n _bpTable = table;\n return table;\n}\n\n/**\n * Drop the cached table, so the next {@link buildBindingPowerTable} call builds\n * a fresh one sized to the token types registered by then.\n *\n * It does NOT add a plugin's operator to the Tier 1 fast path, which is what\n * this comment used to promise. The values in the table come from\n * `BUILTIN_INFIX_BP`, which is module-private and has no registration path, so\n * a rebuilt table holds the same binding powers and a plugin token still reads\n * 0. `PrecedenceParser.BP_TABLE` is a static initialized once at class\n * definition time and never re-read, so it would not see a rebuild anyway.\n *\n * A plugin's infix operator takes the Tier 2 parselet-registry route instead,\n * which is where an operator whose binding power the engine does not already\n * know is meant to live.\n */\nexport function invalidateBindingPowerTable(): void {\n _bpTable = null;\n}\n","import { OpCode } from \"@solve-js/parser/OpCode\";\nimport { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\n\n/**\n * `BytecodeProgram.opcodes` is a `Uint8Array`, every operand written into\n * it (including constant-pool indices from {@link BytecodeBuilder.emitNumber}/\n * {@link BytecodeBuilder.emitString}) is truncated to a single byte on\n * `build()`. Exceeding this silently wraps the index (e.g. entry 300 reads\n * back as entry 44), producing a wrong result with no error. See\n * {@link BytecodeBuilder.emitNumber} for the guard that turns this into a\n * thrown error instead.\n */\nconst MAX_CONSTANT_POOL_INDEX = 255;\n\n/**\n * Compiled bytecode program produced by {@link BytecodeBuilder}.\n * Ready for consumption by {@link executeBytecode} without further processing.\n */\nexport interface BytecodeProgram {\n\topcodes: Uint8Array;\n\tnumbers: Float64Array;\n\tstrings: string[];\n\tconstants?: Map<number, number>;\n\t/**\n\t * Whether the program contains any async opcodes (CALL_PLUGIN, etc.).\n\t * Set during compilation by the BytecodeBuilder. Allows the engine\n\t * to skip the O(n) resolver preflight check in O(1) for purely\n\t * synchronous expressions like `2 + 2`.\n\t */\n\thasAsync: boolean;\n\t/**\n\t * User-defined-function bodies compiled alongside this program (one\n\t * entry per `name(params) = body` definition on this line). See\n\t * {@link BytecodeBuilder.emitUserFunctionBody}. `OpCode.DEFINE_USER_FUNCTION`'s\n\t * operand is an index into this array, resolved at VM-execution time\n\t * (not parse time) so a diagnostic/lookahead parse that never actually\n\t * executes the definition line has no side effect on `vm.userFunctions`.\n\t */\n\tuserFunctionBodies?: UserFunctionDef[];\n\t/**\n\t * Anonymous function bodies compiled alongside this program, one entry\n\t * per `map`/`reduce` inline transform expression (e.g. the `10*x` in\n\t * `map(10*x, [0,1,500])`). See {@link BytecodeBuilder.emitAnonymousBody}.\n\t * Deliberately a SEPARATE side-table from `userFunctionBodies`, not\n\t * routed through `vm.userFunctions` at all: an inline body has no name\n\t * and must never leak into the persistent name-keyed registry the way\n\t * a real `f(x) = ...` definition does.\n\t */\n\tanonymousBodies?: AnonymousBodyDef[];\n}\n\n/**\n * An anonymous transform body for `map`/`reduce`'s inline-expression form\n * (e.g. `10*x` in `map(10*x, [0,1,500])`, or `acc+x` in `reduce(acc+x,\n * [1,2,3])`). Structurally identical to {@link UserFunctionDef} minus the\n * `name`. See `OpCode.MAP_INVOKE`/`REDUCE_INVOKE` and\n * `vm/VM.ts`'s handlers, which build a call frame from `params`/`args`\n * exactly like `CALL_USER_FUNCTION` does, just without ever registering\n * the body in `vm.userFunctions`.\n */\nexport interface AnonymousBodyDef {\n\tparams: string[];\n\tprogram: BytecodeProgram;\n}\n\n/**\n * A user-defined, parameterized, reusable function's compiled form\n * (`f(x) = 2*x + 1`). See `OpCode.DEFINE_USER_FUNCTION`/`CALL_USER_FUNCTION`\n * and `vm/VM.ts`'s `VM.defineUserFunction`/`getUserFunction`.\n *\n * `program` is the body compiled to its OWN independent `BytecodeProgram`,\n * not a fragment of the definition line's own bytecode. Parameter names\n * inside the body compile to ORDINARY `LOAD_VAR <name>` opcodes, no\n * parse-time rewriting, because parameter resolution happens dynamically\n * at the VM level: `CALL_USER_FUNCTION` pushes a name-keyed call frame\n * (`Map<string, Value>`) before re-executing `program`, and `VM.getVar()`\n * checks the innermost call frame before falling back to the flat\n * document-variable store. This is why a `UNIT`-collision parameter name\n * (e.g. `h` in `area(w, h) = w * h`, which lexes as the \"hour\" unit) needs\n * no special handling anywhere, it's just another `LOAD_VAR \"h\"`, resolved\n * the same way as any other name.\n */\nexport interface UserFunctionDef {\n\tname: string;\n\tparams: string[];\n\tprogram: BytecodeProgram;\n}\n\n/**\n * Direct-to-bytecode compiler for the Pratt parser.\n *\n * Accumulates opcodes, numeric constants, and string references during parsing,\n * then produces a {@link BytecodeProgram} for VM execution. Supports:\n * - Standard build via {@link build}\n * - Zero-copy build into pre-allocated buffers via {@link buildInto}\n * - In-place reset for reuse without reallocation\n */\nexport class BytecodeBuilder {\n\tprivate opcodes: number[] = [];\n\tprivate numbers: number[] = [];\n\tprivate strings: string[] = [];\n\tprivate stringIndex = new Map<string, number>();\n\tprivate _hasAsync = false;\n\tprivate userFunctionBodies: UserFunctionDef[] = [];\n\tprivate anonymousBodies: AnonymousBodyDef[] = [];\n\n\t/** Emit an {@link OpCode} instruction. */\n\temitOpcode(op: OpCode): void {\n\t\tthis.opcodes.push(op);\n\t\tif (op === OpCode.CALL_PLUGIN) {\n\t\t\tthis._hasAsync = true;\n\t\t}\n\t}\n\n\t/**\n\t * Emit a numeric literal: appends `n` to the program's constant pool and\n\t * writes its index into the opcode stream (read back by the VM as e.g.\n\t * `PUSH_NUMBER <idx>`).\n\t *\n\t * Numeric constants are NOT deduplicated (unlike {@link emitString})\n\t * every call appends a new entry, so an expression with more than\n\t * {@link MAX_CONSTANT_POOL_INDEX}+1 distinct numeric-literal occurrences\n\t * throws rather than silently wrapping the index (see\n\t * `MAX_CONSTANT_POOL_INDEX`'s doc for what that would otherwise do).\n\t *\n\t * @throws If the constant pool would exceed 256 entries.\n\t */\n\temitNumber(n: number): void {\n\t\tconst idx = this.numbers.length;\n\t\tif (idx > MAX_CONSTANT_POOL_INDEX) {\n\t\t\tthrow ErrorFactory.parsing(\n\t\t\t\t\"TOO_MANY_NUMERIC_CONSTANTS\",\n\t\t\t\t`Expression has more than ${MAX_CONSTANT_POOL_INDEX + 1} numeric literals, exceeding the bytecode constant pool's limit.`,\n\t\t\t\t{ limit: MAX_CONSTANT_POOL_INDEX + 1 }\n\t\t\t);\n\t\t}\n\t\tthis.numbers.push(n);\n\t\tthis.opcodes.push(idx);\n\t}\n\n\t/**\n\t * Emit a string literal: interns `s` into the program's string pool\n\t * (deduplicated via `stringIndex`) and writes its index into the opcode\n\t * stream. Subject to the same constant-pool bound as {@link emitNumber},\n\t * but since strings ARE deduplicated, only distinct string values count\n\t * against the limit.\n\t *\n\t * @throws If the string pool would exceed 256 distinct entries.\n\t */\n\temitString(s: string): void {\n\t\tlet idx = this.stringIndex.get(s);\n\t\tif (idx === undefined) {\n\t\t\tidx = this.strings.length;\n\t\t\tif (idx > MAX_CONSTANT_POOL_INDEX) {\n\t\t\t\tthrow ErrorFactory.parsing(\n\t\t\t\t\t\"TOO_MANY_STRING_CONSTANTS\",\n\t\t\t\t\t`Expression has more than ${MAX_CONSTANT_POOL_INDEX + 1} distinct string literals, exceeding the bytecode constant pool's limit.`,\n\t\t\t\t\t{ limit: MAX_CONSTANT_POOL_INDEX + 1 }\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.strings.push(s);\n\t\t\tthis.stringIndex.set(s, idx);\n\t\t}\n\t\tthis.opcodes.push(idx);\n\t}\n\n\t/**\n\t * Emit a raw numeric operand (0-255) following an opcode, e.g. a\n\t * plugin-function index for `CALL_PLUGIN`, or an argument count. Unlike\n\t * {@link emitOpcode}, this does not go through the `OpCode` enum, so\n\t * package authors use this (not an unsafe cast to `OpCode`) to push\n\t * operands their own opcode handler expects to read positionally.\n\t */\n\temitIndex(idx: number): void {\n\t\tthis.opcodes.push(idx);\n\t}\n\n\t/** Emit a raw byte (0-255), used for fixed small operands like argument counts. */\n\temitByte(b: number): void {\n\t\tthis.opcodes.push(b);\n\t}\n\n\t/** Number of opcodes/operands emitted so far, used to compute jump targets before {@link patchJump}. */\n\tget currentLength(): number {\n\t\treturn this.opcodes.length;\n\t}\n\n\t/**\n\t * Register a compiled user-defined-function body, returning its index\n\t * into this program's `userFunctionBodies` side-table, the caller emits\n\t * that index as `DEFINE_USER_FUNCTION`'s operand via {@link emitIndex}.\n\t * Subject to the same {@link MAX_CONSTANT_POOL_INDEX} bound as\n\t * {@link emitNumber}/{@link emitString} (the index itself is a single\n\t * opcode-stream byte), in practice a single line defines at most a\n\t * handful of functions, so this limit is never realistically reached.\n\t *\n\t * @throws If more than 256 function bodies are registered on one program.\n\t */\n\temitUserFunctionBody(name: string, params: string[], program: BytecodeProgram): number {\n\t\tconst idx = this.userFunctionBodies.length;\n\t\tif (idx > MAX_CONSTANT_POOL_INDEX) {\n\t\t\tthrow ErrorFactory.parsing(\n\t\t\t\t\"TOO_MANY_FUNCTION_DEFINITIONS\",\n\t\t\t\t`More than ${MAX_CONSTANT_POOL_INDEX + 1} function definitions on one line, exceeding the bytecode constant pool's limit.`,\n\t\t\t\t{ limit: MAX_CONSTANT_POOL_INDEX + 1 }\n\t\t\t);\n\t\t}\n\t\tthis.userFunctionBodies.push({ name, params, program });\n\t\treturn idx;\n\t}\n\n\t/**\n\t * Register a compiled `map`/`reduce` anonymous transform body, returning\n\t * its index into this program's `anonymousBodies` side-table, the\n\t * caller emits that index as `MAP_INVOKE`/`REDUCE_INVOKE`'s operand via\n\t * {@link emitIndex}. Same {@link MAX_CONSTANT_POOL_INDEX} bound as\n\t * {@link emitUserFunctionBody}.\n\t *\n\t * @throws If more than 256 anonymous bodies are registered on one program.\n\t */\n\temitAnonymousBody(params: string[], program: BytecodeProgram): number {\n\t\tconst idx = this.anonymousBodies.length;\n\t\tif (idx > MAX_CONSTANT_POOL_INDEX) {\n\t\t\tthrow ErrorFactory.parsing(\n\t\t\t\t\"TOO_MANY_ANONYMOUS_BODIES\",\n\t\t\t\t`More than ${MAX_CONSTANT_POOL_INDEX + 1} map/reduce transform expressions on one line, exceeding the bytecode constant pool's limit.`,\n\t\t\t\t{ limit: MAX_CONSTANT_POOL_INDEX + 1 }\n\t\t\t);\n\t\t}\n\t\tthis.anonymousBodies.push({ params, program });\n\t\treturn idx;\n\t}\n\n\t/** Overwrite a previously-emitted placeholder operand at `position` with the real jump `target`, once known. */\n\tpatchJump(position: number, target: number): void {\n\t\tthis.opcodes[position] = target;\n\t}\n\n\t/**\n\t * Build the accumulated opcodes/numbers/strings into a BytecodeProgram.\n\t * Creates new TypedArrays, the builder can be reused after this call.\n\t */\n\tbuild(): BytecodeProgram {\n\t\treturn {\n\t\t\topcodes: new Uint8Array(this.opcodes),\n\t\t\tnumbers: new Float64Array(this.numbers),\n\t\t\t// Defensive copy: .length = 0 in reset() would clear a shared reference.\n\t\t\t// Strings are rare (only UoM/datetime parselets emit them), so the copy\n\t\t\t// cost is negligible.\n\t\t\tstrings: [...this.strings],\n\t\t\tconstants: new Map(),\n\t\t\thasAsync: this._hasAsync,\n\t\t\tuserFunctionBodies: this.userFunctionBodies.length > 0 ? [...this.userFunctionBodies] : undefined,\n\t\t\tanonymousBodies: this.anonymousBodies.length > 0 ? [...this.anonymousBodies] : undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Build directly into a pre-allocated buffer for zero-copy VM consumption.\n\t *\n\t * When `buf` is provided and large enough, writes into it and returns\n\t * subarray **views** (not copies), the returned TypedArrays share the\n\t * buffer's underlying ArrayBuffer. The caller MUST NOT mutate the buffer\n\t * until the returned BytecodeProgram is no longer needed.\n\t *\n\t * If the caller intends to cache the result, they must copy the TypedArrays\n\t * (e.g. `new Uint8Array(program.opcodes)`) before reusing the buffer pool.\n\t *\n\t * When `buf` is omitted or too small, allocates fresh TypedArrays.\n\t */\n\tbuildInto(buf?: { opcodes: Uint8Array; numbers: Float64Array }): BytecodeProgram {\n\t\tconst opLen = this.opcodes.length;\n\t\tconst numLen = this.numbers.length;\n\n\t\tconst reuseOpcodes = buf && buf.opcodes.length >= opLen;\n\t\tconst reuseNumbers = buf && buf.numbers.length >= numLen;\n\n\t\t// Subarray views that share the buffer's ArrayBuffer (zero-copy)\n\t\tconst opcodes = reuseOpcodes\n\t\t\t? new Uint8Array(buf!.opcodes.buffer, buf!.opcodes.byteOffset, opLen)\n\t\t\t: new Uint8Array(opLen);\n\t\tconst numbers = reuseNumbers\n\t\t\t? new Float64Array(buf!.numbers.buffer, buf!.numbers.byteOffset, numLen)\n\t\t\t: new Float64Array(numLen);\n\n\t\t// Write data into the views\n\t\tfor (let i = 0; i < opLen; i++) opcodes[i] = this.opcodes[i];\n\t\tfor (let i = 0; i < numLen; i++) numbers[i] = this.numbers[i];\n\n\t\treturn {\n\t\t\topcodes,\n\t\t\tnumbers,\n\t\t\tstrings: [...this.strings],\n\t\t\tconstants: new Map(),\n\t\t\thasAsync: this._hasAsync,\n\t\t\tuserFunctionBodies: this.userFunctionBodies.length > 0 ? [...this.userFunctionBodies] : undefined,\n\t\t\tanonymousBodies: this.anonymousBodies.length > 0 ? [...this.anonymousBodies] : undefined,\n\t\t};\n\t}\n\n\treset(): void {\n\t\t// Retain backing stores with .length = 0 to avoid reallocation on growth.\n\t\t// = [] discards the ArrayBuffer, forcing V8 to reallocate on every push()\n\t\t// threshold (4→8→16→32...). For a 50-opcode expression, that's 3-4 copies.\n\t\tthis.opcodes.length = 0;\n\t\tthis.numbers.length = 0;\n\t\tthis.strings.length = 0;\n\t\tthis.stringIndex.clear();\n\t\tthis._hasAsync = false;\n\t\tthis.userFunctionBodies.length = 0;\n\t\tthis.anonymousBodies.length = 0;\n\t}\n}\n","/**\n * Turning a `123n` literal's source text into the digits `PUSH_BIGINT` stores.\n *\n * The lexer coalesces thousands groups into the number token it is building,\n * accepting both `,` and `.` as the separator regardless of locale (see\n * `lexer/ExpressionLexer.ts`'s \"Thousands separators\" block). For a NUMBER that\n * is fine, because the separators are stripped again when the text is turned\n * into a double. For a BIGINT nothing stripped them: both consumers took the\n * token text, removed the trailing `n`, and handed the rest straight to\n * `BigInt()`.\n *\n * So `1.000n` reached `BigInt(\"1.000\")`, which throws a raw `SyntaxError` that\n * arrived at the host as UNEXPECTED_ERROR/INTERNAL: the engine reporting its\n * own bug for six characters a user typed. `1.01n` and `1.1n` were fine, which\n * is the tell that the `n` suffix was never the problem, the three-digit\n * thousands group was: a dot followed by exactly three digits is what the lexer\n * swallows, and one followed by one or two digits it leaves alone.\n *\n * Written once here rather than inline at both call sites. There are two\n * (`parser/PrecedenceParser.ts`'s Tier-1 switch and\n * `packages/biginteger/parselets/BigIntNumberParselet.ts`), they already held\n * identical copies of the `n`-stripping, and the two tiers disagreeing about a\n * literal is a bug shape this codebase has had before.\n *\n * @module BigIntLiteral\n */\n\nimport { getLocale } from \"@solve-js/constants/locales\";\nimport { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\n\n/**\n * Two or more dot-separated groups of three, e.g. `1.234.567`.\n *\n * Unambiguous in any locale, since no locale writes two decimal points, so this\n * is stripped without consulting one. Same regex and same reasoning as\n * `NumberParselet.ts`'s copy for the NUMBER path.\n */\nconst CHAINED_DOT_THOUSANDS_GROUPS = /^\\d{1,3}(\\.\\d{3}){2,}$/;\n\n/** Digits and nothing else, which is what `BigInt()` can be handed safely. */\nconst DIGITS_ONLY = /^\\d+$/;\n\n/**\n * The digit string behind a bigint literal.\n *\n * A bigint literal has no fractional part by construction: the lexer only emits\n * BIGINT when it saw no decimal point of its own and no exponent, so any `.` or\n * `,` still in the text got there as a thousands group. Which of the two the\n * writer meant is a locale question, and answering it wrongly would silently\n * change the value by three orders of magnitude, so only the separator this\n * locale actually uses for grouping is removed. Anything left over is refused\n * rather than guessed at.\n *\n * @param raw - The token's text, with or without the trailing `n`.\n * @param localeCode - The engine's active locale.\n * @returns A string of digits, ready for `BigInt()`.\n * @throws An `INVALID_NUMBER_LITERAL` parsing error when what is left is not a\n * whole number, e.g. `1.000n` in a locale that writes decimals with a dot.\n */\nexport function bigIntLiteralDigits(raw: string, localeCode: string): string {\n\tconst withoutSuffix = raw.endsWith(\"n\") ? raw.slice(0, -1) : raw;\n\n\t// The common case first: nothing was grouped, so there is nothing to decide.\n\tif (DIGITS_ONLY.test(withoutSuffix)) return withoutSuffix;\n\n\tconst digits = CHAINED_DOT_THOUSANDS_GROUPS.test(withoutSuffix)\n\t\t? withoutSuffix.split(\".\").join(\"\")\n\t\t: stripLocaleGrouping(withoutSuffix, localeCode);\n\n\tif (!DIGITS_ONLY.test(digits)) {\n\t\tconst separator = withoutSuffix.includes(\".\") ? \".\" : withoutSuffix.includes(\",\") ? \",\" : withoutSuffix;\n\t\tthrow ErrorFactory.parsing(\n\t\t\t\"INVALID_NUMBER_LITERAL\",\n\t\t\t`\"${raw}\" is not a whole number: \"${separator}\" separates decimals in the ${localeCode} locale, and a whole number cannot have a fractional part.`,\n\t\t\t{ raw, localeCode, separator },\n\t\t);\n\t}\n\treturn digits;\n}\n\n/**\n * Removes the active locale's own thousands separator and nothing else.\n *\n * @param text - The literal without its `n`.\n * @param localeCode - The engine's active locale.\n * @returns The text with grouping removed, which the caller then re-checks.\n */\nfunction stripLocaleGrouping(text: string, localeCode: string): string {\n\tconst thousandsSeparator = getLocale(localeCode).display.thousandsSeparator;\n\treturn thousandsSeparator ? text.split(thousandsSeparator).join(\"\") : text;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/uom/UnitConversion.ts","../src/uom/UomConverter.ts"],"names":["UNIT_TABLE","UNIT_DIFFERENCES","BEST_UNITS_METRIC","EXTENDED_UNITS","MEASURE_KIND_NAMES","MEASURE_SYMBOLS"],"mappings":";;;;;AAmCA,IAAM,cAA8C,IAAI,GAAA,CAAI,MAAA,CAAO,OAAA,CAAQA,4BAAU,CAAC,CAAA;AAStF,IAAM,oBAAiD,IAAI,GAAA,CAAI,MAAA,CAAO,OAAA,CAAQC,kCAAgB,CAAC,CAAA;A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CAAoB,KAAA,EAAO,CAAC,CAAA;AAC3C,IAAA,OAAO,EAAE,KAAA,EAAO,MAAA,CAAO,QAAA,EAAU,IAAA,EAAM,OAAO,IAAA,EAAK;AAAA,EACrD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAE,KAAA,EAAO,IAAA,EAAM,CAAA,EAAE;AAAA,EAC1B;AACF","file":"chunk-PFUESQTW.cjs","sourcesContent":["/**\n * The unit conversion algorithm, ported from the `convert` npm package v7.0.2\n * alongside its tables (see `generated/UnitTable.generated.ts` and\n * THIRD-PARTY-NOTICES.md).\n *\n * Transliterated expression for expression rather than rewritten. Floating\n * point is not associative, so `(q + d) * (a / b) - d2` and any algebraically\n * equal rearrangement disagree in the last bits. Those bits are observable:\n * `0.5 l` best-converts to `500.00000000000006 mL` today, and the test suite\n * pins several conversions to ten decimal places.\n *\n * This module is deliberately unaware of the engine's own additions. Workdays,\n * extended units, currency and the caches all live in `UomConverter.ts`, which\n * layers them on top of these three functions.\n */\n\nimport {\n UNIT_TABLE,\n UNIT_DIFFERENCES,\n BEST_UNITS_METRIC,\n type UnitEntry,\n} from \"./generated/UnitTable.generated\";\n\n/**\n * The generated tables re-keyed into Maps once at module load.\n *\n * Not a micro-optimization. A 1456-key object literal lands in V8's dictionary\n * mode, and guarding a read on it against inherited names (`constructor`,\n * `toString`) costs about 123ns per call with either `hasOwnProperty.call` or\n * `Object.hasOwn`, measured. `Map.get` is about 6ns and needs no guard at all,\n * because a Map has no prototype chain to fall through to. That is a 20x\n * difference on the single hottest operation in the unit system: `convertRaw`\n * performs two of these per call, and `LanguageService` sweeps all 1456 keys\n * to build completions.\n */\nconst UNIT_LOOKUP: ReadonlyMap<string, UnitEntry> = new Map(Object.entries(UNIT_TABLE));\n\n/**\n * Temperature offsets, as a Map for the same reason.\n *\n * Also removes a latent hazard: the upstream code tests membership with `in`,\n * and `\"toString\" in UNIT_DIFFERENCES` is true, so an inherited name reaching\n * that branch would add a function to a number.\n */\nconst DIFFERENCE_LOOKUP: ReadonlyMap<string, number> = new Map(Object.entries(UNIT_DIFFERENCES));\n\n/**\n * Looks up a unit spelling.\n *\n * @returns its `[kind, ratio]` entry, or `undefined` if the spelling is not a\n * unit. Case-sensitive: no normalization or aliasing happens anywhere in this\n * module.\n *\n * The one deliberate deviation from upstream. `convert` tests membership with\n * `in` and reads the property directly, so inherited names like \"constructor\"\n * and \"toString\" reach its measure comparison and fail there with \"Cannot\n * convert between different measures\" instead of \"is not a valid unit\". Both\n * throw a RangeError and both report no measure, so nothing downstream can\n * tell the difference, and naming the real problem is the better message.\n */\nexport function lookupUnit(unit: string): UnitEntry | undefined {\n return UNIT_LOOKUP.get(unit);\n}\n\n/**\n * Converts `quantity` from one unit to another.\n *\n * THROWS a `RangeError` for an unknown unit or a pair in different measures.\n * Callers depend on that: `VM.ts`'s `extractDurationMs()` calls this with an\n * arbitrary unit inside a bare try/catch and treats the throw as \"not a\n * duration, contribute zero\". Returning NaN or the input unchanged instead\n * would turn `<date> + 5 kg` into an Invalid Date rather than a no-op.\n */\nexport function convertRaw(quantity: number, from: string, to: string): number {\n const parsedFrom = UNIT_LOOKUP.get(from);\n if (parsedFrom === undefined) {\n throw new RangeError(`${from} is not a valid unit`);\n }\n\n const parsedTo = UNIT_LOOKUP.get(to);\n if (parsedTo === undefined) {\n throw new RangeError(`${to} is not a valid unit`);\n }\n\n return convertResolved(quantity, from, to, parsedFrom, parsedTo);\n}\n\n/**\n * The conversion arithmetic, for callers that have already looked both units\n * up and want to skip doing it twice.\n *\n * Split out for `UomConverter.convertUnit()`, which has to check whether\n * either side is a workday or an extended unit before it can dispatch, and\n * would otherwise resolve each unit once to decide and again to convert. The\n * entries MUST be the ones this module returned for these exact spellings.\n */\nexport function convertResolved(\n quantity: number,\n from: string,\n to: string,\n fromEntry: UnitEntry,\n toEntry: UnitEntry\n): number {\n const parsedFrom = fromEntry;\n const parsedTo = toEntry;\n\n if (parsedFrom[0] !== parsedTo[0]) {\n // DELIBERATE DEVIATION from the ported original, which silently reinterpreted\n // \"m\" as minutes whenever the other side was a time unit. That is a guess,\n // and this project's stated position is that refusing to guess is the safer\n // default for a tool doing arithmetic on someone's real numbers (see\n // docs/architecture/design-decisions.md). The guess was not harmless: it\n // reached `<date> + <duration>` through VM.ts's extractDurationMs(), where\n // `today + 5 m` silently added five MINUTES for someone who wrote metres.\n //\n // Minutes are spelled \"min\", \"minute\" or \"minutes\", all of which the table\n // has always accepted.\n throw new RangeError(`Cannot convert between different measures: ${from} and ${to}`);\n }\n\n const fromRatio = parsedFrom[1];\n const toRatio = parsedTo[1];\n\n // Only six units in the whole table carry an offset, so the common path is\n // both misses. Reading the Map once per side and reusing the value beats\n // testing membership and then reading it again.\n const fromDifference = DIFFERENCE_LOOKUP.get(from);\n const toDifference = DIFFERENCE_LOOKUP.get(to);\n\n // Scales that do not share an origin (temperature) need the offset applied\n // around the ratio. Do not refactor the four branches into one expression:\n // the grouping is what makes the result bit-identical to the original.\n if (fromDifference !== undefined) {\n if (toDifference !== undefined) {\n return (quantity + fromDifference) * (fromRatio / toRatio) - toDifference;\n }\n return (quantity + fromDifference) * (fromRatio / toRatio);\n }\n\n if (toDifference !== undefined) {\n return quantity * (fromRatio / toRatio) - toDifference;\n }\n\n return quantity * (fromRatio / toRatio);\n}\n\n/**\n * Picks the most readable metric unit for a magnitude and converts to it.\n *\n * Only the metric lists are ported; nothing has ever requested the imperial\n * ones. Note the final conversion goes from the ORIGINAL unit to the chosen\n * one directly rather than via the smallest unit, which is what keeps the\n * result exact.\n */\nexport function convertToBestMetric(\n quantity: number,\n from: string\n): { quantity: number; unit: string } {\n const parsedFrom = UNIT_LOOKUP.get(from);\n if (parsedFrom === undefined) {\n throw new RangeError(`${from} is not a valid unit`);\n }\n\n const best = BEST_UNITS_METRIC[parsedFrom[0]];\n const smallestUnit = best[0][0];\n let bestUnit = smallestUnit;\n\n const baseQuantity = convertRaw(quantity, from, smallestUnit);\n const absQuantity = baseQuantity < 0 ? -baseQuantity : baseQuantity;\n\n // Thresholds are expressed in the smallest unit and ascend, so the last one\n // the magnitude reaches wins. Breaking early rather than scanning the whole\n // list matters for zero and for negatives, which stay on the smallest unit.\n for (let i = 0; i < best.length; i++) {\n const bestEntry = best[i];\n if (absQuantity >= bestEntry[1]) {\n bestUnit = bestEntry[0];\n } else {\n break;\n }\n }\n\n return { quantity: convertRaw(quantity, from, bestUnit), unit: bestUnit };\n}\n","/**\n * UoM Converter, built on the in-house unit tables in `UnitConversion.ts` and\n * `generated/UnitTable.generated.ts` (ported from the `convert` npm package\n * v7.0.2 so the engine ships with no runtime dependencies).\n *\n * Units are strictly case-sensitive and are looked up without aliasing. No unit\n * remapping, what you type is what you get.\n * e.g. 'C' = Celsius, 'c' = cup; 'MB' = megabytes, 'mb' = millibits.\n *\n * This file owns everything the base tables do not: the workday shim, the\n * extended (custom-measure) units, and the two caches.\n */\n\nimport { lookupUnit, convertRaw, convertResolved, convertToBestMetric } from \"@solve-js/uom/UnitConversion\";\nimport { MEASURE_KIND_NAMES, MEASURE_SYMBOLS, UNIT_TABLE } from \"@solve-js/uom/generated/UnitTable.generated\";\nimport { EXTENDED_UNITS } from \"@solve-js/uom/ExtendedUnits\";\n\n// ── \"workday\", a synthetic unit with no entry in the base table ───────────\n//\n// A business day (Mon-Fri) backing the datetime package's `<date> + N\n// workdays` arithmetic and `$X/workday` Rate literals\n// (packages/datetime/). NOT a real physical unit, a business day has no\n// fixed duration, since it depends on which calendar dates are weekends\n// so the ported base table has no concept of it and can't be\n// taught one without monkey-patching its internal unit table.\n//\n// For RATE-MATH purposes only (e.g. \"$500/workday x 4 weeks\" needs a\n// workday count to multiply by), a workday is treated as a FIXED 7/5 of a\n// calendar day: 5 workdays span exactly 7 calendar days in a whole week,\n// so this ratio is exact for whole-week spans and a reasonable linear\n// approximation otherwise. This is deliberately NOT the same\n// calendar-aware, weekend-skipping logic real \"<date> + N workdays\" date\n// arithmetic needs (see vm/VM.ts's addBusinessDays()), that can't be\n// reduced to a fixed ratio, since the exact skip pattern depends on which\n// day of the week the calculation actually starts from.\n//\n// Handled here as a thin pre/post layer in front of the normal\n// base-table path (rather than inside the tables themselves) so every\n// caller of getMeasure()/convertUnit()/canConvert() automatically gets\n// workday support for free.\nconst WORKDAY_UNIT_NAMES = new Set([\"workday\", \"workdays\"]);\nconst WORKDAY_TO_DAY_FACTOR = 7 / 5; // 1 workday == 1.4 calendar days\n\n/** Whether `unit` is the synthetic \"workday\" unit (see module note above). */\nexport function isWorkdayUnit(unit: string | undefined): unit is string {\n return typeof unit === \"string\" && WORKDAY_UNIT_NAMES.has(unit);\n}\n\n/**\n * Validate `unit` against the known unit table.\n *\n * @returns `unit` unchanged in all cases. This does NOT normalize casing\n * or aliasing (units are strictly case-sensitive, see the module note\n * above). A unit the table doesn't recognize is still\n * returned as-is (not thrown), so callers must not assume a returned\n * string is actually convertible, check with {@link isConvertibleUnit}\n * or {@link canConvert} first if that matters.\n *\n * Kept as an identity function purely for API compatibility. It used to guard\n * a validity cache, which existed because validating a unit meant a\n * throw/catch round trip through the old dependency. Validation is now a Map\n * lookup, so the cache cost more than it saved: worse, it was capped at 1000\n * entries against a 1456-unit table, so any sweep over the full vocabulary\n * (which is exactly what LanguageService does to build completions) evicted\n * on almost every call. That one change took the full-table sweep from 7.7ms\n * to under 20us.\n */\nexport function resolveUnit(unit: string): string {\n return unit;\n}\n\n// MEASURE_KIND_NAMES now comes from the generated table (it is derived data,\n// so the generator emits it rather than it being retyped here). The reason it\n// is a module-level constant has not changed: getMeasure() runs at least twice\n// per conversion, and this used to be reallocated on every call.\n\n/**\n * Get the measure/dimension kind for `unit` (e.g. `\"length\"`, `\"mass\"`,\n * `\"temperature\"`), used to check whether two units are even in the same\n * dimension before attempting a conversion.\n *\n * @returns `undefined` if `unit` isn't recognized, rather than throwing.\n */\nexport function getMeasure(unit: string): string | undefined {\n // Workday is a Time-measure unit by convention (see isWorkdayUnit's doc\n // comment) and is not in the base table, so resolve its measure via \"day\"\n // instead of attempting the real lookup below.\n if (isWorkdayUnit(unit)) return getMeasure(\"day\");\n\n // Extended (custom) categories the base table has no measure kind for,\n // see ExtendedUnits.ts.\n const extended = EXTENDED_UNITS[unit];\n if (extended) return extended.measure;\n\n const entry = lookupUnit(unit);\n if (entry === undefined) return undefined;\n\n return MEASURE_KIND_NAMES[entry[0]];\n}\n\n/**\n * Check whether `from` can be converted to `to`. Same unit, or same\n * measure kind (length, mass, ...) and the underlying tables accept the pair.\n * Never throws; returns `false` on any failure.\n */\nexport function canConvert(from: string, to: string): boolean {\n if (from === to) return true;\n if (isWorkdayUnit(from) || isWorkdayUnit(to)) {\n const fromMeasure = getMeasure(from);\n const toMeasure = getMeasure(to);\n return !!fromMeasure && fromMeasure === toMeasure;\n }\n // One table read per side, comparing numeric kind ids. The old shape called\n // getMeasure() on each side (two more reads) purely to compare the resulting\n // STRINGS, then did a throwaway conversion to confirm what the kind check had\n // already established.\n const fromEntry = lookupUnit(from);\n const toEntry = lookupUnit(to);\n if (fromEntry !== undefined && toEntry !== undefined) {\n return fromEntry[0] === toEntry[0];\n }\n\n // Extended (custom) categories aren't in the base table at all, so they are\n // compared on their own measure names instead.\n const fromExtended = EXTENDED_UNITS[from];\n const toExtended = EXTENDED_UNITS[to];\n if (fromExtended !== undefined && toExtended !== undefined) {\n return fromExtended.measure === toExtended.measure;\n }\n\n // Mixed: one side is in the base table and the other is extended. That used\n // to be refused outright, on the grounds that the two measure spaces are\n // disjoint. They are not, once an extended unit names a measure the base\n // table also has: `furlong` is a length and so is `m`, and the ratio between\n // them is exactly what both tables already record.\n return bridgesToBaseMeasure(from, to) || bridgesToBaseMeasure(to, from);\n}\n\n/**\n * Whether `extendedUnit` extends a measure the base table also knows, so a\n * value in it can reach `baseUnit`.\n *\n * The bridge works because both tables express a unit as a ratio to the same\n * physical base: the generated table's length ratios are metres and its mass\n * ratios are grams, and an extended unit declaring `measure: \"length\"` states\n * its `toBase` in the same metres. Composing the two ratios is then ordinary\n * arithmetic rather than a second conversion system.\n *\n * A measure the base table has no concept of, such as pace, still fails here,\n * which is the behaviour this replaced and the reason the check is by measure\n * name rather than by presence in the extended table.\n */\nfunction bridgesToBaseMeasure(extendedUnit: string, baseUnit: string): boolean {\n const extended = EXTENDED_UNITS[extendedUnit];\n if (extended === undefined) return false;\n\n const base = lookupUnit(resolveUnit(baseUnit));\n if (base === undefined) return false;\n\n return MEASURE_KIND_NAMES[base[0]] === extended.measure;\n}\n\n/**\n * Convert `value` from unit `from` to unit `to`.\n *\n * Does not validate that the conversion is possible, callers should check\n * with {@link canConvert} first if `from`/`to` aren't already known-good.\n *\n * THROWS a RangeError for an unknown unit or a cross-measure pair. `VM.ts`'s\n * `extractDurationMs()` depends on that, see {@link convertRaw}.\n *\n * This used to memoize a per-pair conversion factor in an LFU cache. The cache\n * is gone: computing the factor is now two Map reads, while the cache cost a\n * template-string key allocation on every call plus the LFU's own frequency\n * bookkeeping, so it was slower than the work it avoided. Removing it is\n * bit-exact, not merely close: the cache stored `convertRaw(1, f, t)`, which is\n * exactly `fromRatio / toRatio`, and then multiplied, which is the identical\n * expression `convertRaw(value, f, t)` evaluates. It also deleted the special\n * case that existed only to keep offset-based temperature pairs out of a\n * factor cache.\n */\nexport function convertUnit(value: number, from: string, to: string): number {\n if (from === to) return value;\n\n // Fast path first: two ordinary units, which is nearly every call. Resolving\n // both here and handing the entries to convertResolved() avoids looking them\n // up again inside convertRaw(). Neither workdays nor extended units appear in\n // the base table, so they always fall through to the branches below and this\n // ordering cannot steal a case from them. UnitVocabulary.spec.ts pins that\n // the two vocabularies stay disjoint.\n const fromEntry = lookupUnit(from);\n const toEntry = lookupUnit(to);\n if (fromEntry !== undefined && toEntry !== undefined) {\n return convertResolved(value, from, to, fromEntry, toEntry);\n }\n\n // Workday <-> any other Time-measure unit: pivot through \"day\" using the\n // fixed 7/5 ratio (see isWorkdayUnit's doc comment above).\n if (isWorkdayUnit(from) && isWorkdayUnit(to)) return value; // \"workday\" <-> \"workdays\" alias\n if (isWorkdayUnit(from)) {\n const days = value * WORKDAY_TO_DAY_FACTOR;\n return to === \"day\" ? days : convertUnit(days, \"day\", to);\n }\n if (isWorkdayUnit(to)) {\n const days = from === \"day\" ? value : convertUnit(value, from, \"day\");\n return days / WORKDAY_TO_DAY_FACTOR;\n }\n\n // Extended (custom) categories the base table has no measure kind for\n // (see ExtendedUnits.ts), compute the ratio directly from each unit's\n // factor-to-base value instead of calling convertRaw(), which would throw\n // on an unrecognized unit string. Every extended category is a pure linear\n // ratio scale (no Temperature-style offset), so this is always safe.\n const fExt = EXTENDED_UNITS[from];\n const tExt = EXTENDED_UNITS[to];\n if (fExt !== undefined && tExt !== undefined) {\n return value * (fExt.toBase / tExt.toBase);\n }\n\n // One side extended, the other in the base table, sharing a measure. Convert\n // through the measure's base unit, which both tables state their ratios\n // against: an extended length declares its `toBase` in metres, and the\n // generated table's length ratios are metres too.\n if (fExt !== undefined && bridgesToBaseMeasure(from, to)) {\n return convertRaw(value * fExt.toBase, baseUnitFor(to), to);\n }\n if (tExt !== undefined && bridgesToBaseMeasure(to, from)) {\n return convertRaw(value, from, baseUnitFor(from)) / tExt.toBase;\n }\n\n // Offsets, cross-measure rejection and the unknown-unit throw all live in\n // convertRaw. Nothing is layered on top here any more.\n return convertRaw(value, from, to);\n}\n\n/**\n * The unit a measure states its ratios against, found from any unit in it.\n *\n * Read out of the table rather than hard-coded, so it cannot drift from the\n * ratios it has to agree with: the base is whichever unit of that measure has\n * a ratio of exactly one.\n */\nfunction baseUnitFor(unit: string): string {\n const entry = lookupUnit(resolveUnit(unit));\n if (entry === undefined) return unit;\n\n for (const symbol of Object.keys(UNIT_TABLE)) {\n const candidate = UNIT_TABLE[symbol];\n if (candidate[0] === entry[0] && candidate[1] === 1) return symbol;\n }\n return unit;\n}\n\n/**\n * List every unit symbol in the same measure/dimension as `unit` (wiki:\n * Units-Of-Measurement, \"Conversion Possibilities\", `sourceUnit to ?`\n * e.g. `cm to ?\"` → every Length unit). Excludes `unit` itself.\n *\n * Reads MEASURE_SYMBOLS, which is a curated symbols-only vocabulary and\n * deliberately NOT the keys of the unit table filtered by kind. The two\n * differ: Volume's symbols include `c` and `pt` but not `cup`/`cups`, and\n * Time's include `wk` and `mo` but not `week`/`month`. Deriving this list\n * from the unit table instead would roughly quadruple every answer.\n *\n * @returns `[]` if `unit` isn't recognized, rather than throwing.\n */\nexport function getConvertiblePossibilities(unit: string): string[] {\n const resolved = resolveUnit(unit);\n const entry = lookupUnit(resolved);\n if (entry === undefined) return [];\n const symbols = MEASURE_SYMBOLS[entry[0]];\n if (!symbols) return [];\n return symbols.filter((s) => s !== resolved);\n}\n\n/** Check whether `unit` is a unit the conversion tables recognize. Never throws. */\nexport function isConvertibleUnit(unit: string): boolean {\n if (isWorkdayUnit(unit)) return true;\n if (EXTENDED_UNITS[unit]) return true;\n return lookupUnit(resolveUnit(unit)) !== undefined;\n}\n\n/**\n * Convert `value` (in `unit`) to whichever unit of the same measure gives\n * the most human-readable magnitude, e.g. 1500 metres becomes 1.5 km. Falls\n * back to returning `value`/`unit` unchanged if `unit` isn't recognized,\n * which is what every extended unit and workday does.\n *\n * Note the chosen unit is drawn from the best-unit lists, which are not\n * restricted to spellings the lexer accepts: 0.5 l reports \"mL\".\n */\nexport function getBestUnit(value: number, unit: string): { value: number; unit: string } {\n const u = resolveUnit(unit);\n try {\n const result = convertToBestMetric(value, u);\n return { value: result.quantity, unit: result.unit };\n } catch {\n return { value, unit: u };\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/uom/UnitConversion.ts","../src/uom/UomConverter.ts"],"names":[],"mappings":";;;AAmCA,IAAM,cAA8C,IAAI,GAAA,CAAI,MAAA,CAAO,OAAA,CAAQ,UAAU,CAAC,CAAA;AAStF,IAAM,oBAAiD,IAAI,GAAA,CAAI,MAAA,CAAO,OAAA,CAAQ,gBAAgB,CAAC,CAAA;AAgBxF,SAAS,WAAW,IAAA,EAAqC;AAC9D,EAAA,OAAO,WAAA,CAAY,IAAI,IAAI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M,OAAO,IAAA,EAAK;AAAA,EACrD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAE,KAAA,EAAO,IAAA,EAAM,CAAA,EAAE;AAAA,EAC1B;AACF","file":"chunk-R3PY4G7J.js","sourcesContent":["/**\n * The unit conversion algorithm, ported from the `convert` npm package v7.0.2\n * alongside its tables (see `generated/UnitTable.generated.ts` and\n * THIRD-PARTY-NOTICES.md).\n *\n * Transliterated expression for expression rather than rewritten. Floating\n * point is not associative, so `(q + d) * (a / b) - d2` and any algebraically\n * equal rearrangement disagree in the last bits. Those bits are observable:\n * `0.5 l` best-converts to `500.00000000000006 mL` today, and the test suite\n * pins several conversions to ten decimal places.\n *\n * This module is deliberately unaware of the engine's own additions. Workdays,\n * extended units, currency and the caches all live in `UomConverter.ts`, which\n * layers them on top of these three functions.\n */\n\nimport {\n UNIT_TABLE,\n UNIT_DIFFERENCES,\n BEST_UNITS_METRIC,\n type UnitEntry,\n} from \"./generated/UnitTable.generated\";\n\n/**\n * The generated tables re-keyed into Maps once at module load.\n *\n * Not a micro-optimization. A 1456-key object literal lands in V8's dictionary\n * mode, and guarding a read on it against inherited names (`constructor`,\n * `toString`) costs about 123ns per call with either `hasOwnProperty.call` or\n * `Object.hasOwn`, measured. `Map.get` is about 6ns and needs no guard at all,\n * because a Map has no prototype chain to fall through to. That is a 20x\n * difference on the single hottest operation in the unit system: `convertRaw`\n * performs two of these per call, and `LanguageService` sweeps all 1456 keys\n * to build completions.\n */\nconst UNIT_LOOKUP: ReadonlyMap<string, UnitEntry> = new Map(Object.entries(UNIT_TABLE));\n\n/**\n * Temperature offsets, as a Map for the same reason.\n *\n * Also removes a latent hazard: the upstream code tests membership with `in`,\n * and `\"toString\" in UNIT_DIFFERENCES` is true, so an inherited name reaching\n * that branch would add a function to a number.\n */\nconst DIFFERENCE_LOOKUP: ReadonlyMap<string, number> = new Map(Object.entries(UNIT_DIFFERENCES));\n\n/**\n * Looks up a unit spelling.\n *\n * @returns its `[kind, ratio]` entry, or `undefined` if the spelling is not a\n * unit. Case-sensitive: no normalization or aliasing happens anywhere in this\n * module.\n *\n * The one deliberate deviation from upstream. `convert` tests membership with\n * `in` and reads the property directly, so inherited names like \"constructor\"\n * and \"toString\" reach its measure comparison and fail there with \"Cannot\n * convert between different measures\" instead of \"is not a valid unit\". Both\n * throw a RangeError and both report no measure, so nothing downstream can\n * tell the difference, and naming the real problem is the better message.\n */\nexport function lookupUnit(unit: string): UnitEntry | undefined {\n return UNIT_LOOKUP.get(unit);\n}\n\n/**\n * Converts `quantity` from one unit to another.\n *\n * THROWS a `RangeError` for an unknown unit or a pair in different measures.\n * Callers depend on that: `VM.ts`'s `extractDurationMs()` calls this with an\n * arbitrary unit inside a bare try/catch and treats the throw as \"not a\n * duration, contribute zero\". Returning NaN or the input unchanged instead\n * would turn `<date> + 5 kg` into an Invalid Date rather than a no-op.\n */\nexport function convertRaw(quantity: number, from: string, to: string): number {\n const parsedFrom = UNIT_LOOKUP.get(from);\n if (parsedFrom === undefined) {\n throw new RangeError(`${from} is not a valid unit`);\n }\n\n const parsedTo = UNIT_LOOKUP.get(to);\n if (parsedTo === undefined) {\n throw new RangeError(`${to} is not a valid unit`);\n }\n\n return convertResolved(quantity, from, to, parsedFrom, parsedTo);\n}\n\n/**\n * The conversion arithmetic, for callers that have already looked both units\n * up and want to skip doing it twice.\n *\n * Split out for `UomConverter.convertUnit()`, which has to check whether\n * either side is a workday or an extended unit before it can dispatch, and\n * would otherwise resolve each unit once to decide and again to convert. The\n * entries MUST be the ones this module returned for these exact spellings.\n */\nexport function convertResolved(\n quantity: number,\n from: string,\n to: string,\n fromEntry: UnitEntry,\n toEntry: UnitEntry\n): number {\n const parsedFrom = fromEntry;\n const parsedTo = toEntry;\n\n if (parsedFrom[0] !== parsedTo[0]) {\n // DELIBERATE DEVIATION from the ported original, which silently reinterpreted\n // \"m\" as minutes whenever the other side was a time unit. That is a guess,\n // and this project's stated position is that refusing to guess is the safer\n // default for a tool doing arithmetic on someone's real numbers (see\n // docs/architecture/design-decisions.md). The guess was not harmless: it\n // reached `<date> + <duration>` through VM.ts's extractDurationMs(), where\n // `today + 5 m` silently added five MINUTES for someone who wrote metres.\n //\n // Minutes are spelled \"min\", \"minute\" or \"minutes\", all of which the table\n // has always accepted.\n throw new RangeError(`Cannot convert between different measures: ${from} and ${to}`);\n }\n\n const fromRatio = parsedFrom[1];\n const toRatio = parsedTo[1];\n\n // Only six units in the whole table carry an offset, so the common path is\n // both misses. Reading the Map once per side and reusing the value beats\n // testing membership and then reading it again.\n const fromDifference = DIFFERENCE_LOOKUP.get(from);\n const toDifference = DIFFERENCE_LOOKUP.get(to);\n\n // Scales that do not share an origin (temperature) need the offset applied\n // around the ratio. Do not refactor the four branches into one expression:\n // the grouping is what makes the result bit-identical to the original.\n if (fromDifference !== undefined) {\n if (toDifference !== undefined) {\n return (quantity + fromDifference) * (fromRatio / toRatio) - toDifference;\n }\n return (quantity + fromDifference) * (fromRatio / toRatio);\n }\n\n if (toDifference !== undefined) {\n return quantity * (fromRatio / toRatio) - toDifference;\n }\n\n return quantity * (fromRatio / toRatio);\n}\n\n/**\n * Picks the most readable metric unit for a magnitude and converts to it.\n *\n * Only the metric lists are ported; nothing has ever requested the imperial\n * ones. Note the final conversion goes from the ORIGINAL unit to the chosen\n * one directly rather than via the smallest unit, which is what keeps the\n * result exact.\n */\nexport function convertToBestMetric(\n quantity: number,\n from: string\n): { quantity: number; unit: string } {\n const parsedFrom = UNIT_LOOKUP.get(from);\n if (parsedFrom === undefined) {\n throw new RangeError(`${from} is not a valid unit`);\n }\n\n const best = BEST_UNITS_METRIC[parsedFrom[0]];\n const smallestUnit = best[0][0];\n let bestUnit = smallestUnit;\n\n const baseQuantity = convertRaw(quantity, from, smallestUnit);\n const absQuantity = baseQuantity < 0 ? -baseQuantity : baseQuantity;\n\n // Thresholds are expressed in the smallest unit and ascend, so the last one\n // the magnitude reaches wins. Breaking early rather than scanning the whole\n // list matters for zero and for negatives, which stay on the smallest unit.\n for (let i = 0; i < best.length; i++) {\n const bestEntry = best[i];\n if (absQuantity >= bestEntry[1]) {\n bestUnit = bestEntry[0];\n } else {\n break;\n }\n }\n\n return { quantity: convertRaw(quantity, from, bestUnit), unit: bestUnit };\n}\n","/**\n * UoM Converter, built on the in-house unit tables in `UnitConversion.ts` and\n * `generated/UnitTable.generated.ts` (ported from the `convert` npm package\n * v7.0.2 so the engine ships with no runtime dependencies).\n *\n * Units are strictly case-sensitive and are looked up without aliasing. No unit\n * remapping, what you type is what you get.\n * e.g. 'C' = Celsius, 'c' = cup; 'MB' = megabytes, 'mb' = millibits.\n *\n * This file owns everything the base tables do not: the workday shim, the\n * extended (custom-measure) units, and the two caches.\n */\n\nimport { lookupUnit, convertRaw, convertResolved, convertToBestMetric } from \"@solve-js/uom/UnitConversion\";\nimport { MEASURE_KIND_NAMES, MEASURE_SYMBOLS, UNIT_TABLE } from \"@solve-js/uom/generated/UnitTable.generated\";\nimport { EXTENDED_UNITS } from \"@solve-js/uom/ExtendedUnits\";\n\n// ── \"workday\", a synthetic unit with no entry in the base table ───────────\n//\n// A business day (Mon-Fri) backing the datetime package's `<date> + N\n// workdays` arithmetic and `$X/workday` Rate literals\n// (packages/datetime/). NOT a real physical unit, a business day has no\n// fixed duration, since it depends on which calendar dates are weekends\n// so the ported base table has no concept of it and can't be\n// taught one without monkey-patching its internal unit table.\n//\n// For RATE-MATH purposes only (e.g. \"$500/workday x 4 weeks\" needs a\n// workday count to multiply by), a workday is treated as a FIXED 7/5 of a\n// calendar day: 5 workdays span exactly 7 calendar days in a whole week,\n// so this ratio is exact for whole-week spans and a reasonable linear\n// approximation otherwise. This is deliberately NOT the same\n// calendar-aware, weekend-skipping logic real \"<date> + N workdays\" date\n// arithmetic needs (see vm/VM.ts's addBusinessDays()), that can't be\n// reduced to a fixed ratio, since the exact skip pattern depends on which\n// day of the week the calculation actually starts from.\n//\n// Handled here as a thin pre/post layer in front of the normal\n// base-table path (rather than inside the tables themselves) so every\n// caller of getMeasure()/convertUnit()/canConvert() automatically gets\n// workday support for free.\nconst WORKDAY_UNIT_NAMES = new Set([\"workday\", \"workdays\"]);\nconst WORKDAY_TO_DAY_FACTOR = 7 / 5; // 1 workday == 1.4 calendar days\n\n/** Whether `unit` is the synthetic \"workday\" unit (see module note above). */\nexport function isWorkdayUnit(unit: string | undefined): unit is string {\n return typeof unit === \"string\" && WORKDAY_UNIT_NAMES.has(unit);\n}\n\n/**\n * Validate `unit` against the known unit table.\n *\n * @returns `unit` unchanged in all cases. This does NOT normalize casing\n * or aliasing (units are strictly case-sensitive, see the module note\n * above). A unit the table doesn't recognize is still\n * returned as-is (not thrown), so callers must not assume a returned\n * string is actually convertible, check with {@link isConvertibleUnit}\n * or {@link canConvert} first if that matters.\n *\n * Kept as an identity function purely for API compatibility. It used to guard\n * a validity cache, which existed because validating a unit meant a\n * throw/catch round trip through the old dependency. Validation is now a Map\n * lookup, so the cache cost more than it saved: worse, it was capped at 1000\n * entries against a 1456-unit table, so any sweep over the full vocabulary\n * (which is exactly what LanguageService does to build completions) evicted\n * on almost every call. That one change took the full-table sweep from 7.7ms\n * to under 20us.\n */\nexport function resolveUnit(unit: string): string {\n return unit;\n}\n\n// MEASURE_KIND_NAMES now comes from the generated table (it is derived data,\n// so the generator emits it rather than it being retyped here). The reason it\n// is a module-level constant has not changed: getMeasure() runs at least twice\n// per conversion, and this used to be reallocated on every call.\n\n/**\n * Get the measure/dimension kind for `unit` (e.g. `\"length\"`, `\"mass\"`,\n * `\"temperature\"`), used to check whether two units are even in the same\n * dimension before attempting a conversion.\n *\n * @returns `undefined` if `unit` isn't recognized, rather than throwing.\n */\nexport function getMeasure(unit: string): string | undefined {\n // Workday is a Time-measure unit by convention (see isWorkdayUnit's doc\n // comment) and is not in the base table, so resolve its measure via \"day\"\n // instead of attempting the real lookup below.\n if (isWorkdayUnit(unit)) return getMeasure(\"day\");\n\n // Extended (custom) categories the base table has no measure kind for,\n // see ExtendedUnits.ts.\n const extended = EXTENDED_UNITS[unit];\n if (extended) return extended.measure;\n\n const entry = lookupUnit(unit);\n if (entry === undefined) return undefined;\n\n return MEASURE_KIND_NAMES[entry[0]];\n}\n\n/**\n * Check whether `from` can be converted to `to`. Same unit, or same\n * measure kind (length, mass, ...) and the underlying tables accept the pair.\n * Never throws; returns `false` on any failure.\n */\nexport function canConvert(from: string, to: string): boolean {\n if (from === to) return true;\n if (isWorkdayUnit(from) || isWorkdayUnit(to)) {\n const fromMeasure = getMeasure(from);\n const toMeasure = getMeasure(to);\n return !!fromMeasure && fromMeasure === toMeasure;\n }\n // One table read per side, comparing numeric kind ids. The old shape called\n // getMeasure() on each side (two more reads) purely to compare the resulting\n // STRINGS, then did a throwaway conversion to confirm what the kind check had\n // already established.\n const fromEntry = lookupUnit(from);\n const toEntry = lookupUnit(to);\n if (fromEntry !== undefined && toEntry !== undefined) {\n return fromEntry[0] === toEntry[0];\n }\n\n // Extended (custom) categories aren't in the base table at all, so they are\n // compared on their own measure names instead.\n const fromExtended = EXTENDED_UNITS[from];\n const toExtended = EXTENDED_UNITS[to];\n if (fromExtended !== undefined && toExtended !== undefined) {\n return fromExtended.measure === toExtended.measure;\n }\n\n // Mixed: one side is in the base table and the other is extended. That used\n // to be refused outright, on the grounds that the two measure spaces are\n // disjoint. They are not, once an extended unit names a measure the base\n // table also has: `furlong` is a length and so is `m`, and the ratio between\n // them is exactly what both tables already record.\n return bridgesToBaseMeasure(from, to) || bridgesToBaseMeasure(to, from);\n}\n\n/**\n * Whether `extendedUnit` extends a measure the base table also knows, so a\n * value in it can reach `baseUnit`.\n *\n * The bridge works because both tables express a unit as a ratio to the same\n * physical base: the generated table's length ratios are metres and its mass\n * ratios are grams, and an extended unit declaring `measure: \"length\"` states\n * its `toBase` in the same metres. Composing the two ratios is then ordinary\n * arithmetic rather than a second conversion system.\n *\n * A measure the base table has no concept of, such as pace, still fails here,\n * which is the behaviour this replaced and the reason the check is by measure\n * name rather than by presence in the extended table.\n */\nfunction bridgesToBaseMeasure(extendedUnit: string, baseUnit: string): boolean {\n const extended = EXTENDED_UNITS[extendedUnit];\n if (extended === undefined) return false;\n\n const base = lookupUnit(resolveUnit(baseUnit));\n if (base === undefined) return false;\n\n return MEASURE_KIND_NAMES[base[0]] === extended.measure;\n}\n\n/**\n * Convert `value` from unit `from` to unit `to`.\n *\n * Does not validate that the conversion is possible, callers should check\n * with {@link canConvert} first if `from`/`to` aren't already known-good.\n *\n * THROWS a RangeError for an unknown unit or a cross-measure pair. `VM.ts`'s\n * `extractDurationMs()` depends on that, see {@link convertRaw}.\n *\n * This used to memoize a per-pair conversion factor in an LFU cache. The cache\n * is gone: computing the factor is now two Map reads, while the cache cost a\n * template-string key allocation on every call plus the LFU's own frequency\n * bookkeeping, so it was slower than the work it avoided. Removing it is\n * bit-exact, not merely close: the cache stored `convertRaw(1, f, t)`, which is\n * exactly `fromRatio / toRatio`, and then multiplied, which is the identical\n * expression `convertRaw(value, f, t)` evaluates. It also deleted the special\n * case that existed only to keep offset-based temperature pairs out of a\n * factor cache.\n */\nexport function convertUnit(value: number, from: string, to: string): number {\n if (from === to) return value;\n\n // Fast path first: two ordinary units, which is nearly every call. Resolving\n // both here and handing the entries to convertResolved() avoids looking them\n // up again inside convertRaw(). Neither workdays nor extended units appear in\n // the base table, so they always fall through to the branches below and this\n // ordering cannot steal a case from them. UnitVocabulary.spec.ts pins that\n // the two vocabularies stay disjoint.\n const fromEntry = lookupUnit(from);\n const toEntry = lookupUnit(to);\n if (fromEntry !== undefined && toEntry !== undefined) {\n return convertResolved(value, from, to, fromEntry, toEntry);\n }\n\n // Workday <-> any other Time-measure unit: pivot through \"day\" using the\n // fixed 7/5 ratio (see isWorkdayUnit's doc comment above).\n if (isWorkdayUnit(from) && isWorkdayUnit(to)) return value; // \"workday\" <-> \"workdays\" alias\n if (isWorkdayUnit(from)) {\n const days = value * WORKDAY_TO_DAY_FACTOR;\n return to === \"day\" ? days : convertUnit(days, \"day\", to);\n }\n if (isWorkdayUnit(to)) {\n const days = from === \"day\" ? value : convertUnit(value, from, \"day\");\n return days / WORKDAY_TO_DAY_FACTOR;\n }\n\n // Extended (custom) categories the base table has no measure kind for\n // (see ExtendedUnits.ts), compute the ratio directly from each unit's\n // factor-to-base value instead of calling convertRaw(), which would throw\n // on an unrecognized unit string. Every extended category is a pure linear\n // ratio scale (no Temperature-style offset), so this is always safe.\n const fExt = EXTENDED_UNITS[from];\n const tExt = EXTENDED_UNITS[to];\n if (fExt !== undefined && tExt !== undefined) {\n return value * (fExt.toBase / tExt.toBase);\n }\n\n // One side extended, the other in the base table, sharing a measure. Convert\n // through the measure's base unit, which both tables state their ratios\n // against: an extended length declares its `toBase` in metres, and the\n // generated table's length ratios are metres too.\n if (fExt !== undefined && bridgesToBaseMeasure(from, to)) {\n return convertRaw(value * fExt.toBase, baseUnitFor(to), to);\n }\n if (tExt !== undefined && bridgesToBaseMeasure(to, from)) {\n return convertRaw(value, from, baseUnitFor(from)) / tExt.toBase;\n }\n\n // Offsets, cross-measure rejection and the unknown-unit throw all live in\n // convertRaw. Nothing is layered on top here any more.\n return convertRaw(value, from, to);\n}\n\n/**\n * The unit a measure states its ratios against, found from any unit in it.\n *\n * Read out of the table rather than hard-coded, so it cannot drift from the\n * ratios it has to agree with: the base is whichever unit of that measure has\n * a ratio of exactly one.\n */\nfunction baseUnitFor(unit: string): string {\n const entry = lookupUnit(resolveUnit(unit));\n if (entry === undefined) return unit;\n\n for (const symbol of Object.keys(UNIT_TABLE)) {\n const candidate = UNIT_TABLE[symbol];\n if (candidate[0] === entry[0] && candidate[1] === 1) return symbol;\n }\n return unit;\n}\n\n/**\n * List every unit symbol in the same measure/dimension as `unit` (wiki:\n * Units-Of-Measurement, \"Conversion Possibilities\", `sourceUnit to ?`\n * e.g. `cm to ?\"` → every Length unit). Excludes `unit` itself.\n *\n * Reads MEASURE_SYMBOLS, which is a curated symbols-only vocabulary and\n * deliberately NOT the keys of the unit table filtered by kind. The two\n * differ: Volume's symbols include `c` and `pt` but not `cup`/`cups`, and\n * Time's include `wk` and `mo` but not `week`/`month`. Deriving this list\n * from the unit table instead would roughly quadruple every answer.\n *\n * @returns `[]` if `unit` isn't recognized, rather than throwing.\n */\nexport function getConvertiblePossibilities(unit: string): string[] {\n const resolved = resolveUnit(unit);\n const entry = lookupUnit(resolved);\n if (entry === undefined) return [];\n const symbols = MEASURE_SYMBOLS[entry[0]];\n if (!symbols) return [];\n return symbols.filter((s) => s !== resolved);\n}\n\n/** Check whether `unit` is a unit the conversion tables recognize. Never throws. */\nexport function isConvertibleUnit(unit: string): boolean {\n if (isWorkdayUnit(unit)) return true;\n if (EXTENDED_UNITS[unit]) return true;\n return lookupUnit(resolveUnit(unit)) !== undefined;\n}\n\n/**\n * Convert `value` (in `unit`) to whichever unit of the same measure gives\n * the most human-readable magnitude, e.g. 1500 metres becomes 1.5 km. Falls\n * back to returning `value`/`unit` unchanged if `unit` isn't recognized,\n * which is what every extended unit and workday does.\n *\n * Note the chosen unit is drawn from the best-unit lists, which are not\n * restricted to spellings the lexer accepts: 0.5 l reports \"mL\".\n */\nexport function getBestUnit(value: number, unit: string): { value: number; unit: string } {\n const u = resolveUnit(unit);\n try {\n const result = convertToBestMetric(value, u);\n return { value: result.quantity, unit: result.unit };\n } catch {\n return { value, unit: u };\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lexer/ExpressionLexer.ts"],"names":["registerAllTokenTypes","getLocale","knownUnits","tokenTypeId","ErrorFactory","input","text"],"mappings":";;;;;;;;AAOAA,uCAAA,EAAsB;AA8GtB,SAAS,mBAAA,GAAkC;AACzC,EAAA,MAAM,KAAA,GAAQ,IAAI,UAAA,CAAW,GAAG,CAAA;AAGhC,EAAA,KAAA,IAAS,IAAI,EAAA,EAAI,CAAA,IAAK,IAAI,CAAA,EAAA,EAAK,KAAA,CAAM,CAAC,CAAA,GAAI,CAAA;AAG1C,EAAA,KAAA,IAAS,IAAI,EAAA,EAAI,CAAA,IAAK,IAAI,CAAA,EAAA,EA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AAA,CAAM,UAAA,CAAW,GAAG,CAAA;AAC/B,MAAA,IAAI,EAAA,KAAO,EAAA,IAAM,EAAA,KAAO,EAAA,EAAI;AAC5B,MAAA,GAAA,EAAA;AAAA,IACF;AAEA,IAAA,MAAM,IAAA,GAAO,KAAA,CAAM,KAAA,CAAM,KAAA,EAAO,GAAG,CAAA;AACnC,IAAA,IAAA,CAAK,GAAA,GAAM,GAAA;AACX,IAAA,OAAO,IAAI,UAAA,CAAW,SAAA,EAAWD,6BAAA,CAAY,SAAS,CAAA,EAAG,IAAA,EAAM,IAAA,EAAM,KAAA,EAAO,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,QAAQ,CAAA;AAAA,EACpG;AACF,CAAA;AAl+Ca,gBAAA,CACa,aAAa,mBAAA,EAAoB;AADpD,IAAM,eAAA,GAAN","file":"chunk-R7YVBHCV.cjs","sourcesContent":["import { Token, tokenTypeId, registerAllTokenTypes } from '@solve-js/lexer/Token';\nimport { knownUnits } from '@solve-js/lexer/units';\nimport { getLocale, type ILocale } from '@solve-js/constants/locales';\nimport { ErrorFactory } from '@solve-js/errors/UnifiedErrorFramework';\nimport type { TokenLookup } from '@solve-js/lexer/TokenClassRegistry';\n\n// Bootstrap all token types at module load\nregisterAllTokenTypes();\n\n// ── Markdown line classification (Phase B) ──────────────────────────────\n\n/** What a line is, structurally, before anything tries to evaluate it. */\nexport type MarkdownLineType =\n | 'expression'\n | 'prose'\n | 'heading'\n | 'blockquote'\n | 'list'\n | 'code_fence'\n | 'math_fence'\n | 'table'\n | 'table_separator'\n | 'hr'\n | 'wikilink'\n | 'comment'\n | 'empty';\n\n/**\n * What a line is and whether it holds anything to evaluate.\n *\n * Produced by a character-level scan that never consults the keyword, unit or\n * operator tables, so any lexer gives the same answer for the same line. See\n * `__tests__/lexer/LineClassificationIsVocabularyIndependent.spec.ts`.\n */\nexport interface LineClassification {\n /** The type of this markdown line */\n type: MarkdownLineType;\n /** Whether this line should be skipped (no expression evaluation) */\n skip: boolean;\n /** Whether the line contains inline solve markers (`s`...``) */\n hasInlineSolve: boolean;\n /**\n * Offset of the first evaluable character, when structural markup precedes\n * it. Absolute, in the same coordinates the classification was asked for,\n * and absent when the whole line is evaluable.\n *\n * A list marker is markup, not arithmetic. `- 100 + 20` is a bullet holding\n * `100 + 20`, but `-` is also a prefix operator, so without this the line\n * evaluated as negative one hundred and answered -80: a wrong answer that\n * looks like a right one. `*` and `+` in the same position could not even do\n * that, one erroring and the other correct by luck, so the three markers\n * disagreed with each other about the same document.\n *\n * Consumers must slice both the text and the token stream from here, or the\n * two describe different lines.\n */\n contentOffset?: number;\n}\n\n/** Inline solve position with precise coordinates */\nexport interface InlineSolveSpan {\n /** Character offset of the `s`` marker */\n start: number;\n /** Character offset past the closing `` ` `` */\n end: number;\n /** The expression text between the backticks */\n expression: string;\n /** 1-based column of the `s`` marker */\n columnNumber: number;\n /** Token index of INLINE_SOLVE_START in the line's token array (set during tokenization). */\n startTokenIndex?: number;\n /** Token index of closing BACKTICK_OPEN in the line's token array (set during tokenization). */\n endTokenIndex?: number;\n}\n\n/**\n * Result from a single line processed by scanDocument().\n * Combines line classification, tokenized tokens, and inline solve spans\n * into a single structure, eliminating the need for separate classifyLine()\n * findInlineSolves(), and per-line Lexer.reset() calls.\n */\nexport interface ScanLineResult {\n /** The raw line text (without trailing newline). */\n text: string;\n /** 1-based line number within the document. */\n lineNumber: number;\n /** Character offset of the line start within the document. */\n startOffset: number;\n /** Character offset of the line end (before newline). */\n endOffset: number;\n /** The line classification. */\n classification: LineClassification;\n /** Tokenized tokens (empty array if line is skipped). */\n tokens: Token[];\n /** Inline solve spans found in this line (empty if none). */\n inlineSolves: InlineSolveSpan[];\n}\n\n// ── Character class constants ─────────────────────────────────────────────\n// Used as the result of the CHAR_CLASS lookup table. V8 compiles the\n// outer switch on these small integer constants into a jump table.\nconst enum CharClass {\n SKIP = 0, // Invalid / control / unicode fallback\n WHITESPACE = 1, // space, tab, \\n, \\r\n DIGIT = 2, // 0-9\n ALPHA = 3, // a-z, A-Z, _\n DOT = 4, // . (could be decimal point or DOT token)\n OPERATOR = 5, // + - * / ^ % ( ) [ ] { } , : ; = ? & | ~ ! < >\n QUOTE = 6, // \"\n HASH = 7, // # (comment)\n DOLLAR = 8, // $\n POUND = 9, // £ (U+00A3)\n EURO = 10, // € (U+20AC)\n BACKTICK = 11, // `\n}\n\n// ── Static character class table (built once at module load) ──────────────\nfunction buildCharClassTable(): Uint8Array {\n const table = new Uint8Array(128);\n\n // Digits 0-9\n for (let i = 48; i <= 57; i++) table[i] = CharClass.DIGIT;\n\n // Uppercase A-Z\n for (let i = 65; i <= 90; i++) table[i] = CharClass.ALPHA;\n\n // Lowercase a-z\n for (let i = 97; i <= 122; i++) table[i] = CharClass.ALPHA;\n\n // Underscore\n table[95] = CharClass.ALPHA;\n\n // Dot\n table[46] = CharClass.DOT;\n\n // Whitespace\n table[32] = CharClass.WHITESPACE; // space\n table[9] = CharClass.WHITESPACE; // tab\n table[10] = CharClass.WHITESPACE; // \\n\n table[13] = CharClass.WHITESPACE; // \\r\n\n // Operators / punctuation\n table[33] = CharClass.OPERATOR; // !\n table[37] = CharClass.OPERATOR; // %\n table[38] = CharClass.OPERATOR; // &\n table[40] = CharClass.OPERATOR; // (\n table[41] = CharClass.OPERATOR; // )\n table[42] = CharClass.OPERATOR; // *\n table[43] = CharClass.OPERATOR; // +\n table[44] = CharClass.OPERATOR; // ,\n table[45] = CharClass.OPERATOR; // -\n table[47] = CharClass.OPERATOR; // /\n table[58] = CharClass.OPERATOR; // :\n table[59] = CharClass.OPERATOR; // ;\n table[60] = CharClass.OPERATOR; // <\n table[61] = CharClass.OPERATOR; // =\n table[62] = CharClass.OPERATOR; // >\n table[63] = CharClass.OPERATOR; // ?\n table[91] = CharClass.OPERATOR; // [\n table[93] = CharClass.OPERATOR; // ]\n table[94] = CharClass.OPERATOR; // ^\n table[123] = CharClass.OPERATOR; // {\n table[124] = CharClass.OPERATOR; // |\n table[125] = CharClass.OPERATOR; // }\n table[126] = CharClass.OPERATOR; // ~\n // \"@\" was previously unclassified (defaulted to CharClass.SKIP, silently\n // dropped before ever reaching OP_MAP). See OP_MAP's own \"@\" entry doc\n // comment for why this is being activated now.\n table[64] = CharClass.OPERATOR; // @\n\n // Other\n table[34] = CharClass.QUOTE; // \"\n table[35] = CharClass.HASH; // #\n table[36] = CharClass.DOLLAR; // $\n table[96] = CharClass.BACKTICK; // `\n\n return table;\n}\n\n/**\n * Whether a non-ASCII code point separates tokens rather than joining them.\n *\n * The CHAR_CLASS table above is 128 entries wide, so every code point past\n * ASCII falls through to one branch that reads it as part of an identifier.\n * That is right for `café`, `日本語` and emoji, and wrong for the dozen or so\n * code points that are whitespace without being ASCII whitespace. Without this,\n * a no-break space between two operands JOINED them: `1<NBSP>+<NBSP>1` lexed as\n * one identifier and reported \"Undefined variable: 1 + 1\", and a byte-order\n * mark at the head of a file did the same to its first line. Both arrive\n * constantly in pasted text, from a web page, a word processor, a spreadsheet\n * export, or a Windows editor that writes a BOM.\n *\n * The zero-width JOINERS are deliberately absent. U+200D is what holds a family\n * emoji together as one grapheme, and U+200C is its non-joining partner; both\n * bind their neighbours rather than separating them, so they stay identifier\n * characters. U+200B, the zero-width SPACE, is a separator despite being\n * invisible, which is exactly why it is worth handling: it is unreadable on\n * screen and would otherwise silently break the line it lands in.\n *\n * @param cc - A UTF-16 code unit, only meaningful for values >= 128.\n * @returns True when the character should be skipped like a space.\n */\nfunction isUnicodeSpace(cc: number): boolean {\n return (\n cc === 0x0085 || // NEL, next line\n cc === 0x00A0 || // no-break space\n cc === 0x1680 || // ogham space mark\n (cc >= 0x2000 && cc <= 0x200A) || // en quad through hair space, incl. figure/thin space\n cc === 0x200B || // zero-width space\n cc === 0x2028 || // line separator\n cc === 0x2029 || // paragraph separator\n cc === 0x202F || // narrow no-break space\n cc === 0x205F || // medium mathematical space\n cc === 0x3000 || // ideographic space\n cc === 0xFEFF // byte-order mark / zero-width no-break space\n );\n}\n\n// ── Monomorphic Token class ───────────────────────────────────────────────\n// V8 assigns a single stable HiddenClass because all properties are\n// initialized in the constructor and never added/removed afterwards.\n// This enables fast property access (inline cache hits) and allows\n// allocation in V8's nursery (cheap GC).\n// All 9 fields are always set, no optional fields, no different shapes.\n/**\n * A token, as the lexer produces it.\n *\n * A class rather than an object literal because tokens are created on every\n * keystroke and a shared hidden class keeps that path predictable for the\n * engine running it.\n */\nexport class LexerToken implements Token {\n constructor(\n public type: string,\n public typeId: number,\n public value: string,\n public text: string,\n public offset: number,\n public lineBreaks: number,\n public line: number,\n public col: number,\n /** See {@link Token.sourceEnd}. Set only on normalizer-fused tokens. */\n public sourceEnd?: number,\n ) {}\n}\n\n// ── Two-character operator lookup ─────────────────────────────────────────\n// Maps first-char → (second-char → token type). Used for operators like\n// ==, !=, >=, <=, **, <<, >>.\ninterface TwoCharOpMap {\n [firstChar: number]: { [secondChar: number]: string };\n}\nconst TWO_CHAR_OPS: TwoCharOpMap = {\n 61: { 61: 'EQUALITY', 62: 'THEREFORE' }, // ==, => (opposite char order from >='s GTE below — no collision)\n 33: { 61: 'NEQ' }, // !=\n 62: { 61: 'GTE' }, // >=\n 60: { 61: 'LTE' }, // <=\n 38: { 38: 'LOGICAL_AND' }, // &&\n 124: { 124: 'LOGICAL_OR' }, // ||\n // Note: ** is NOT a single token, the existing moo lexer emits two\n // separate STAR tokens, and the parser consumes them that way.\n // 42: { 42: 'EXPONENT' }, // **, disabled for moo compatibility\n};\n// Note: LSHIFT (<<) and RSHIFT (>>) are handled separately because\n// 60 is also used for LTE, so we check LTE first then LSHIFT.\n\n// ── Single-character operator lookup ──────────────────────────────────────\nconst OP_MAP: Record<number, string> = {\n 43: 'PLUS', // +\n 45: 'MINUS', // -\n 42: 'STAR', // *\n 47: 'SLASH', // /\n 94: 'CARET', // ^\n 37: 'PERCENT', // %\n 40: 'LPAREN', // (\n 41: 'RPAREN', // )\n 91: 'LBRACKET', // [\n 93: 'RBRACKET', // ]\n 123: 'LBRACE', // {\n 125: 'RBRACE', // }\n 44: 'COMMA', // ,\n 58: 'COLON', // :\n 59: 'SEMICOLON',// ;\n 61: 'EQUALS', // =\n 63: 'QUESTION', // ?\n 33: 'BANG', // !\n 38: 'BIT_AND', // &\n 124: 'BIT_OR', // |\n 60: 'LT', // <\n 62: 'GT', // >\n 126: 'BIT_NOT', // ~\n // \"@\", activates the token type name already dormant-reserved for this\n // exact purpose (see Token.ts's OVER/RATE_AT doc comment and\n // normalizer/TokenNormalizer.ts's NON_WORD_NAMES, both of which already\n // anticipated \"AT\" as a future \"@\" symbol token before this addition).\n // Backs the time package's video-timecode literal's alternate fps\n // separator (`01:02:03:04 @ 30fps`, equivalent to `... at 30fps`). See\n // packages/time/parselets/VideoTimecodeParselet.ts.\n 64: 'AT', // @\n};\n\n/**\n * Plugin interface for extending the ExpressionLexer with custom tokens.\n *\n * Plugins can register:\n * - `keywords`: Map identifier strings to custom token types (checked after locale keywords).\n * - `operators`: Map multi-character operator sequences to custom token types.\n * - `units`: Register additional unit identifiers (checked alongside built-in units).\n *\n * Multi-word phrase matching has been moved to the TokenNormalizer post-lexer\n * stage. To register phrase patterns, use `IEnginePackage.normalizerRules` instead.\n *\n * All registrations are additive, built-in patterns still work.\n */\nexport interface LexerVocabulary {\n /**\n * Keyword → tokenType mappings. Each key is a lowercase identifier that,\n * when encountered, will emit the specified token type instead of IDENT.\n * These are checked AFTER the locale's built-in keywordMap, so locale\n * keywords take priority.\n */\n keywords?: Record<string, string>;\n\n /**\n * Multi-character operator → tokenType mappings. Each key is the exact\n * character sequence (e.g., \"::\", \"->\", \"=>\") and the value is the token\n * type to emit. Two-character operators take priority during matching.\n * Built-in operators (==, !=, >=, <=, <<, >>) always take priority.\n */\n operators?: Record<string, string>;\n\n /**\n * Additional unit identifiers to recognize (e.g., \"gp\", \"osrs\", \"tile\").\n * These are checked alongside the built-in `knownUnits` set.\n */\n units?: string[];\n\n /**\n * Whole-line patterns matched against the RAW line text, BEFORE any\n * per-character tokenization begins.\n *\n * Every other extension point in this file (`keywords`/`operators`/\n * `units`, plus `IEnginePackage.phrases`/`normalizerRules`) transforms\n * a token STREAM -- they all assume the line is, at some granularity,\n * valid Solve syntax. This hook exists for the one shape that isn't:\n * a package whose grammar captures arbitrary free-form text terminated\n * by a fixed marker (e.g. a natural-language query ending in `= ?`),\n * where the text itself (\"distance to the moon\") would never tokenize\n * or parse as a normal expression and must be captured verbatim\n * instead -- see `packages/knowledge/` for the reference use.\n *\n * Each entry's `pattern` is tested (via `RegExp.exec`) against the\n * full, untrimmed line text. If it matches AND capture group 1 is\n * non-empty after trimming, the ENTIRE line becomes a single\n * synthetic token of `tokenType` whose `value`/`text` is the trimmed\n * capture group -- the character-by-character scanner never runs for\n * that line. Patterns are tried in registration order; the first\n * match wins. A package registering a rule here still needs a\n * `prefixParselets` entry for `tokenType` to actually consume the\n * resulting token.\n *\n * Because this bypasses tokenization entirely, a matching line can\n * contain characters that would otherwise be lexer errors (unmatched\n * quotes, stray symbols, ...) -- by design, since the whole point is\n * to hand the package raw text the normal pipeline was never meant to\n * parse.\n */\n rawLinePatterns?: Array<{ pattern: RegExp; tokenType: string }>;\n}\n\n// ── Expression gating (L1) ──────────────────────────────────────────────\n// Pre-computed Set of character codes that indicate an expression might\n// be present. Used by hasExpressionIndicators() to gate prose lines\n// before full tokenization.\n//\n// NOTE: Currently unused, L1 prose gating was removed from classifyFromPositions()\n// because it incorrectly skipped keyword-only lines (\"pi\"), single identifiers\n// (\"hello\"), and short alpha lines. Retained for future re-implementation with\n// keyword-awareness and proper test coverage.\nconst EXPRESSION_INDICATOR_CODES = (() => {\n const set = new Set<number>();\n // Digits 0-9\n for (let i = 48; i <= 57; i++) set.add(i);\n // Operators / punctuation\n // Note: colon (58) is intentionally excluded, it's common in prose\n // (e.g., \"Subject: Hello world\") and would cause false-positive\n // expression classification. Variable assignment lines like\n // \":myVar = 5\" are still caught by '=' and digit indicators.\n const opCodes = [43, 45, 42, 47, 94, 37, 40, 41, 91, 93, 123, 125, 61, 60, 62, 33, 38, 124, 126, 59, 63];\n for (const c of opCodes) set.add(c);\n // Currency\n set.add(36); // $\n set.add(0x00A3); // £\n set.add(0x20AC); // €\n set.add(0x00A5); // ¥\n set.add(0x20BD); // ₽\n set.add(0x20A9); // ₩\n // Backtick (inline solve)\n set.add(96); // `\n // Dot (could be decimal)\n set.add(46); // .\n // Hash (comment, still an expression indicator)\n set.add(35); // #\n return set;\n})();\n\n// ── ExpressionLexer ───────────────────────────────────────────────────────\n/**\n * Character-by-character tokenizer for expression text.\n *\n * Scans a raw line/expression string into a stream of typed tokens\n * (numbers, identifiers, operators, units, keywords, ...), handling\n * markdown-line classification (`classifyLine`), inline `` s`...` `` solve\n * spans, and package-contributed vocabulary (registered via\n * {@link registerVocabulary}/{@link unregisterVocabulary}, keywords\n * operators, and units a package wants recognized as their own token\n * types rather than falling through to generic identifiers).\n *\n * Most consumers should use the higher-level {@link Lexer} wrapper, which\n * adds streaming `next()`/`peek()` access over this class's scan results.\n */\nexport class ExpressionLexer {\n private static readonly CHAR_CLASS = buildCharClassTable();\n /**\n * Configured TokenLookup from TokenClassRegistry. When set, replaces\n * the internal keyword map and unit set with registry-built equivalents.\n * Enables data-driven keyword/unit registration across locale keywords,\n * provider keywords, and plugins.\n *\n * Set at construction time via the constructor parameter. Plugin-registered\n * keywords/units (via registerVocabulary()) are checked alongside\n * the configuredLookup, neither source is bypassed.\n */\tprivate configuredLookup: TokenLookup | null = null;\n\n\t// Instance state\n private input: string = '';\n private pos: number = 0;\n private len: number = 0;\n\n // Line / column tracking (1-indexed)\n private line: number = 1;\n private lineStartPos: number = 0;\n\n // Keyword map: lowercase identifier → token type (locale keywords only)\n private keywordMap: Map<string, string>;\n\n // ── Merged lookup collections (keywordMap + pluginKeywordMap, knownUnits + pluginUnits)\n private mergedKeywords: Map<string, string>;\n private mergedUnits: Set<string>;\n\n // Plugin-extensible keyword map (merged with locale keywordMap)\n private pluginKeywordMap: Map<string, string> = new Map();\n\n // Plugin-extensible two-char operators: firstChar → (secondChar → tokenType)\n private pluginOperators: Map<number, Map<number, string>> = new Map();\n\n // Plugin-extensible units (merged with knownUnits)\n private pluginUnits: Set<string> = new Set();\t// Fast-path guards: skip plugin lookups entirely when no plugins registered\n\tprivate hasPluginOps = false;\n\n // Locale for function-identifier lookups\n private localeCode: string;\n private locale: ILocale;\n\n /**\n * Inline solve spans collected during the most recent tokenization pass.\n * Populated by [Symbol.iterator]() and consumed by scanDocument().\n */\n _inlineSolveSpans: InlineSolveSpan[] = [];\n\n // Plugin-extensible raw-line patterns. See LexerVocabulary.rawLinePatterns.\n private pluginRawLinePatterns: Array<{ pattern: RegExp; tokenType: string }> = [];\n\n /**\n * If a `rawLinePatterns` rule matches the FULL text most recently passed\n * to {@link reset}, this holds the single synthetic token that\n * {@link tokenizeAll} should return instead of running the\n * character-by-character scanner. Cleared (re-evaluated) on every\n * {@link reset} call. `null` when no plugin registered any raw-line\n * patterns, or none matched, the overwhelmingly common case, checked\n * with a `length === 0` guard before ever touching this field so a\n * plugin-free lexer pays zero cost for the feature.\n */\n private pendingRawLineToken: Token | null = null;\n\n /**\n * Test `text` against every registered `rawLinePatterns` rule, in\n * registration order. Returns a synthetic token for the first rule\n * whose `pattern` matches AND whose capture group 1 is non-empty after\n * trimming; returns `null` if no rule matches (the normal\n * character-by-character scanner should run instead).\n */\n private matchRawLine(text: string): Token | null {\n for (const rule of this.pluginRawLinePatterns) {\n const m = rule.pattern.exec(text);\n if (m && typeof m[1] === 'string') {\n const value = m[1].trim();\n if (value.length > 0) {\n return new LexerToken(rule.tokenType, tokenTypeId(rule.tokenType), value, value, 0, 0, this.line, 1);\n }\n }\n }\n return null;\n }\n\n /** Rebuild merged keyword and unit collections after plugin registration. */\n private rebuildMergedCollections(): void {\n this.mergedKeywords = new Map([...this.keywordMap, ...this.pluginKeywordMap]);\n this.mergedUnits = new Set([...knownUnits, ...this.pluginUnits]);\n }\n\n constructor(localeCode = 'en', lookup?: TokenLookup) {\n this.localeCode = localeCode;\n this.locale = getLocale(localeCode);\n this.configuredLookup = lookup ?? null;\n this.keywordMap = new Map<string, string>();\n for (const [k, v] of Object.entries(this.locale.keywordMap)) {\n this.keywordMap.set(k.toLowerCase(), v);\n }\n this.mergedKeywords = new Map(this.keywordMap);\n this.mergedUnits = new Set(knownUnits);\n }\n\n /**\n * Register a plugin to extend the lexer with custom tokens.\n *\n * All registrations are additive, built-in patterns still work.\n * Keywords, operators, and units from the plugin are merged\n * with existing ones. Calling multiple times adds more entries.\n *\n * Note: multi-word phrases are now handled by the TokenNormalizer\n * (see `IEnginePackage.normalizerRules`), not the lexer.\n *\n * Built-in tokens CANNOT be overridden. Throws a EngineError if the\n * plugin attempts to register a keyword, operator, or unit\n * that conflicts with a built-in one.\n */\n registerVocabulary(plugin: LexerVocabulary): void {\n if (plugin.keywords) {\n for (const [keyword, tokenType] of Object.entries(plugin.keywords)) {\n const lower = keyword.toLowerCase();\n // Guard: prevent overriding built-in locale keywords\n if (this.keywordMap.has(lower)) {\n throw ErrorFactory.config(\n 'PLUGIN_KEYWORD_COLLISION',\n `Plugin keyword \"${keyword}\" conflicts with built-in keyword ` +\n `(type: ${this.keywordMap.get(lower)}). Built-in keywords cannot be overridden.`,\n { keyword, builtinType: this.keywordMap.get(lower) }\n );\n }\n this.pluginKeywordMap.set(lower, tokenType);\n }\n this.rebuildMergedCollections();\n }\n\n if (plugin.operators) {\n this.hasPluginOps = true;\n for (const [chars, tokenType] of Object.entries(plugin.operators)) {\n // Only support 2-char operators for the fast path\n if (chars.length === 2) {\n const first = chars.charCodeAt(0);\n const second = chars.charCodeAt(1);\n\n // Guard: prevent overriding built-in two-char operators (==, !=, >=, <=)\n const builtInSecondMap = TWO_CHAR_OPS[first];\n if (builtInSecondMap && builtInSecondMap[second] !== undefined) {\n throw ErrorFactory.config(\n 'PLUGIN_OPERATOR_COLLISION',\n `Plugin operator \"${chars}\" conflicts with built-in operator ` +\n `(type: ${builtInSecondMap[second]}). Built-in operators cannot be overridden.`,\n { operator: chars, builtinType: builtInSecondMap[second] }\n );\n }\n // Guard: prevent overriding LSHIFT (<<) and RSHIFT (>>)\n if (first === 60 && second === 60) {\n throw ErrorFactory.config(\n 'PLUGIN_OPERATOR_COLLISION',\n `Plugin operator \"${chars}\" conflicts with built-in operator ` +\n `(type: LSHIFT). Built-in operators cannot be overridden.`,\n { operator: chars, builtinType: 'LSHIFT' }\n );\n }\n if (first === 62 && second === 62) {\n throw ErrorFactory.config(\n 'PLUGIN_OPERATOR_COLLISION',\n `Plugin operator \"${chars}\" conflicts with built-in operator ` +\n `(type: RSHIFT). Built-in operators cannot be overridden.`,\n { operator: chars, builtinType: 'RSHIFT' }\n );\n }\n // Guard: prevent overriding comment sequences (//)\n if (first === 47 && second === 47) {\n throw ErrorFactory.config(\n 'PLUGIN_OPERATOR_COLLISION',\n `Plugin operator \"${chars}\" conflicts with built-in comment sequence. ` +\n `Comment sequences cannot be overridden.`,\n { operator: chars, builtinType: 'COMMENT' }\n );\n }\n\n let inner = this.pluginOperators.get(first);\n if (!inner) {\n inner = new Map();\n this.pluginOperators.set(first, inner);\n }\n inner.set(second, tokenType);\n }\n }\n }\n\n if (plugin.units) {\n for (const unit of plugin.units) {\n // Guard: prevent overriding built-in units\n if (knownUnits.has(unit)) {\n throw ErrorFactory.config(\n 'PLUGIN_UNIT_COLLISION',\n `Plugin unit \"${unit}\" conflicts with a built-in unit. ` +\n `Built-in units cannot be overridden.`,\n { unit }\n );\n }\n this.pluginUnits.add(unit);\n }\n this.rebuildMergedCollections();\n }\n\n if (plugin.rawLinePatterns) {\n this.pluginRawLinePatterns.push(...plugin.rawLinePatterns);\n }\n }\n\n /**\n * Unregister a plugin, removing its custom tokens from the lexer.\n *\n * This is the inverse of registerVocabulary(). All keywords, operators,\n * and units registered by the plugin are removed. After\n * unregistration, those tokens will revert to their default behavior\n * (e.g., keywords become IDENT, operators become ERROR).\n *\n * Calling unregisterVocabulary with a plugin that was never registered\n * is safe, it simply has no effect.\n */\n unregisterVocabulary(plugin: LexerVocabulary): void {\n if (plugin.keywords) {\n for (const keyword of Object.keys(plugin.keywords)) {\n this.pluginKeywordMap.delete(keyword.toLowerCase());\n }\n \n this.rebuildMergedCollections();\n }\n\n if (plugin.operators) {\n for (const chars of Object.keys(plugin.operators)) {\n if (chars.length === 2) {\n const first = chars.charCodeAt(0);\n const second = chars.charCodeAt(1);\n const inner = this.pluginOperators.get(first);\n if (inner) {\n inner.delete(second);\n if (inner.size === 0) {\n this.pluginOperators.delete(first);\n }\n }\n }\n }\n this.hasPluginOps = this.pluginOperators.size > 0;\n }\n\n if (plugin.units) {\n for (const unit of plugin.units) {\n this.pluginUnits.delete(unit);\n }\n \n this.rebuildMergedCollections();\n }\n\n if (plugin.rawLinePatterns) {\n const toRemove = new Set(plugin.rawLinePatterns);\n this.pluginRawLinePatterns = this.pluginRawLinePatterns.filter((r) => !toRemove.has(r));\n }\n }\n\n reset(input: string): void {\n this.input = input;\n this.pos = 0;\n this.len = input.length;\n this.line = 1;\n this.lineStartPos = 0;\n this.pendingRawLineToken = this.pluginRawLinePatterns.length > 0 ? this.matchRawLine(input) : null;\n }\n\n /**\n * Scan a full document text in a single pass, classifying each line and\n * tokenizing non-skipped lines.\n *\n * Replaces the separate classifyLine() + findInlineSolves() + per-line\n * reset() + tokenizeAll() pattern with a single character-by-character\n * walk through the entire document. Key benefits:\n *\n * - **Single reset()**: `this.pos`, `this.len`, `this.line`, and\n * `this.lineStartPos` are set once for the whole document, not per-line.\n * - **Single classification**: classifyLine() runs once per line inline;\n * skipped lines are jumped over without tokenization.\n * - **Shared tokenization**: Non-skipped lines are tokenized using the\n * existing state machine, yielding Token[] without per-line reset().\n * - **Inline solve detection**: findInlineSolves() is called only for\n * lines that classifyLine() marks as having inline solves.\n *\n * Tokenization is scoped to each line by temporarily restricting\n * `this.len` to the line end position, so the [Symbol.iterator]\n * generator naturally stops at the line boundary. After tokenization,\n * `this.len` is restored and `this.pos` advances past the newline.\n *\n * @param text The full document text (with newlines).\n * @returns Array of ScanLineResult, one per line, in document order.\n */\n scanDocument(text: string): ScanLineResult[] {\n this.input = text;\n this.pos = 0;\n this.len = text.length;\n this.line = 1;\n this.lineStartPos = 0;\n\n const results: ScanLineResult[] = [];\n const input = this.input;\n const docLen = this.len;\n\n while (this.pos < docLen) {\n const lineStart = this.pos;\n\n // ── Find end of current line (newline boundary) ───────────────\n let lineEnd = this.pos;\n while (lineEnd < docLen) {\n const cc = input.charCodeAt(lineEnd);\n if (cc === 10 || cc === 13) break; // \\n or \\r\n lineEnd++;\n }\n\n const lineNumber = this.line;\n\n // ── Classify the line ─────────────────────────────────────────\n // Uses classifyFromPositions() to read from this.input directly\n // avoids allocating a substring and keeps classification reads\n // within the same memory region as tokenization.\n const classification = this.classifyFromPositions(lineStart, lineEnd);\n\n // ── Slice line text for ScanLineResult.text ────────────────\n // Hoisted above tokenization (rather than after, as originally) so the\n // raw-line-pattern check below can test the exact substring a plugin\n // registered via `LexerVocabulary.rawLinePatterns`. See reset()/\n // tokenizeAll() for the single-expression-string equivalent of this\n // same check.\n const lineText = input.slice(lineStart, lineEnd);\n\n // ── Tokenize non-skipped lines ────────────────────────────────\n let tokens: Token[] = [];\n if (!classification.skip) {\n const rawToken = this.pluginRawLinePatterns.length > 0 ? this.matchRawLine(lineText) : null;\n if (rawToken) {\n tokens = [rawToken];\n } else {\n // Scope tokenization to just this line by temporarily restricting len.\n // The [Symbol.iterator]() generator captures `this.len` at call time,\n // so creating the iterator AFTER setting this.len = lineEnd ensures\n // tokenization stops at the line boundary. After tokenization,\n // this.pos will be at lineEnd (the newline position).\n const savedLen = this.len;\n this.len = lineEnd;\n // Start past any structural marker, so the marker never becomes a\n // token. Token source offsets stay absolute, so everything\n // downstream (spans, highlighting, inline solves) still lines up\n // with the raw document.\n if (classification.contentOffset !== undefined) this.pos = classification.contentOffset;\n tokens = Array.from(this);\n this.len = savedLen;\n // this.pos is now at lineEnd, advance past newline below\n }\n }\n\n // ── Detect inline solves ──────────────────────────────────────\n // Two data sources are merged:\n // 1. _inlineSolveSpans, token indices collected inline during\n // [Symbol.iterator](). Provides correct startTokenIndex /\n // endTokenIndex. Also handles \\` escape (skips the pair\n // instead of closing the span early).\n // 2. findInlineSolves(), character-level string scan for\n // expression text. Still needed because token-based\n // reconstruction loses whitespace (the lexer skips spaces),\n // which breaks multi-word expressions like\n // \"2 weeks in days\" → \"2weeksindays\" (wrong tokenization).\n let inlineSolves: InlineSolveSpan[] = [];\n if (classification.hasInlineSolve) {\n if (!classification.skip && tokens.length > 0) {\n const charSpans = this.findInlineSolves(lineText);\n inlineSolves = this._inlineSolveSpans.map((span, i) => ({\n start: charSpans[i]?.start ?? 0,\n end: charSpans[i]?.end ?? 0,\n expression: charSpans[i]?.expression ?? '',\n columnNumber: charSpans[i]?.columnNumber ?? span.columnNumber,\n startTokenIndex: span.startTokenIndex,\n endTokenIndex: span.endTokenIndex,\n }));\n } else {\n // Skipped lines weren't tokenized, fall back to string scan\n inlineSolves = this.findInlineSolves(lineText);\n }\n }\n\n results.push({\n text: lineText,\n lineNumber,\n startOffset: lineStart,\n endOffset: lineEnd,\n classification,\n tokens,\n inlineSolves,\n });\n\n // ── Advance past newline ─────────────────────────────────────\n this.pos = lineEnd;\n if (this.pos < docLen) {\n const nlChar = input.charCodeAt(this.pos);\n if (nlChar === 13) { // \\r\n this.pos++;\n if (this.pos < docLen && input.charCodeAt(this.pos) === 10) {\n this.pos++; // skip \\n in \\r\\n\n }\n } else if (nlChar === 10) { // \\n\n this.pos++;\n }\n }\n this.line++;\n this.lineStartPos = this.pos;\n }\n\n return results;\n }\n\n /**\n * Tokenize an expression string into an array of Tokens.\n *\n * Delegates to the lazy [Symbol.iterator]() generator and collects all\n * yielded tokens via Array.from(). For memory-sensitive use cases, prefer\n * iterating the lexer directly with for...of to avoid array allocation.\n *\n * Optimizations:\n * - CHAR_CLASS jump table (Uint8Array) → switch on small integers\n * - Direct character-code dispatch (c0 cached pattern)\n * - Mathematical digit parsing (integer math, not slice+parseFloat)\n * - Inline operator tokenizer with two-char peek-ahead\n * - Whitespace eliminated in-lexer (never emitted)\n * - 0-char and 1-char fast paths\n */\n tokenizeAll(): Token[] {\n if (this.pendingRawLineToken) {\n this._inlineSolveSpans = [];\n return [this.pendingRawLineToken];\n }\n return Array.from(this);\n }\n\n // ── Lazy iterator ─────────────────────────────────────────────────────\n /**\n * Lazy token-by-token generator. Yields each token without allocating an\n * intermediate Token[] array. Supports for...of and spread usage.\n *\n * Usage:\n * for (const t of lexer) { ... } // lazy, no array allocation\n * const tokens = [...lexer]; // materializes via spread\n * const tokens = lexer.tokenizeAll(); // materializes via Array.from()\n *\n * IMPORTANT: This generator captures `this.len` ONCE at creation time\n * (const len = this.len). `scanDocument()` relies on this behavior to\n * scope tokenization to a single line by temporarily restricting\n * `this.len` to the line end position before creating the iterator.\n * Do NOT refactor to re-read `this.len` mid-loop without also updating\n * `scanDocument()`.\n */\n *[Symbol.iterator](): Generator<Token, void, undefined> {\n const len = this.len;\n\n // ── 0-char fast path ────────────────────────────────────────────────\n if (len === 0) { this._inlineSolveSpans = []; return; }\n\n // Inline solve tracking state, collected inline during tokenization\n let tokenIndex = 0;\n let openSpan: { startTokenIndex: number; startColumn: number } | null = null;\n const collectedSpans: InlineSolveSpan[] = [];\n\n // ── 1-char fast path ────────────────────────────────────────────────\n if (len === 1) {\n const c0 = this.input.charCodeAt(0);\n const cc = ExpressionLexer.CHAR_CLASS[c0] ?? CharClass.SKIP;\n\n switch (cc) {\n case CharClass.DIGIT:\n case CharClass.DOT:\n yield new LexerToken('NUMBER', tokenTypeId('NUMBER'), this.input, this.input, 0, 0, 1, 1);\n tokenIndex++;\n break;\n\n case CharClass.ALPHA: {\n const input = this.input;\n const identLower = input.toLowerCase();\n // Use pre-merged collections (built-in + plugin), single lookup each\n if (this.mergedUnits.has(input)) {\n yield new LexerToken('UNIT', tokenTypeId('UNIT'), input, input, 0, 0, 1, 1);\n } else {\n const kwType = this.mergedKeywords.get(identLower);\n if (kwType) {\n yield new LexerToken(kwType, tokenTypeId(kwType), input, input, 0, 0, 1, 1);\n } else {\n yield new LexerToken('IDENT', tokenTypeId('IDENT'), input, input, 0, 0, 1, 1);\n }\n }\n tokenIndex++;\n break;\n }\n\n case CharClass.OPERATOR: {\n const opType = OP_MAP[c0];\n if (opType) {\n yield new LexerToken(opType, tokenTypeId(opType), this.input, this.input, 0, 0, 1, 1);\n tokenIndex++;\n }\n break;\n }\n\n case CharClass.QUOTE:\n // Delegate to tokenizeString for correctness (handles unterminated)\n this.pos = 0;\n yield this.tokenizeString();\n tokenIndex++;\n break;\n\n case CharClass.HASH:\n // Delegate to tokenizeComment for correctness\n this.pos = 0;\n yield this.tokenizeComment();\n tokenIndex++;\n break;\n\n case CharClass.DOLLAR:\n yield new LexerToken('DOLLAR', tokenTypeId('DOLLAR'), '$', '$', 0, 0, 1, 1);\n tokenIndex++;\n break;\n\n case CharClass.BACKTICK:\n // s` is 2 chars, openSpan can never be set in the 1-char fast path\n yield new LexerToken('BACKTICK_OPEN', tokenTypeId('BACKTICK_OPEN'), '`', '`', 0, 0, 1, 1);\n tokenIndex++;\n break;\n\n default: {\n // CharClass.SKIP, includes non-ASCII characters (code >= 128)\n if (isUnicodeSpace(c0)) {\n // A line holding nothing but a no-break space or a byte-order mark\n // holds no expression, exactly as a line holding one space does.\n // Yielding an IDENT for it made it an undefined variable instead.\n } else if (c0 === 0x00D7) { // × → STAR\n yield new LexerToken('STAR', tokenTypeId('STAR'), '\\u00D7', '\\u00D7', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x00F7) { // ÷ → SLASH\n yield new LexerToken('SLASH', tokenTypeId('SLASH'), '\\u00F7', '\\u00F7', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x2260) { // ≠ → NEQ\n yield new LexerToken('NEQ', tokenTypeId('NEQ'), '\\u2260', '\\u2260', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x00A3) { // £\n yield new LexerToken('POUND', tokenTypeId('POUND'), '\\u00A3', '\\u00A3', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20AC) { // €\n yield new LexerToken('EURO', tokenTypeId('EURO'), '\\u20AC', '\\u20AC', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x00A5) { // ¥\n yield new LexerToken('YEN', tokenTypeId('YEN'), '¥', '¥', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20BD) { // ₽\n yield new LexerToken('RUBLE', tokenTypeId('RUBLE'), '₽', '₽', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20A9) { // ₩\n yield new LexerToken('WON', tokenTypeId('WON'), '₩', '₩', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20B9) { // ₹ (Indian rupee) — see uom/CurrencyAliases.ts\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₹', '₹', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20BA) { // ₺ (Turkish lira)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₺', '₺', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20B4) { // ₴ (Ukrainian hryvnia)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₴', '₴', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20AA) { // ₪ (Israeli new shekel)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₪', '₪', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20AB) { // ₫ (Vietnamese dong)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₫', '₫', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20A6) { // ₦ (Nigerian naira)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₦', '₦', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20B1) { // ₱ (Philippine peso)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₱', '₱', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 >= 128) {\n // Unknown unicode, treat as IDENT for forward compatibility\n yield new LexerToken('IDENT', tokenTypeId('IDENT'), this.input, this.input, 0, 0, 1, 1);\n tokenIndex++;\n }\n break;\n }\n }\n this._inlineSolveSpans = collectedSpans;\n return;\n }\n\n const input = this.input;\n\n // ── Main tokenization loop ──────────────────────────────────────────\n while (this.pos < len) {\n const c0 = input.charCodeAt(this.pos);\n const cc = ExpressionLexer.CHAR_CLASS[c0] ?? CharClass.SKIP;\n\n // ── Escaped backtick inside inline solve ────────────────────────\n // \\` is treated as an escaped backtick, skip both characters\n // without closing the inline solve span. Without this, the\n // backtick would close the span early, producing wrong expression\n // text for expressions like s`hello \\` world`.\n if (openSpan && c0 === 92 && this.pos + 1 < len && input.charCodeAt(this.pos + 1) === 96) {\n this.pos += 2; // skip \\ and `\n continue;\n }\n\n switch (cc) {\n // ── Whitespace, skip entirely, track newlines ────────────────\n case CharClass.WHITESPACE:\n this.pos++;\n if (c0 === 10) { // \\n\n this.line++;\n this.lineStartPos = this.pos;\n } else if (c0 === 13) { // \\r\n this.line++;\n if (this.pos < len && input.charCodeAt(this.pos) === 10) {\n this.pos++; // skip \\n in \\r\\n\n }\n this.lineStartPos = this.pos;\n }\n break;\n\n // ── Digit, inline number tokenizer ───────────────────────────\n case CharClass.DIGIT:\n yield this.tokenizeNumber();\n tokenIndex++;\n break;\n\n // ── Alpha / underscore, identifier or keyword ────────────────\n case CharClass.ALPHA: {\n const token = this.tokenizeIdentifier();\n if (token.type === 'INLINE_SOLVE_START') {\n openSpan = { startTokenIndex: tokenIndex, startColumn: token.col };\n }\n yield token;\n tokenIndex++;\n break;\n }\n\n // ── Dot, could be decimal (.5) or DOT token ─────────────────\n case CharClass.DOT:\n if (this.pos + 1 < len) {\n const nextCc = ExpressionLexer.CHAR_CLASS[input.charCodeAt(this.pos + 1)] ?? CharClass.SKIP;\n if (nextCc === CharClass.DIGIT) {\n yield this.tokenizeNumber();\n } else {\n const col = this.pos - this.lineStartPos + 1;\n yield new LexerToken('DOT', tokenTypeId('DOT'), '.', '.', this.pos, 0, this.line, col);\n this.pos++;\n }\n } else {\n const col = this.pos - this.lineStartPos + 1;\n yield new LexerToken('DOT', tokenTypeId('DOT'), '.', '.', this.pos, 0, this.line, col);\n this.pos++;\n }\n tokenIndex++;\n break;\n\n // ── Operator / punctuation ────────────────────────────────────\n case CharClass.OPERATOR:\n yield this.tokenizeOperator();\n tokenIndex++;\n break;\n\n // ── String literal ────────────────────────────────────────────\n case CharClass.QUOTE:\n yield this.tokenizeString();\n tokenIndex++;\n break;\n\n // ── Comment (# or //) ─────────────────────────────────────────\n case CharClass.HASH:\n yield this.tokenizeComment();\n tokenIndex++;\n break;\n\n // ── Dollar sign $ ─────────────────────────────────────────────\n case CharClass.DOLLAR: {\n const col = this.pos - this.lineStartPos + 1;\n yield new LexerToken('DOLLAR', tokenTypeId('DOLLAR'), '$', '$', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n break;\n }\n\n // ── Backtick ` ───────────────────────────────────────────────\n case CharClass.BACKTICK: {\n const col = this.pos - this.lineStartPos + 1;\n yield new LexerToken('BACKTICK_OPEN', tokenTypeId('BACKTICK_OPEN'), '`', '`', this.pos, 0, this.line, col);\n this.pos++;\n if (openSpan) {\n const span = openSpan; // narrow for TS\n collectedSpans.push({\n start: 0, end: 0, expression: '',\n columnNumber: span.startColumn,\n startTokenIndex: span.startTokenIndex,\n endTokenIndex: tokenIndex,\n });\n openSpan = null;\n }\n tokenIndex++;\n break;\n }\n\n // ── Non-ASCII characters ─────────────────────────────────────\n default: {\n const col = this.pos - this.lineStartPos + 1;\n if (isUnicodeSpace(c0)) {\n // Separates its neighbours instead of joining them. See\n // isUnicodeSpace()'s doc comment: this branch is why a sum pasted\n // out of a web page or a spreadsheet evaluates at all.\n this.pos++;\n if (c0 === 0x2028 || c0 === 0x2029 || c0 === 0x0085) {\n // The three that are line breaks rather than spaces, tracked the\n // same way \"\\n\" is above so a later token reports its own line.\n this.line++;\n this.lineStartPos = this.pos;\n }\n } else if (c0 === 0x00D7) { // × → STAR\n yield new LexerToken('STAR', tokenTypeId('STAR'), '\\u00D7', '\\u00D7', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x00F7) { // ÷ → SLASH\n yield new LexerToken('SLASH', tokenTypeId('SLASH'), '\\u00F7', '\\u00F7', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x2260) { // ≠ → NEQ\n yield new LexerToken('NEQ', tokenTypeId('NEQ'), '\\u2260', '\\u2260', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x00A3) { // £\n yield new LexerToken('POUND', tokenTypeId('POUND'), '\\u00A3', '\\u00A3', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20AC) { // €\n yield new LexerToken('EURO', tokenTypeId('EURO'), '\\u20AC', '\\u20AC', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x00A5) { // ¥\n yield new LexerToken('YEN', tokenTypeId('YEN'), '¥', '¥', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20BD) { // ₽\n yield new LexerToken('RUBLE', tokenTypeId('RUBLE'), '₽', '₽', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20A9) { // ₩\n yield new LexerToken('WON', tokenTypeId('WON'), '₩', '₩', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20B9) { // ₹ (Indian rupee) — see uom/CurrencyAliases.ts\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₹', '₹', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20BA) { // ₺ (Turkish lira)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₺', '₺', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20B4) { // ₴ (Ukrainian hryvnia)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₴', '₴', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20AA) { // ₪ (Israeli new shekel)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₪', '₪', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20AB) { // ₫ (Vietnamese dong)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₫', '₫', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20A6) { // ₦ (Nigerian naira)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₦', '₦', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20B1) { // ₱ (Philippine peso)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₱', '₱', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 >= 128) {\n // Unknown unicode, treat as IDENT for forward compatibility.\n // tokenizeIdentifier() now includes cc >= 128 in its reading loop,\n // so this properly advances past all consecutive Unicode chars.\n yield this.tokenizeIdentifier();\n tokenIndex++;\n } else {\n // Unknown ASCII, silently skip\n this.pos++;\n }\n break;\n }\n }\n }\n this._inlineSolveSpans = collectedSpans;\n }\n\n // ── Inline number tokenizer ────────────────────────────────────────────\n /**\n * Character-by-character number parsing.\n *\n * Supports: integers, floats, scientific notation (1.5e10, 1.5e-10),\n * hex (0xFF), binary (0b1010), octal (0o17), BigInt suffix (123n),\n * thousands separators (1,234 or 1.234.567).\n *\n * Returns a LexerToken and advances `this.pos` past the number.\n */\n private tokenizeNumber(): Token {\n const input = this.input;\n const len = this.len;\n let pos = this.pos;\n const start = pos;\n const startCol = pos - this.lineStartPos + 1;\n let cc: number;\n\n // ── Hex literal: 0x / 0X ───────────────────────────────────────────\n if (input.charCodeAt(pos) === 48 && pos + 1 < len) {\n const next = input.charCodeAt(pos + 1);\n if (next === 0x78 || next === 0x58) { // 'x' or 'X'\n pos += 2;\n while (\n pos < len &&\n ((cc = input.charCodeAt(pos)),\n (cc >= 48 && cc <= 57) || (cc >= 65 && cc <= 70) || (cc >= 97 && cc <= 102))\n ) {\n pos++;\n }\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('NUMBER', tokenTypeId('NUMBER'), text, text, start, 0, this.line, startCol);\n }\n // ── Binary literal: 0b / 0B ─────────────────────────────────────\n if (next === 0x62 || next === 0x42) { // 'b' or 'B'\n pos += 2;\n while (pos < len && ((cc = input.charCodeAt(pos)), cc === 48 || cc === 49)) {\n pos++;\n }\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('NUMBER', tokenTypeId('NUMBER'), text, text, start, 0, this.line, startCol);\n }\n // ── Octal literal: 0o / 0O ───────────────────────────────────────\n if (next === 0x6F || next === 0x4F) { // 'o' or 'O'\n pos += 2;\n while (pos < len && ((cc = input.charCodeAt(pos)), cc >= 48 && cc <= 55)) {\n pos++;\n }\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('NUMBER', tokenTypeId('NUMBER'), text, text, start, 0, this.line, startCol);\n }\n }\n\n let hasIntPart = false;\n\n // ── Integer part ───────────────────────────────────────────────────\n while (pos < len && ((cc = input.charCodeAt(pos)), cc >= 48 && cc <= 57)) {\n hasIntPart = true;\n pos++;\n }\n\n // ── Thousands separators, coalesce with digits ────────────────────\n while (hasIntPart && pos < len && (input.charCodeAt(pos) === 44 || input.charCodeAt(pos) === 46)) {\n if (pos + 4 <= len) {\n const d1 = input.charCodeAt(pos + 1);\n const d2 = input.charCodeAt(pos + 2);\n const d3 = input.charCodeAt(pos + 3);\n // A genuine thousands group is always exactly 3 digits, followed\n // by either another separator, or a non-digit (end of number,\n // operator, unit, EOF), never a 4th consecutive digit. Without\n // this check, a plain decimal fraction with 4+ digits after the\n // point, e.g. \"0.0001\", had its first 3 fractional digits\n // misread as a \".\" thousands-group, silently truncating the\n // number to \"0.000\" and leaving the remaining digit(s) as a\n // separate, unrelated NUMBER token right after it (so\n // \"0.0001 BTC to USD\" tokenized as \"0.000\", \"1\", \"BTC\", \"to\",\n // \"USD\", two number literals instead of one, and evaluated to\n // a bare 0 instead of a real BTC quantity).\n const d4 = pos + 4 < len ? input.charCodeAt(pos + 4) : -1;\n const isGroupOfExactlyThree = !(d4 >= 48 && d4 <= 57);\n if (\n d1 >= 48 && d1 <= 57 &&\n d2 >= 48 && d2 <= 57 &&\n d3 >= 48 && d3 <= 57 &&\n isGroupOfExactlyThree\n ) {\n pos += 4;\n hasIntPart = true;\n continue;\n }\n }\n break;\n }\n\n // ── Decimal part (.xxx) ───────────────────────────────────────────\n let hasDecimal = false;\n if (pos < len && input.charCodeAt(pos) === 46) {\n if (pos + 1 < len) {\n const nextCc = input.charCodeAt(pos + 1);\n if (nextCc >= 48 && nextCc <= 57) {\n hasDecimal = true;\n pos++;\n while (pos < len && ((cc = input.charCodeAt(pos)), cc >= 48 && cc <= 57)) {\n pos++;\n }\n }\n }\n }\n\n // ── Exponent (e / E [+-]? \\n+) ────────────────────────────────────\n let hasExponent = false;\n if (pos < len) {\n const ec = input.charCodeAt(pos);\n if (ec === 0x65 || ec === 0x45) { // 'e' or 'E'\n if (pos + 1 < len) {\n const next = input.charCodeAt(pos + 1);\n if (\n (next >= 48 && next <= 57) ||\n next === 43 || next === 45 // + or -\n ) {\n hasExponent = true;\n pos++;\n if (next === 43 || next === 45) pos++;\n while (pos < len && ((cc = input.charCodeAt(pos)), cc >= 48 && cc <= 57)) {\n pos++;\n }\n }\n }\n }\n }\n\n // ── BigInt suffix check ────────────────────────────────────────────\n if (pos < len && input.charCodeAt(pos) === 110) { // 'n'\n if (hasIntPart && !hasDecimal && !hasExponent) {\n pos++;\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('BIGINT', tokenTypeId('BIGINT'), text, text, start, 0, this.line, startCol);\n }\n }\n\n // ── Emit NUMBER token ──────────────────────────────────────────────\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('NUMBER', tokenTypeId('NUMBER'), text, text, start, 0, this.line, startCol);\n }\n\n // ── Inline identifier / keyword tokenizer ──────────────────────────────\n /**\n * Reads [a-zA-Z_][a-zA-Z0-9_]* and resolves to:\n * - A unit type (via knownUnits, case-sensitive)\n * - A keyword type (via locale keywordMap, case-insensitive)\n * - IDENT if none of the above\n *\n * Multi-word phrases (e.g., \"to the power of\") are handled by the\n * TokenNormalizer post-lexer pass, not the lexer.\n */\n private tokenizeIdentifier(): Token {\n const input = this.input;\n const len = this.len;\n let pos = this.pos;\n const start = pos;\n const startCol = pos - this.lineStartPos + 1;\n let cc: number;\n\n // Read [a-zA-Z0-9_]* plus any Unicode (>= 128) including emoji surrogate pairs.\n // Without this, non-ASCII characters cause an infinite loop: the default case\n // calls tokenizeIdentifier(), the while loop doesn't match the Unicode char,\n // pos never advances, and the outer loop re-reads the same char forever.\n while (\n pos < len &&\n ((cc = input.charCodeAt(pos)),\n (cc >= 48 && cc <= 57) || // 0-9\n (cc >= 65 && cc <= 90) || // A-Z\n (cc >= 97 && cc <= 122) || // a-z\n cc === 95 || // _\n (cc >= 128 && !isUnicodeSpace(cc))) // Unicode (accented chars, emoji, etc.), but not Unicode whitespace\n ) {\n pos++;\n }\n\n const identText = input.slice(start, pos);\n const identLower = identText.toLowerCase();\n\n // ── Inline solve marker: s` (lowercase 's' followed by backtick) ──\n if (identLower === 's' && pos < len && input.charCodeAt(pos) === 96) {\n pos++;\n this.pos = pos;\n const fullText = input.slice(start, pos);\n return new LexerToken('INLINE_SOLVE_START', tokenTypeId('INLINE_SOLVE_START'), fullText, fullText, start, 0, this.line, startCol);\n }\n\n // ── Unit lookup (case-sensitive)\n const isKnownUnit = this.mergedUnits.has(identText);\n if (isKnownUnit) {\n if (!this.isFollowedByLParen(pos)) {\n this.pos = pos;\n return new LexerToken('UNIT', tokenTypeId('UNIT'), identText, identText, start, 0, this.line, startCol);\n }\n }\n\n // ── Keyword lookup (case-insensitive)\n const localeKwType = this.mergedKeywords.get(identLower);\n if (localeKwType) {\n this.pos = pos;\n return new LexerToken(localeKwType, tokenTypeId(localeKwType), identText, identText, start, 0, this.line, startCol);\n }\n\n // ── Fall through: emit IDENT\n // Multi-word phrases are now handled by the TokenNormalizer post-lexer pass,\n // which keeps the lexer slim and focused on single-token production.\n this.pos = pos;\n return new LexerToken('IDENT', tokenTypeId('IDENT'), identText, identText, start, 0, this.line, startCol);\n }\n\n /**\n * Peek past in-expression whitespace (space, tab) from `pos` to check\n * if the next significant character is '('.\n */\n private isFollowedByLParen(pos: number): boolean {\n const len = this.len;\n let lookPos = pos;\n while (lookPos < len) {\n const cc = this.input.charCodeAt(lookPos);\n if (cc === 40) return true;\n if (cc !== 32 && cc !== 9) break;\n lookPos++;\n }\n return false;\n }\n\n // ── Inline operator tokenizer ─────────────────────────────────────────\n /**\n * Reads an operator/punctuation token.\n * Handles two-char operators (==, !=, >=, <=, **) and the special\n * cases << (LSHIFT) and >> (RSHIFT).\n */\n private tokenizeOperator(): Token {\n const input = this.input;\n const pos = this.pos;\n const col = pos - this.lineStartPos + 1;\n const c0 = input.charCodeAt(pos);\n const len = this.len;\n\n // ── Two-character operators ────────────────────────────────────────\n if (pos + 1 < len) {\n const c1 = input.charCodeAt(pos + 1);\n\n // ==, !=, >=, <=\n const secondMap = TWO_CHAR_OPS[c0];\n if (secondMap) {\n const twoCharType = secondMap[c1];\n if (twoCharType) {\n const text = input.slice(pos, pos + 2);\n this.pos = pos + 2;\n return new LexerToken(twoCharType, tokenTypeId(twoCharType), text, text, pos, 0, this.line, col);\n }\n }\n\n // // comment\n if (c0 === 47 && c1 === 47) {\n let commentPos = pos + 2;\n while (commentPos < len) {\n const cc = input.charCodeAt(commentPos);\n if (cc === 10 || cc === 13) break;\n commentPos++;\n }\n const text = input.slice(pos, commentPos);\n this.pos = commentPos;\n return new LexerToken('COMMENT', tokenTypeId('COMMENT'), text, text, pos, 0, this.line, col);\n }\n\n // << (LSHIFT), >> (RSHIFT) and >>> (URSHIFT).\n //\n // >>> is tested before >>, or the two-char match would consume the first\n // two angle brackets and leave a stray > for the parser to choke on.\n if (c0 === 60 && c1 === 60) {\n this.pos = pos + 2;\n return new LexerToken('LSHIFT', tokenTypeId('LSHIFT'), '<<', '<<', pos, 0, this.line, col);\n }\n if (c0 === 62 && c1 === 62) {\n if (input.charCodeAt(pos + 2) === 62) {\n this.pos = pos + 3;\n return new LexerToken('URSHIFT', tokenTypeId('URSHIFT'), '>>>', '>>>', pos, 0, this.line, col);\n }\n this.pos = pos + 2;\n return new LexerToken('RSHIFT', tokenTypeId('RSHIFT'), '>>', '>>', pos, 0, this.line, col);\n }\n\n // ── Plugin-registered two-char operators ──────────────────────\n if (this.hasPluginOps) {\n const pluginInner = this.pluginOperators.get(c0);\n if (pluginInner) {\n const pluginType = pluginInner.get(c1);\n if (pluginType) {\n const text = input.slice(pos, pos + 2);\n this.pos = pos + 2;\n return new LexerToken(pluginType, tokenTypeId(pluginType), text, text, pos, 0, this.line, col);\n }\n }\n }\n }\n\n // ── Single-character operator ──────────────────────────────────────\n this.pos = pos + 1;\n const opType = OP_MAP[c0];\n const text = input.charAt(pos);\n return new LexerToken(opType || 'ERROR', tokenTypeId(opType || 'ERROR'), text, text, pos, 0, this.line, col);\n }\n\n // ── String literal tokenizer ──────────────────────────────────────────\n /**\n * Reads a double-quoted string literal. Supports backslash escapes.\n *\n * `text` is the raw source slice, quotes included, because that is what\n * `offset` + `text.length` has to span for a host to underline the literal.\n * `value` is the PAYLOAD, quotes excluded, because that is what\n * `PUSH_STRING` puts into the Value.\n *\n * The two used to be the same string. `\"abc\"` carried the five characters\n * `\"abc\"` as its value, which was invisible on screen (the formatter prints\n * the payload raw and the retained quotes landed where a display would have\n * put them back) and not invisible anywhere else: `parseFloat('\"5\"')` is NaN\n * whatever the digits say, so `\"5\" + 5` answered 5.\n *\n * An unterminated literal is an error rather than a string that happens to\n * reach the end of the line. It used to return what it had, so `\"abc` and\n * `\"abc\"` were indistinguishable by payload once the quotes were stripped,\n * which is the other half of why they are stripped here rather than later.\n */\n private tokenizeString(): Token {\n const input = this.input;\n const len = this.len;\n const start = this.pos;\n const startCol = start - this.lineStartPos + 1;\n let pos = start + 1;\n let lineBreaks = 0;\n\n while (pos < len) {\n const c0 = input.charCodeAt(pos);\n if (c0 === 34) {\n pos++;\n const text = input.slice(start, pos);\n const value = input.slice(start + 1, pos - 1);\n this.pos = pos;\n return new LexerToken('STRING', tokenTypeId('STRING'), value, text, start, lineBreaks, this.line, startCol);\n }\n if (c0 === 92 && pos + 1 < len) {\n pos += 2;\n continue;\n }\n if (c0 === 10) {\n this.line++;\n this.lineStartPos = pos + 1;\n lineBreaks++;\n }\n pos++;\n }\n\n this.pos = pos;\n throw ErrorFactory.parsing(\n \"UNTERMINATED_STRING\",\n `Unterminated string literal: ${input.slice(start, pos)}`,\n { literal: input.slice(start, pos), offset: start },\n );\n }\n\n // ── Markdown line scanner (Phase B) ───────────────────────────────────\n\n /**\n * L1 expression gating: quickly determine if a line contains any\n * characters that indicate an expression (digits, operators, currency,\n * backticks, parentheses, etc.).\n *\n * Pure prose lines (e.g., \"The quick brown fox jumps over the lazy dog\")\n * return false and can be skipped without full tokenization (L2).\n *\n * This is a fast character-by-character scan that stops at the first\n * expression indicator. Called once per line in classifyFromPositions().\n */\n static hasExpressionIndicators(input: string, start: number, end: number): boolean {\n const indicatorCodes = EXPRESSION_INDICATOR_CODES;\n for (let i = start; i < end; i++) {\n const cc = input.charCodeAt(i);\n // Check digits and operators via pre-computed Set (O(1) lookup)\n if (indicatorCodes.has(cc)) return true;\n // Unicode math/currency symbols (≥ 128, not in the 128-byte table)\n if (cc >= 128) {\n // ×, ÷, ≠, £, €, ¥, ₽, ₩, common expression symbols\n if (cc === 0x00D7 || cc === 0x00F7 || cc === 0x2260 ||\n cc === 0x00A3 || cc === 0x20AC ||\n cc === 0x00A5 || cc === 0x20BD || cc === 0x20A9) {\n return true;\n }\n }\n }\n return false;\n }\n\n /**\n * Classify a line by its character positions within this.input.\n * Reads directly from this.input using start/end boundaries.\n * DOES NOT modify this.pos, purely a read-only classifier.\n */\n /**\n * Advance past the whitespace after a list marker, and past a task-item\n * checkbox if one follows.\n *\n * The checkbox is included because it is markup by the same argument the\n * marker is, and because leaving it stopped the line dead: `- [ ] 100 + 20`\n * lexed `[ ]` as a matrix literal and reported that a matrix cannot be\n * empty, which tells a user writing a to-do list nothing they can act on.\n *\n * @param from - Offset just past the marker character.\n * @param end - Line end, never read past.\n * @returns Offset of the first evaluable character.\n */\n private skipMarkerGap(from: number, end: number): number {\n const input = this.input;\n let pos = from;\n while (pos < end && (input.charCodeAt(pos) === 32 || input.charCodeAt(pos) === 9)) pos++;\n\n // `[ ]`, `[x]`, `[X]`, or any single-character state Obsidian allows.\n if (pos + 2 < end && input.charCodeAt(pos) === 91 && input.charCodeAt(pos + 2) === 93) {\n let after = pos + 3;\n while (after < end && (input.charCodeAt(after) === 32 || input.charCodeAt(after) === 9)) after++;\n // Only when whitespace followed, so `[1,2]` opening a real matrix is\n // never mistaken for a checkbox.\n if (after > pos + 3) return after;\n }\n return pos;\n }\n\n private classifyFromPositions(start: number, end: number): LineClassification {\n const len = end;\n\n if (start >= len) {\n return { type: 'empty', skip: true, hasInlineSolve: false };\n }\n\n const input = this.input;\n let pos = start;\n\n while (pos < len) {\n const cc = input.charCodeAt(pos);\n if (cc !== 32 && cc !== 9) break;\n pos++;\n }\n\n if (pos >= len) {\n return { type: 'empty', skip: true, hasInlineSolve: false };\n }\n\n const c0 = input.charCodeAt(pos);\n let hasInline: boolean | undefined;\n\n // ── Heading: #{1,6} ' ' ──────────────────────────────────────────\n if (c0 === 35) {\n let hashCount = 1;\n while (pos + hashCount < len && input.charCodeAt(pos + hashCount) === 35) {\n hashCount++;\n }\n if (hashCount <= 6 && pos + hashCount < len && input.charCodeAt(pos + hashCount) === 32) {\n return { type: 'heading', skip: true, hasInlineSolve: false };\n }\n return { type: 'heading', skip: true, hasInlineSolve: false };\n }\n\n // ── Blockquote: > ' ' ────────────────────────────────────────────\n if (c0 === 62) {\n if (pos + 1 < len && input.charCodeAt(pos + 1) === 32) {\n return { type: 'blockquote', skip: true, hasInlineSolve: false };\n }\n }\n\n // ── Code fence: ``` or ~~~ ────────────────────────────────────────\n if (c0 === 96 && pos + 2 < len && input.charCodeAt(pos + 1) === 96 && input.charCodeAt(pos + 2) === 96) {\n return { type: 'code_fence', skip: true, hasInlineSolve: false };\n }\n if (c0 === 126 && pos + 2 < len && input.charCodeAt(pos + 1) === 126 && input.charCodeAt(pos + 2) === 126) {\n return { type: 'code_fence', skip: true, hasInlineSolve: false };\n }\n\n // ── Math fence: $$ ────────────────────────────────────────────────\n if (c0 === 36 && pos + 1 < len && input.charCodeAt(pos + 1) === 36) {\n return { type: 'math_fence', skip: true, hasInlineSolve: false };\n }\n\n // ── Horizontal rule: ---, ***, ___ (3+ same char, then only whitespace)\n if (c0 === 45 || c0 === 42 || c0 === 95) {\n let count = 1;\n while (pos + count < len && input.charCodeAt(pos + count) === c0) {\n count++;\n }\n if (count >= 3) {\n let trailPos = pos + count;\n while (trailPos < len && (input.charCodeAt(trailPos) === 32 || input.charCodeAt(trailPos) === 9)) {\n trailPos++;\n }\n if (trailPos >= len) {\n return { type: 'hr', skip: true, hasInlineSolve: false };\n }\n }\n }\n\n // ── Unordered list: - ' ', * ' ', + ' ' ──────────────────────────\n if ((c0 === 45 || c0 === 42 || c0 === 43) && pos + 1 < len && input.charCodeAt(pos + 1) === 32) {\n if (hasInline === undefined) {\n const idx = input.indexOf('s`', pos);\n hasInline = idx !== -1 && idx < len;\n }\n // The space is what makes this a marker rather than an operator, and it\n // is required by CommonMark for exactly that reason. `-100 + 20` has no\n // space and stays arithmetic; `- 100 + 20` is a bullet.\n return { type: 'list', skip: false, hasInlineSolve: hasInline, contentOffset: this.skipMarkerGap(pos + 1, len) };\n }\n\n // ── Ordered list: \\n+ '. ' ────────────────────────────────────────\n if (c0 >= 48 && c0 <= 57) {\n let digitPos = pos;\n while (digitPos < len && input.charCodeAt(digitPos) >= 48 && input.charCodeAt(digitPos) <= 57) {\n digitPos++;\n }\n if (digitPos < len && input.charCodeAt(digitPos) === 46) {\n if (digitPos + 1 < len && input.charCodeAt(digitPos + 1) === 32) {\n if (hasInline === undefined) {\n const idx = input.indexOf('s`', pos);\n hasInline = idx !== -1 && idx < len;\n }\n return { type: 'list', skip: false, hasInlineSolve: hasInline, contentOffset: this.skipMarkerGap(digitPos + 1, len) };\n }\n }\n }\n\n // ── Table / table separator: | ────────────────────────────────────\n if (c0 === 124) {\n let tPos = pos + 1;\n while (tPos < len) {\n const tc = input.charCodeAt(tPos);\n if (tc !== 45 && tc !== 58 && tc !== 124 && tc !== 32 && tc !== 9 && tc !== 13) break;\n tPos++;\n }\n if (tPos >= len) {\n return { type: 'table_separator', skip: true, hasInlineSolve: false };\n }\n }\n\n // ── Wikilink / embed: [[ or ![[ ───────────────────────────────────\n if (c0 === 91 && pos + 1 < len && input.charCodeAt(pos + 1) === 91) {\n const closePos = input.indexOf(']]', pos + 2);\n if (closePos !== -1 && closePos < len) {\n let trailPos = closePos + 2;\n while (trailPos < len && (input.charCodeAt(trailPos) === 32 || input.charCodeAt(trailPos) === 9)) {\n trailPos++;\n }\n if (trailPos >= len) {\n return { type: 'wikilink', skip: true, hasInlineSolve: false };\n }\n }\n }\n if (c0 === 33 && pos + 2 < len && input.charCodeAt(pos + 1) === 91 && input.charCodeAt(pos + 2) === 91) {\n const closePos = input.indexOf(']]', pos + 3);\n if (closePos !== -1 && closePos < len) {\n let trailPos = closePos + 2;\n while (trailPos < len && (input.charCodeAt(trailPos) === 32 || input.charCodeAt(trailPos) === 9)) {\n trailPos++;\n }\n if (trailPos >= len) {\n return { type: 'wikilink', skip: true, hasInlineSolve: false };\n }\n }\n }\n\n // ── Comment: // ──────────────────────────────────────────────────\n if (c0 === 47 && pos + 1 < len && input.charCodeAt(pos + 1) === 47) {\n return { type: 'comment', skip: true, hasInlineSolve: false };\n }\n\n // ── Default: expression or prose line ─────────────────────────────\n if (c0 === 62) {\n let trail = pos + 1;\n while (trail < len && (input.charCodeAt(trail) === 32 || input.charCodeAt(trail) === 9)) trail++;\n if (trail >= len) return { type: 'blockquote', skip: true, hasInlineSolve: false };\n }\n if (c0 === 45 || c0 === 42 || c0 === 43) {\n let trail = pos + 1;\n while (trail < len && (input.charCodeAt(trail) === 32 || input.charCodeAt(trail) === 9)) trail++;\n if (trail >= len) return { type: 'list', skip: false, hasInlineSolve: false };\n }\n if (hasInline === undefined) {\n const idx = input.indexOf('s`', pos);\n hasInline = idx !== -1 && idx < len;\n }\n\n // Return expression, all non-markdown-structure lines are tokenized.\n // (L1 prose gating removed: it incorrectly skipped keyword-only lines\n // like \"pi\", single identifiers like \"hello\", and any line without\n // digits/operators/currency. Can be re-added with keyword-awareness\n // and proper test coverage.)\n return { type: 'expression', skip: false, hasInlineSolve: hasInline };\n }\n\n /**\n * Classify a single line of markdown text.\n */\n classifyLine(lineText: string): LineClassification {\n const savedInput = this.input;\n const savedLen = this.len;\n const savedPos = this.pos;\n this.input = lineText;\n this.len = lineText.length;\n this.pos = 0;\n const result = this.classifyFromPositions(0, lineText.length);\n this.input = savedInput;\n this.len = savedLen;\n this.pos = savedPos;\n return result;\n }\n\n /**\n * Every keyword this lexer currently recognizes, locale keywords\n * (`pi`, `sqrt`, `convert`, ...) merged with any plugin-contributed ones\n * from `registerVocabulary()` (e.g. a package's custom keywords), mapped to\n * the token type they lex to. A snapshot copy, not a live reference\n * mutating the return value has no effect on the lexer.\n */\n getKeywords(): Record<string, string> {\n return Object.fromEntries(this.mergedKeywords);\n }\n\n /**\n * Find all inline solve markers in a line with precise coordinate mapping.\n */\n findInlineSolves(lineText: string): InlineSolveSpan[] {\n const results: InlineSolveSpan[] = [];\n const len = lineText.length;\n let pos = 0;\n\n while (pos < len) {\n const sPos = lineText.indexOf('s`', pos);\n if (sPos === -1) break;\n\n const exprStart = sPos + 2;\n\n let exprEnd = exprStart;\n while (exprEnd < len) {\n const cc = lineText.charCodeAt(exprEnd);\n if (cc === 92 && exprEnd + 1 < len) {\n exprEnd += 2;\n continue;\n }\n if (cc === 96) break;\n exprEnd++;\n }\n\n if (exprEnd >= len) {\n exprEnd = len;\n }\n\n const expression = lineText.slice(exprStart, exprEnd);\n const end = exprEnd < len ? exprEnd + 1 : exprEnd;\n\n results.push({\n start: sPos,\n end,\n expression,\n columnNumber: sPos + 1,\n });\n\n pos = end;\n }\n\n return results;\n }\n\n // ── Comment tokenizer ─────────────────────────────────────────────────\n /**\n * Reads a comment: # to end of line, or // to end of line.\n */\n private tokenizeComment(): Token {\n const input = this.input;\n const len = this.len;\n const start = this.pos;\n const startCol = start - this.lineStartPos + 1;\n let pos = this.pos;\n\n if (pos + 1 < len && input.charCodeAt(pos + 1) === 47) {\n pos += 2;\n } else {\n pos++;\n }\n\n while (pos < len) {\n const c0 = input.charCodeAt(pos);\n if (c0 === 10 || c0 === 13) break;\n pos++;\n }\n\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('COMMENT', tokenTypeId('COMMENT'), text, text, start, 0, this.line, startCol);\n }\n}"]}