solve-engine 1.2.0 → 2.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.
- package/README.md +12 -17
- package/dist/{BytecodeBuilder-Bp9xeTmX.d.cts → BytecodeBuilder-DGGeByAP.d.cts} +18 -0
- package/dist/{BytecodeBuilder-Bp9xeTmX.d.ts → BytecodeBuilder-DGGeByAP.d.ts} +18 -0
- package/dist/{Configuration-C9W8tJv_.d.cts → Configuration-B6W0-T67.d.cts} +17 -4
- package/dist/{Configuration-C9W8tJv_.d.ts → Configuration-B6W0-T67.d.ts} +17 -4
- package/dist/{EngineError-CNA_rHY-.d.cts → EngineError-Ce1lPkjZ.d.cts} +2 -0
- package/dist/{EngineError-CNA_rHY-.d.ts → EngineError-Ce1lPkjZ.d.ts} +2 -0
- package/dist/{PackageCompatibility-B6NX9IaN.d.cts → PackageCompatibility-Bn5jnBtA.d.cts} +2 -2
- package/dist/{PackageCompatibility-Ceg5XdAp.d.ts → PackageCompatibility-CIvq2MP5.d.ts} +2 -2
- package/dist/{PackageRegistry-DrCPQNyy.d.ts → PackageRegistry-DzeiWcv4.d.ts} +93 -172
- package/dist/{PackageRegistry-DnJYVw9G.d.cts → PackageRegistry-dpdurBVO.d.cts} +93 -172
- package/dist/{Parselet-Bhf7d0_W.d.ts → Parselet-B-zoPrTa.d.ts} +8 -5
- package/dist/{Parselet-Cv7S7KRt.d.cts → Parselet-C4Wu055_.d.cts} +8 -5
- package/dist/{ScopeManager-Bzq87GfA.d.ts → ScopeManager-C2LDOrDx.d.ts} +7 -16
- package/dist/{ScopeManager-DRDBVfan.d.cts → ScopeManager-D7uMXbhS.d.cts} +7 -16
- package/dist/{VMCheckpoints-C6c17Hbo.d.ts → VMCheckpoints-CGyFhivM.d.ts} +3 -3
- package/dist/{VMCheckpoints-dZxSMGHG.d.cts → VMCheckpoints-I9jg3jWR.d.cts} +3 -3
- package/dist/{Value-DZNQ_PU7.d.cts → Value-CCi_Eecs.d.cts} +40 -0
- package/dist/{Value-DZNQ_PU7.d.ts → Value-CCi_Eecs.d.ts} +40 -0
- package/dist/{WorkerError-Djd7GGGa.d.cts → WorkerError-B4p6PNfx.d.cts} +1 -1
- package/dist/{WorkerError-B7t7R2-m.d.ts → WorkerError-Dhj9BQ_A.d.ts} +1 -1
- package/dist/chunk-2JMFUQZH.js +2 -0
- package/dist/chunk-2JMFUQZH.js.map +1 -0
- package/dist/chunk-2LFLR3VZ.cjs +2 -0
- package/dist/chunk-2LFLR3VZ.cjs.map +1 -0
- package/dist/chunk-2RWAXT6O.js +0 -1
- package/dist/chunk-32GC2FHC.cjs +2 -0
- package/dist/chunk-32GC2FHC.cjs.map +1 -0
- package/dist/chunk-4BZIYU7S.cjs +3 -0
- package/dist/chunk-4BZIYU7S.cjs.map +1 -0
- package/dist/chunk-4E4YVQKK.js +5 -0
- package/dist/chunk-4E4YVQKK.js.map +1 -0
- package/dist/chunk-4QVBSG6B.cjs +2 -0
- package/dist/chunk-4QVBSG6B.cjs.map +1 -0
- package/dist/chunk-5FO4PDIG.js +2 -0
- package/dist/chunk-5FO4PDIG.js.map +1 -0
- package/dist/chunk-5IJD5L3O.cjs +2 -0
- package/dist/chunk-5IJD5L3O.cjs.map +1 -0
- package/dist/chunk-62LMTO4F.js +2 -0
- package/dist/chunk-62LMTO4F.js.map +1 -0
- package/dist/chunk-6G3PMEPA.js +2 -0
- package/dist/chunk-6G3PMEPA.js.map +1 -0
- package/dist/chunk-6INX773F.cjs +2 -0
- package/dist/chunk-6INX773F.cjs.map +1 -0
- package/dist/chunk-76F3LCIL.js +4 -0
- package/dist/chunk-76F3LCIL.js.map +1 -0
- package/dist/chunk-7BXPCWKM.cjs +2 -0
- package/dist/chunk-7BXPCWKM.cjs.map +1 -0
- package/dist/chunk-7GK3XEZF.js +2 -0
- package/dist/chunk-7GK3XEZF.js.map +1 -0
- package/dist/chunk-AXMQG5TS.cjs +2 -0
- package/dist/chunk-AXMQG5TS.cjs.map +1 -0
- package/dist/chunk-CIQOK7Q4.cjs +2 -0
- package/dist/chunk-CIQOK7Q4.cjs.map +1 -0
- package/dist/chunk-E2Q3PQ2G.js +3 -0
- package/dist/chunk-E2Q3PQ2G.js.map +1 -0
- package/dist/chunk-E6Z4NQAS.js +2 -0
- package/dist/chunk-E6Z4NQAS.js.map +1 -0
- package/dist/chunk-EFJCC6FJ.cjs +2 -0
- package/dist/chunk-EFJCC6FJ.cjs.map +1 -0
- package/dist/chunk-ESUN2THE.cjs +2 -0
- package/dist/chunk-ESUN2THE.cjs.map +1 -0
- package/dist/chunk-EVAOPEO4.js +2 -0
- package/dist/chunk-EVAOPEO4.js.map +1 -0
- package/dist/chunk-EVI6OHQH.cjs +2 -0
- package/dist/chunk-EVI6OHQH.cjs.map +1 -0
- package/dist/chunk-FDE5HWDI.cjs +2 -0
- package/dist/chunk-FDE5HWDI.cjs.map +1 -0
- package/dist/chunk-FWW3M36J.cjs +2 -0
- package/dist/chunk-FWW3M36J.cjs.map +1 -0
- package/dist/chunk-G7TBEQRQ.js +2 -0
- package/dist/chunk-G7TBEQRQ.js.map +1 -0
- package/dist/chunk-GK2OHWRF.cjs +5 -0
- package/dist/chunk-GK2OHWRF.cjs.map +1 -0
- package/dist/chunk-HFKDWQUL.js +2 -0
- package/dist/chunk-HFKDWQUL.js.map +1 -0
- package/dist/chunk-HLBYHXQD.cjs +3 -0
- package/dist/chunk-HLBYHXQD.cjs.map +1 -0
- package/dist/chunk-I52MYCVI.js +3 -0
- package/dist/chunk-I52MYCVI.js.map +1 -0
- package/dist/chunk-IANAMBJQ.cjs +2 -0
- package/dist/chunk-IANAMBJQ.cjs.map +1 -0
- package/dist/chunk-IJMNVBIS.js +2 -0
- package/dist/chunk-IJMNVBIS.js.map +1 -0
- package/dist/chunk-J4LZD4ZY.js +3 -0
- package/dist/chunk-J4LZD4ZY.js.map +1 -0
- package/dist/chunk-JAK3RAFA.cjs +2 -0
- package/dist/chunk-JAK3RAFA.cjs.map +1 -0
- package/dist/chunk-JFAJN3C2.cjs +2 -0
- package/dist/chunk-JFAJN3C2.cjs.map +1 -0
- package/dist/chunk-JPFCXLJV.js +2 -0
- package/dist/chunk-JPFCXLJV.js.map +1 -0
- package/dist/chunk-JUIJ6NRD.cjs +3 -0
- package/dist/chunk-JUIJ6NRD.cjs.map +1 -0
- package/dist/chunk-MIQBJGGR.js +2 -0
- package/dist/chunk-MIQBJGGR.js.map +1 -0
- package/dist/chunk-MPB7KUN5.js +3 -0
- package/dist/chunk-MPB7KUN5.js.map +1 -0
- package/dist/chunk-MSYX32PF.cjs +2 -0
- package/dist/chunk-MSYX32PF.cjs.map +1 -0
- package/dist/chunk-MVZUTETT.js +2 -0
- package/dist/chunk-MVZUTETT.js.map +1 -0
- package/dist/chunk-N7N7MPMK.cjs +2 -0
- package/dist/chunk-N7N7MPMK.cjs.map +1 -0
- package/dist/chunk-NGBBNL4K.cjs +1 -3
- package/dist/chunk-OVKDDTXO.cjs +3 -0
- package/dist/chunk-OVKDDTXO.cjs.map +1 -0
- package/dist/chunk-P6WPEUAJ.cjs +2 -0
- package/dist/chunk-P6WPEUAJ.cjs.map +1 -0
- package/dist/chunk-PS272DZJ.cjs +2 -0
- package/dist/chunk-PS272DZJ.cjs.map +1 -0
- package/dist/chunk-R2ENWQ76.js +2 -0
- package/dist/chunk-R2ENWQ76.js.map +1 -0
- package/dist/chunk-R2SZFJTT.cjs +2 -0
- package/dist/chunk-R2SZFJTT.cjs.map +1 -0
- package/dist/chunk-RAF57WYO.js +2 -0
- package/dist/chunk-RAF57WYO.js.map +1 -0
- package/dist/chunk-RSF25YSJ.js +2 -0
- package/dist/chunk-RSF25YSJ.js.map +1 -0
- package/dist/chunk-SOMGSIO4.cjs +3 -0
- package/dist/chunk-SOMGSIO4.cjs.map +1 -0
- package/dist/chunk-SYYE3QAX.cjs +2 -0
- package/dist/chunk-SYYE3QAX.cjs.map +1 -0
- package/dist/chunk-TCZSPH4A.js +2 -0
- package/dist/chunk-TCZSPH4A.js.map +1 -0
- package/dist/chunk-TLG7VZRX.cjs +2 -0
- package/dist/chunk-TLG7VZRX.cjs.map +1 -0
- package/dist/chunk-TN5E6JU6.js +2 -0
- package/dist/chunk-TN5E6JU6.js.map +1 -0
- package/dist/chunk-TRBXW6HW.js +2 -0
- package/dist/{chunk-AQNHHJMJ.cjs.map → chunk-TRBXW6HW.js.map} +1 -1
- package/dist/chunk-TTFO4YDP.cjs +2 -0
- package/dist/chunk-TTFO4YDP.cjs.map +1 -0
- package/dist/chunk-TWC7K3ZX.js +2 -0
- package/dist/chunk-TWC7K3ZX.js.map +1 -0
- package/dist/chunk-U4AEVL5Z.js +2 -0
- package/dist/chunk-U4AEVL5Z.js.map +1 -0
- package/dist/chunk-UURM7P3P.cjs +4 -0
- package/dist/chunk-UURM7P3P.cjs.map +1 -0
- package/dist/chunk-VAGS5JS7.cjs +2 -0
- package/dist/chunk-VAGS5JS7.cjs.map +1 -0
- package/dist/chunk-W2JAR233.js +2 -0
- package/dist/chunk-W2JAR233.js.map +1 -0
- package/dist/chunk-WGZ3FNHI.js +2 -0
- package/dist/chunk-WGZ3FNHI.js.map +1 -0
- package/dist/chunk-XEIDV5JP.js +2 -0
- package/dist/chunk-XEIDV5JP.js.map +1 -0
- package/dist/chunk-XNIWQHXY.js +2 -0
- package/dist/chunk-XNIWQHXY.js.map +1 -0
- package/dist/chunk-Y7O4D3BJ.cjs +2 -0
- package/dist/chunk-Y7O4D3BJ.cjs.map +1 -0
- package/dist/chunk-YAHGSBMC.js +2 -0
- package/dist/chunk-YAHGSBMC.js.map +1 -0
- package/dist/chunk-YAYBVVG2.js +3 -0
- package/dist/chunk-YAYBVVG2.js.map +1 -0
- package/dist/chunk-YJ2OPULK.js +2 -0
- package/dist/chunk-YJ2OPULK.js.map +1 -0
- package/dist/chunk-YVKHEAFT.js +2 -0
- package/dist/chunk-YVKHEAFT.js.map +1 -0
- package/dist/chunk-ZCNBT44X.cjs +2 -0
- package/dist/chunk-ZCNBT44X.cjs.map +1 -0
- package/dist/chunk-ZLRJ7TDP.cjs +2 -0
- package/dist/chunk-ZLRJ7TDP.cjs.map +1 -0
- package/dist/constants.cjs +1 -21
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -4
- package/dist/engine.cjs +1 -94
- package/dist/engine.d.cts +10 -11
- package/dist/engine.d.ts +10 -11
- package/dist/engine.js +1 -37
- package/dist/errors.cjs +1 -105
- package/dist/errors.d.cts +3 -3
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +1 -4
- package/dist/format.cjs +1 -26
- package/dist/format.d.cts +2 -2
- package/dist/format.d.ts +2 -2
- package/dist/format.js +1 -9
- package/dist/index.cjs +1 -314
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -20
- package/dist/index.d.ts +52 -20
- package/dist/index.js +1 -278
- package/dist/index.js.map +1 -1
- package/dist/language.cjs +1 -369
- package/dist/language.cjs.map +1 -1
- package/dist/language.d.cts +9 -10
- package/dist/language.d.ts +9 -10
- package/dist/language.js +1 -348
- package/dist/language.js.map +1 -1
- package/dist/lexer.cjs +1 -63
- package/dist/lexer.js +1 -10
- package/dist/normalizer.cjs +1 -39
- package/dist/normalizer.js +1 -10
- package/dist/packages.cjs +1 -132
- package/dist/packages.d.cts +8 -9
- package/dist/packages.d.ts +8 -9
- package/dist/packages.js +1 -23
- package/dist/parser.cjs +1 -54
- package/dist/parser.d.cts +8 -8
- package/dist/parser.d.ts +8 -8
- package/dist/parser.js +1 -9
- package/dist/{pipeline-D-PS9gVw.d.ts → pipeline-72QmQlGx.d.ts} +1 -1
- package/dist/{pipeline-DtSBJ8TS.d.cts → pipeline-DCQicwWX.d.cts} +1 -1
- package/dist/resolvers.cjs +1 -12
- package/dist/resolvers.d.cts +2 -2
- package/dist/resolvers.d.ts +2 -2
- package/dist/resolvers.js +1 -3
- package/dist/services.cjs +1 -20
- package/dist/services.js +1 -3
- package/dist/testing.cjs +3 -477
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +9 -10
- package/dist/testing.d.ts +9 -10
- package/dist/testing.js +3 -469
- package/dist/testing.js.map +1 -1
- package/dist/uom.cjs +1 -55
- package/dist/uom.d.cts +2 -2
- package/dist/uom.d.ts +2 -2
- package/dist/uom.js +1 -10
- package/dist/utilities.cjs +1 -36
- package/dist/utilities.js +1 -7
- package/dist/vm.cjs +1 -295
- package/dist/vm.cjs.map +1 -1
- package/dist/vm.d.cts +22 -10
- package/dist/vm.d.ts +22 -10
- package/dist/vm.js +1 -193
- package/dist/vm.js.map +1 -1
- package/dist/worker.cjs +2 -492
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +16 -17
- package/dist/worker.d.ts +16 -17
- package/dist/worker.js +2 -483
- package/dist/worker.js.map +1 -1
- package/package.json +1 -13
- package/dist/chunk-3BOK2LDK.js +0 -17
- package/dist/chunk-3BOK2LDK.js.map +0 -1
- package/dist/chunk-3VGDNEE3.js +0 -84
- package/dist/chunk-3VGDNEE3.js.map +0 -1
- package/dist/chunk-4K5W7EH2.cjs +0 -112
- package/dist/chunk-4K5W7EH2.cjs.map +0 -1
- package/dist/chunk-5EFKSKMA.js +0 -413
- package/dist/chunk-5EFKSKMA.js.map +0 -1
- package/dist/chunk-5HRB36DK.js +0 -405
- package/dist/chunk-5HRB36DK.js.map +0 -1
- package/dist/chunk-5ON7PUAZ.js +0 -12
- package/dist/chunk-5ON7PUAZ.js.map +0 -1
- package/dist/chunk-7AXJNQMF.cjs +0 -297
- package/dist/chunk-7AXJNQMF.cjs.map +0 -1
- package/dist/chunk-7JM3F4KL.js +0 -1795
- package/dist/chunk-7JM3F4KL.js.map +0 -1
- package/dist/chunk-7USV76HV.cjs +0 -341
- package/dist/chunk-7USV76HV.cjs.map +0 -1
- package/dist/chunk-A2DZ5BEJ.cjs +0 -1930
- package/dist/chunk-A2DZ5BEJ.cjs.map +0 -1
- package/dist/chunk-ADBA3XBE.cjs +0 -20
- package/dist/chunk-ADBA3XBE.cjs.map +0 -1
- package/dist/chunk-AKNGX4TZ.cjs +0 -236
- package/dist/chunk-AKNGX4TZ.cjs.map +0 -1
- package/dist/chunk-ALYRJ72W.cjs +0 -434
- package/dist/chunk-ALYRJ72W.cjs.map +0 -1
- package/dist/chunk-AMOJYLG2.cjs +0 -1692
- package/dist/chunk-AMOJYLG2.cjs.map +0 -1
- package/dist/chunk-AOH6UR2L.js +0 -825
- package/dist/chunk-AOH6UR2L.js.map +0 -1
- package/dist/chunk-AQNHHJMJ.cjs +0 -261
- package/dist/chunk-B7LXJ6LC.cjs +0 -36
- package/dist/chunk-B7LXJ6LC.cjs.map +0 -1
- package/dist/chunk-BESTLPRK.cjs +0 -6919
- package/dist/chunk-BESTLPRK.cjs.map +0 -1
- package/dist/chunk-BLI4NIQY.js +0 -98
- package/dist/chunk-BLI4NIQY.js.map +0 -1
- package/dist/chunk-BSPXMGIS.js +0 -455
- package/dist/chunk-BSPXMGIS.js.map +0 -1
- package/dist/chunk-C2OMO3WN.cjs +0 -2806
- package/dist/chunk-C2OMO3WN.cjs.map +0 -1
- package/dist/chunk-CSDQMDU2.js +0 -204
- package/dist/chunk-CSDQMDU2.js.map +0 -1
- package/dist/chunk-EJ3ILXX6.cjs +0 -223
- package/dist/chunk-EJ3ILXX6.cjs.map +0 -1
- package/dist/chunk-ENRIK36Q.cjs +0 -94
- package/dist/chunk-ENRIK36Q.cjs.map +0 -1
- package/dist/chunk-F4UB4XIL.js +0 -109
- package/dist/chunk-F4UB4XIL.js.map +0 -1
- package/dist/chunk-FD5ZZHEU.js +0 -92
- package/dist/chunk-FD5ZZHEU.js.map +0 -1
- package/dist/chunk-FE4RC37D.js +0 -2801
- package/dist/chunk-FE4RC37D.js.map +0 -1
- package/dist/chunk-FEAIOR7N.cjs +0 -91
- package/dist/chunk-FEAIOR7N.cjs.map +0 -1
- package/dist/chunk-FR7RNOPT.cjs +0 -3303
- package/dist/chunk-FR7RNOPT.cjs.map +0 -1
- package/dist/chunk-G2YPPLGX.cjs +0 -484
- package/dist/chunk-G2YPPLGX.cjs.map +0 -1
- package/dist/chunk-GCM5JHMX.js +0 -88
- package/dist/chunk-GCM5JHMX.js.map +0 -1
- package/dist/chunk-GDEU72RG.cjs +0 -829
- package/dist/chunk-GDEU72RG.cjs.map +0 -1
- package/dist/chunk-HKTQCQ4Z.cjs +0 -8383
- package/dist/chunk-HKTQCQ4Z.cjs.map +0 -1
- package/dist/chunk-HWHU642X.cjs +0 -316
- package/dist/chunk-HWHU642X.cjs.map +0 -1
- package/dist/chunk-ICEKS6YC.cjs +0 -507
- package/dist/chunk-ICEKS6YC.cjs.map +0 -1
- package/dist/chunk-IJGOFP2J.js +0 -6904
- package/dist/chunk-IJGOFP2J.js.map +0 -1
- package/dist/chunk-IQJGDZOP.js +0 -333
- package/dist/chunk-IQJGDZOP.js.map +0 -1
- package/dist/chunk-IT74O4BE.cjs +0 -456
- package/dist/chunk-IT74O4BE.cjs.map +0 -1
- package/dist/chunk-KXDQKVNX.cjs +0 -459
- package/dist/chunk-KXDQKVNX.cjs.map +0 -1
- package/dist/chunk-L2TE7PMO.cjs +0 -14
- package/dist/chunk-L2TE7PMO.cjs.map +0 -1
- package/dist/chunk-L5YHV6BQ.js +0 -499
- package/dist/chunk-L5YHV6BQ.js.map +0 -1
- package/dist/chunk-LO7HU5WB.cjs +0 -209
- package/dist/chunk-LO7HU5WB.cjs.map +0 -1
- package/dist/chunk-LSALB3IN.js +0 -292
- package/dist/chunk-LSALB3IN.js.map +0 -1
- package/dist/chunk-MI7OTUHL.cjs +0 -339
- package/dist/chunk-MI7OTUHL.cjs.map +0 -1
- package/dist/chunk-MIGXCBXT.cjs +0 -381
- package/dist/chunk-MIGXCBXT.cjs.map +0 -1
- package/dist/chunk-MVTOCRV2.js +0 -213
- package/dist/chunk-MVTOCRV2.js.map +0 -1
- package/dist/chunk-N7FNVFXW.cjs +0 -32
- package/dist/chunk-N7FNVFXW.cjs.map +0 -1
- package/dist/chunk-N7OA4WPJ.js +0 -362
- package/dist/chunk-N7OA4WPJ.js.map +0 -1
- package/dist/chunk-NAWZATKT.js +0 -478
- package/dist/chunk-NAWZATKT.js.map +0 -1
- package/dist/chunk-NLNDMWZC.js +0 -31
- package/dist/chunk-NLNDMWZC.js.map +0 -1
- package/dist/chunk-ORM7CHYZ.js +0 -1531
- package/dist/chunk-ORM7CHYZ.js.map +0 -1
- package/dist/chunk-OUHT5Z36.cjs +0 -393
- package/dist/chunk-OUHT5Z36.cjs.map +0 -1
- package/dist/chunk-PCZVMMWU.cjs +0 -74
- package/dist/chunk-PCZVMMWU.cjs.map +0 -1
- package/dist/chunk-RNKDIXDV.js +0 -336
- package/dist/chunk-RNKDIXDV.js.map +0 -1
- package/dist/chunk-SBUFNJVE.js +0 -258
- package/dist/chunk-SBUFNJVE.js.map +0 -1
- package/dist/chunk-TC6BTUSU.cjs +0 -1799
- package/dist/chunk-TC6BTUSU.cjs.map +0 -1
- package/dist/chunk-TPOK3UNI.js +0 -8355
- package/dist/chunk-TPOK3UNI.js.map +0 -1
- package/dist/chunk-UF6JG5SG.js +0 -312
- package/dist/chunk-UF6JG5SG.js.map +0 -1
- package/dist/chunk-UKQHXPGW.js +0 -30
- package/dist/chunk-UKQHXPGW.js.map +0 -1
- package/dist/chunk-V4XG5QF6.js +0 -1685
- package/dist/chunk-V4XG5QF6.js.map +0 -1
- package/dist/chunk-VEKIWQ3F.cjs +0 -39
- package/dist/chunk-VEKIWQ3F.cjs.map +0 -1
- package/dist/chunk-WMQRJTAO.js +0 -3266
- package/dist/chunk-WMQRJTAO.js.map +0 -1
- package/dist/chunk-X6K3HUOY.cjs +0 -86
- package/dist/chunk-X6K3HUOY.cjs.map +0 -1
- package/dist/chunk-XBTEO4OB.js +0 -391
- package/dist/chunk-XBTEO4OB.js.map +0 -1
- package/dist/chunk-XIYYHA65.cjs +0 -101
- package/dist/chunk-XIYYHA65.cjs.map +0 -1
- package/dist/chunk-YJHY7CMN.cjs +0 -1534
- package/dist/chunk-YJHY7CMN.cjs.map +0 -1
- package/dist/chunk-YLJ4XMA6.js +0 -33
- package/dist/chunk-YLJ4XMA6.js.map +0 -1
- package/dist/chunk-YNIWOYW6.js +0 -232
- package/dist/chunk-YNIWOYW6.js.map +0 -1
- package/dist/chunk-Z2XP767T.cjs +0 -35
- package/dist/chunk-Z2XP767T.cjs.map +0 -1
- package/dist/chunk-Z4X2RWOF.js +0 -37
- package/dist/chunk-Z4X2RWOF.js.map +0 -1
- package/dist/chunk-ZN6YYPIW.js +0 -67
- package/dist/chunk-ZN6YYPIW.js.map +0 -1
- package/dist/chunk-ZNFFTYWH.js +0 -1854
- package/dist/chunk-ZNFFTYWH.js.map +0 -1
- package/dist/variables.cjs +0 -17
- package/dist/variables.cjs.map +0 -1
- package/dist/variables.d.cts +0 -87
- package/dist/variables.d.ts +0 -87
- package/dist/variables.js +0 -4
- package/dist/variables.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunk5IJD5L3O_cjs=require('./chunk-5IJD5L3O.cjs'),chunkMSYX32PF_cjs=require('./chunk-MSYX32PF.cjs'),chunkSOMGSIO4_cjs=require('./chunk-SOMGSIO4.cjs');var o={Lowest:0,Assignment:10,LogicalOr:12,LogicalAnd:14,Conjunction:16,BitwiseOr:18,BitwiseXor:20,BitwiseAnd:22,Conditional:24,Shift:27,Sum:30,Product:40,Uncertainty:45,Exponent:50,Prefix:60,Postfix:70,Call:80};var l={[chunk5IJD5L3O_cjs.a.PLUS]:o.Sum,[chunk5IJD5L3O_cjs.a.MINUS]:o.Sum,[chunk5IJD5L3O_cjs.a.STAR]:o.Product,[chunk5IJD5L3O_cjs.a.SLASH]:o.Product,[chunk5IJD5L3O_cjs.a.MOD]:o.Product,[chunk5IJD5L3O_cjs.a.CARET]:o.Exponent,[chunk5IJD5L3O_cjs.a.BIT_OR]:o.BitwiseOr,[chunk5IJD5L3O_cjs.a.BIT_XOR]:o.BitwiseXor,[chunk5IJD5L3O_cjs.a.BIT_AND]:o.BitwiseAnd,[chunk5IJD5L3O_cjs.a.LSHIFT]:o.Shift,[chunk5IJD5L3O_cjs.a.RSHIFT]:o.Shift,[chunk5IJD5L3O_cjs.a.URSHIFT]:o.Shift,[chunk5IJD5L3O_cjs.a.PERCENT]:o.Postfix,[chunk5IJD5L3O_cjs.a.OF]:o.Product},m=null;function N(){if(m)return m;let s=0;for(let e of Object.keys(l)){let t=chunk5IJD5L3O_cjs.c(e);t>s&&(s=t);}for(let e of Object.values(chunk5IJD5L3O_cjs.a)){let t=chunk5IJD5L3O_cjs.c(e);t>s&&(s=t);}let n=new Uint8Array(s+1);for(let[e,t]of Object.entries(l)){let u=chunk5IJD5L3O_cjs.c(e);n[u]=t;}return m=n,n}function O(){m=null;}var r=255,f=class{constructor(n){this.pluginFunctionIndex=n;this.opcodes=[];this.numbers=[];this.strings=[];this.stringIndex=new Map;this._hasAsync=false;this.userFunctionBodies=[];this.anonymousBodies=[];}get pluginIndexMap(){return this.pluginFunctionIndex}emitPluginCall(n,e){let t=this.pluginFunctionIndex?.get(n);if(t===void 0)throw chunkSOMGSIO4_cjs.c.execution("UNKNOWN_PLUGIN_FUNCTION",`No registered plugin function named "${n}". A package must declare it in its pluginFunctions record and be registered before an expression using it is parsed.`,{functionName:n});this.emitOpcode(50),this.emitIndex(t),this.emitIndex(e);}emitOpcode(n){this.opcodes.push(n),n===50&&(this._hasAsync=true);}emitNumber(n){let e=this.numbers.length;if(e>r)throw chunkSOMGSIO4_cjs.c.parsing("TOO_MANY_NUMERIC_CONSTANTS",`Expression has more than ${r+1} numeric literals, exceeding the bytecode constant pool's limit.`,{limit:r+1});this.numbers.push(n),this.opcodes.push(e);}emitString(n){let e=this.stringIndex.get(n);if(e===void 0){if(e=this.strings.length,e>r)throw chunkSOMGSIO4_cjs.c.parsing("TOO_MANY_STRING_CONSTANTS",`Expression has more than ${r+1} distinct string literals, exceeding the bytecode constant pool's limit.`,{limit:r+1});this.strings.push(n),this.stringIndex.set(n,e);}this.opcodes.push(e);}emitIndex(n){this.opcodes.push(n);}emitByte(n){this.opcodes.push(n);}get currentLength(){return this.opcodes.length}emitUserFunctionBody(n,e,t){let u=this.userFunctionBodies.length;if(u>r)throw chunkSOMGSIO4_cjs.c.parsing("TOO_MANY_FUNCTION_DEFINITIONS",`More than ${r+1} function definitions on one line, exceeding the bytecode constant pool's limit.`,{limit:r+1});return this.userFunctionBodies.push({name:n,params:e,program:t}),u}emitAnonymousBody(n,e){let t=this.anonymousBodies.length;if(t>r)throw chunkSOMGSIO4_cjs.c.parsing("TOO_MANY_ANONYMOUS_BODIES",`More than ${r+1} map/reduce transform expressions on one line, exceeding the bytecode constant pool's limit.`,{limit:r+1});return this.anonymousBodies.push({params:n,program:e}),t}patchJump(n,e){this.opcodes[n]=e;}build(){return {opcodes:new Uint8Array(this.opcodes),numbers:new Float64Array(this.numbers),strings:[...this.strings],constants:new Map,hasAsync:this._hasAsync,userFunctionBodies:this.userFunctionBodies.length>0?[...this.userFunctionBodies]:void 0,anonymousBodies:this.anonymousBodies.length>0?[...this.anonymousBodies]:void 0}}buildInto(n){let e=this.opcodes.length,t=this.numbers.length,u=n&&n.opcodes.length>=e,b=n&&n.numbers.length>=t,h=u?new Uint8Array(n.opcodes.buffer,n.opcodes.byteOffset,e):new Uint8Array(e),p=b?new Float64Array(n.numbers.buffer,n.numbers.byteOffset,t):new Float64Array(t);for(let d=0;d<e;d++)h[d]=this.opcodes[d];for(let d=0;d<t;d++)p[d]=this.numbers[d];return {opcodes:h,numbers:p,strings:[...this.strings],constants:new Map,hasAsync:this._hasAsync,userFunctionBodies:this.userFunctionBodies.length>0?[...this.userFunctionBodies]:void 0,anonymousBodies:this.anonymousBodies.length>0?[...this.anonymousBodies]:void 0}}reset(){this.opcodes.length=0,this.numbers.length=0,this.strings.length=0,this.stringIndex.clear(),this._hasAsync=false,this.userFunctionBodies.length=0,this.anonymousBodies.length=0;}};var B=/^\d{1,3}(\.\d{3}){2,}$/,y=/^\d+$/;function U(s,n){let e=s.endsWith("n")?s.slice(0,-1):s;if(y.test(e))return e;let t=B.test(e)?e.split(".").join(""):A(e,n);if(!y.test(t)){let u=e.includes(".")?".":e.includes(",")?",":e;throw chunkSOMGSIO4_cjs.c.parsing("INVALID_NUMBER_LITERAL",`"${s}" is not a whole number: "${u}" separates decimals in the ${n} locale, and a whole number cannot have a fractional part.`,{raw:s,localeCode:n,separator:u})}return t}function A(s,n){let e=chunkMSYX32PF_cjs.a(n).display.thousandsSeparator;return e?s.split(e).join(""):s}exports.a=o;exports.b=N;exports.c=O;exports.d=f;exports.e=U;//# sourceMappingURL=chunk-4QVBSG6B.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-4QVBSG6B.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/parser/BindingPower.ts","../src/parser/BytecodeBuilder.ts","../src/parser/BigIntLiteral.ts"],"names":["BindingPower","BUILTIN_INFIX_BP","TokenTypes","_bpTable","buildBindingPowerTable","maxId","name","id","tokenTypeId","table","bp","invalidateBindingPowerTable","MAX_CONSTANT_POOL_INDEX","BytecodeBuilder","pluginFunctionIndex","argCount","index","ErrorFactory","op","idx","s","b","params","program","position","target","buf","opLen","numLen","reuseOpcodes","reuseNumbers","opcodes","numbers","i","CHAINED_DOT_THOUSANDS_GROUPS","DIGITS_ONLY","bigIntLiteralDigits","raw","localeCode","withoutSuffix","digits","stripLocaleGrouping","separator","text","thousandsSeparator","getLocale"],"mappings":"uKAWO,IAAMA,CAAAA,CAAe,CAC1B,MAAA,CAAQ,CAAA,CACR,WAAY,EAAA,CACZ,SAAA,CAAW,EAAA,CACX,UAAA,CAAY,EAAA,CAaZ,WAAA,CAAa,GAab,SAAA,CAAW,EAAA,CACX,WAAY,EAAA,CACZ,UAAA,CAAY,GACZ,WAAA,CAAa,EAAA,CACb,KAAA,CAAO,EAAA,CACP,GAAA,CAAK,EAAA,CACL,QAAS,EAAA,CAMT,WAAA,CAAa,GAIb,QAAA,CAAU,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,CAAYH,CAAAA,CAAc,QAAA,CAAS,GAAG,CAAA,CAAI,GAAA,CAAMA,EAAc,QAAA,CAAS,GAAG,EAAI,GAAA,CAAMA,CAAAA,CAC1F,MAAMtB,mBAAAA,CAAa,OAAA,CAClB,wBAAA,CACA,CAAA,CAAA,EAAIoB,CAAG,CAAA,0BAAA,EAA6BK,CAAS,CAAA,4BAAA,EAA+BJ,CAAU,6DACtF,CAAE,GAAA,CAAAD,EAAK,UAAA,CAAAC,CAAAA,CAAY,SAAA,CAAAI,CAAU,CAC9B,CACD,CACA,OAAOF,CACR,CASA,SAASC,CAAAA,CAAoBE,EAAcL,CAAAA,CAA4B,CACtE,IAAMM,CAAAA,CAAqBC,mBAAAA,CAAUP,CAAU,EAAE,OAAA,CAAQ,kBAAA,CACzD,OAAOM,CAAAA,CAAqBD,CAAAA,CAAK,KAAA,CAAMC,CAAkB,CAAA,CAAE,IAAA,CAAK,EAAE,CAAA,CAAID,CACvE","file":"chunk-4QVBSG6B.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 declaring an infix parselet in a\n * package's `infixParselets`. See the built-in packages for examples of\n * picking an appropriate level (e.g. arithmetic `+`/`-` use `Sum`, `*`/`/`\n * 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 // `±` (the uncertainty operator), tighter than `+ - * /` and looser than `^`,\n // so the tolerance attaches to its adjacent values: `12.3 ± 0.5 * 4` reads as\n // `(12.3 ± 0.5) * 4` (the parenthesised headline case), and `2 + 3 ± 0.5` as\n // `2 + (3 ± 0.5)`. A Tier-2 parselet (packages/uncertainty/), so this level is\n // read off the parselet rather than the Tier-1 BUILTIN_INFIX_BP table below.\n Uncertainty: 45,\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/**\n\t * The per-engine `plugin function name -> registry index` map, wired in by\n\t * the engine so {@link emitPluginCall} can resolve a name at emit time. The\n\t * same object reference is shared with every builder in an engine (the pool\n\t * and each ad-hoc nested-body builder), and the engine populates it as\n\t * packages register, so a parselet never sees the numeric index.\n\t */\n\tconstructor(private readonly pluginFunctionIndex?: ReadonlyMap<string, number>) {}\n\n\t/** The name->index map, so a nested-body builder inherits the same resolution. */\n\tget pluginIndexMap(): ReadonlyMap<string, number> | undefined {\n\t\treturn this.pluginFunctionIndex;\n\t}\n\n\t/**\n\t * Emit a plugin-function call by NAME. The engine assigns each registered\n\t * `pluginFunctions` entry an index at registration; this resolves the name to\n\t * that index and emits `CALL_PLUGIN` + index + argCount. Package authors emit\n\t * through this rather than a hand-allocated index.\n\t */\n\temitPluginCall(name: string, argCount: number): void {\n\t\tconst index = this.pluginFunctionIndex?.get(name);\n\t\tif (index === undefined) {\n\t\t\tthrow ErrorFactory.execution(\n\t\t\t\t\"UNKNOWN_PLUGIN_FUNCTION\",\n\t\t\t\t`No registered plugin function named \"${name}\". A package must declare it in its pluginFunctions record and be registered before an expression using it is parsed.`,\n\t\t\t\t{ functionName: name },\n\t\t\t);\n\t\t}\n\t\tthis.emitOpcode(OpCode.CALL_PLUGIN);\n\t\tthis.emitIndex(index);\n\t\tthis.emitIndex(argCount);\n\t}\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"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a}from'./chunk-G7TBEQRQ.js';import {c}from'./chunk-IJMNVBIS.js';import {c as c$1}from'./chunk-MPB7KUN5.js';var v={maxPasses:100,maxTokens:1e4,onFusion:()=>{}};function N(a$1,e,r){let n=r[0],o=r[r.length-1],t=new a(a$1,c(a$1),e,e,n.offset,n.lineBreaks??0,n.line,n.col);return t.sourceEnd=o.sourceEnd??o.offset+o.text.length,t}function C(a,e){let r=e[e.length-1];r&&(a.sourceEnd=r.sourceEnd??r.offset+r.text.length);}var w=["NUMBER","HEX","BIGINT","FLOAT","LSHIFT","RSHIFT","BIT_AND","BIT_OR","BIT_XOR","LPAREN","RPAREN","LBRACKET","RBRACKET","COMMA","COLON","EQUALS","THEREFORE","PIPE","AMPERSAND","AT","SEMICOLON","QUESTION","EXCLAMATION","EOF","WS","NEWLINE"],I=(()=>{let a=w.map(n=>c(n)),e=Math.max(...a)+1,r=new Uint8Array(e);for(let n of a)r[n]=1;return r})(),L=class{constructor(e={}){this.rules=[];this.sortedRulesCache=null;this.phraseTrie=new T;this.options={...v,...e};}register(e){this.rules.push(e),this.sortedRulesCache=null;}unregister(e){this.rules=this.rules.filter(r=>r.name!==e),this.sortedRulesCache=null;}clear(){this.rules=[],this.sortedRulesCache=null,this.phraseTrie=new T;}getSortedRules(){return this.sortedRulesCache===null&&(this.sortedRulesCache=[...this.rules].sort((e,r)=>r.priority-e.priority)),this.sortedRulesCache}get ruleCount(){return this.rules.length}addPhrase(e,r){this.phraseTrie.addPhrase(e,r);}getPhrases(){return this.phraseTrie.getAllPhrases()}canStartPhrase(e){return this.phraseTrie.canStart(e)}normalize(e,r){if(e.length===0)return e;let n=this.getSortedRules(),o=r??this.options.onFusion,t=this.options.maxPasses,s=this.options.maxTokens,i=e,m=true,p=0;for(;m&&p<t;){m=false,p++;let h=[],u=0;for(;u<i.length;){let E=false,y=i[u].typeId;if(y>=I.length||I[y]===0){let c=this.phraseTrie.matchAt(i,u);if(c){let l=i.slice(u,u+c.consumed);for(let d of c.replacement)h.push(d);c.consumed>1&&c.replacement.length===1&&(C(c.replacement[0],l),o({rule:c.ruleName??"phrase-trie",sourceTokens:l,fusedToken:c.replacement[0]})),u+=c.consumed,m=true;continue}}for(let c of n){let l=c.match(i,u);if(l){let d=i.slice(u,u+l.consumed);for(let g of l.replacement)h.push(g);if(l.consumed>1&&l.replacement.length===1)C(l.replacement[0],d),o({rule:c.name,sourceTokens:d,fusedToken:l.replacement[0]});else if(l.consumed>1&&l.replacement.length<l.consumed)for(let g of l.replacement)o({rule:c.name,sourceTokens:d,fusedToken:g});u+=l.consumed,m=true,E=true;break}}E||(h.push(i[u]),u++);}if(h.length>s)throw c$1.validation("NORMALIZED_TOKEN_LIMIT_EXCEEDED",`Normalized token count (${h.length}) exceeds safety limit (${s})`,{tokenCount:h.length,maxTokens:s});i=h;}return i}};var T=class{constructor(){this.startWords=new Set;this.root=new Map;}addPhrase(e,r){let n=e.toLowerCase().trim().split(/\s+/);if(n.length===0||n[0]==="")return;this.startWords.add(n[0]);let o=n[0],t;if(this.root.has(o)?t=this.root.get(o):(t={children:new Map,terminal:null},this.root.set(o,t)),n.length===1){t.terminal={tokenType:r,phrase:e,consumed:1};return}for(let s=1;s<n.length;s++){let i=n[s];t.children.has(i)||t.children.set(i,{children:new Map,terminal:null}),t=t.children.get(i);}t.terminal={tokenType:r,phrase:e,consumed:n.length};}matchAt(e,r){if(r>=e.length)return null;let n=e[r].type;if(n==="TAG"||n.startsWith("TAG_"))return null;let o=e[r].value.toLowerCase();if(!this.startWords.has(o))return null;let t=this.root.get(o);if(!t)return null;let s=null,i=1;if(t.terminal){let m=e.slice(r,r+1);s={consumed:1,replacement:[N(t.terminal.tokenType,t.terminal.phrase,m)],ruleName:t.terminal.phrase};}for(let m=r+1;m<e.length&&t?.children;m++){let p=e[m].type;if(p==="TAG"||p.startsWith("TAG_"))break;let h=e[m].value.toLowerCase();if(t=t.children.get(h),!t)break;if(i++,t.terminal){let u=e.slice(r,r+i);s={consumed:i,replacement:[N(t.terminal.tokenType,t.terminal.phrase,u)],ruleName:t.terminal.phrase};}}return s}get size(){return this.root.size}getAllPhrases(){let e={},r=(n,o)=>{n.terminal&&(e[o.join(" ")]=n.terminal.tokenType);for(let[t,s]of n.children)r(s,[...o,t]);};for(let[n,o]of this.root)r(o,[n]);return e}canStart(e){return this.startWords.has(e.toLowerCase())}};var S=new Set(["per","a","an","each","every"]),k=new Set(["to","power","increase","decrease","times","multiply","divide","by"]);function x(a$1=50,e){let r=e??(n=>k.has(n.toLowerCase()));return {name:"implicit:multiply",priority:a$1,match(n,o){if(o+1>=n.length)return null;let t=n[o],s=n[o+1],i=s.value.toLowerCase();if(r(i)||S.has(i)&&n[o+2]?.type==="UNIT"||!((t.type==="NUMBER"||t.type==="RPAREN")&&(s.type==="IDENT"||s.type==="LPAREN"||s.type==="PI"||s.type==="E")))return null;let p=new a("STAR",c("STAR"),"*","*",s.offset,0,s.line,s.col);return {consumed:1,replacement:[t,p]}}}}function W(a,e){let r=[];for(let n=0;n<e;n++){let o=a[n];if(o.type==="LBRACKET")r.push(true);else if(o.type==="LPAREN"){let t=a[n-1],s=!!t&&(t.type==="MAP"||t.type==="REDUCE"||t.type==="SUM_FN"||t.type==="PROD_FN"||t.type==="IDENT"&&(t.value.toLowerCase()==="map"||t.value.toLowerCase()==="reduce"||t.value.toLowerCase()==="sum"||t.value.toLowerCase()==="prod"));r.push(s);}else (o.type==="RBRACKET"||o.type==="RPAREN")&&r.pop();}return r.length>0&&r[r.length-1]}function U(){return [x()]}var Y={"to the power of":"CARET","power of":"CARET","increase by":"INCREASE_BY","decrease by":"DECREASE_BY","times by":"TIMES_BY","multiply by":"MULTIPLY_BY","divide by":"DIVIDE_BY","multiplied by":"MULTIPLY_BY","divided by":"DIVIDE_BY"};export{T as a,N as b,L as c,x as d,W as e,U as f,Y as g};//# sourceMappingURL=chunk-5FO4PDIG.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-5FO4PDIG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/normalizer/TokenNormalizer.ts","../src/normalizer/PhraseTrie.ts","../src/normalizer/BuiltinNormalizerRules.ts"],"names":["DEFAULT_OPTIONS","createFusedToken","type","text","sourceTokens","first","last","token","LexerToken","tokenTypeId","recordSourceSpan","fused","NON_WORD_NAMES","NON_WORD_TABLE","ids","len","table","id","TokenNormalizer","options","PhraseTrie","rule","ruleName","a","b","phrase","tokenType","word","tokens","onFusion","sorted","fusionHandler","maxPasses","maxTokens","current","changed","passCount","result","pos","matched","tid","trieMatch","rt","match","ErrorFactory","words","firstWord","node","i","startType","best","depth","contType","collect","path","child","RATE_DENOMINATOR_WORDS","PHRASE_START_WORDS","implicitMultiplyRule","priority","canStart","phraseGuard","next","nextValue","starToken","isInsideRangeContext","safeStack","t","prev","opensMapReduceCall","createBuiltinNormalizerRules","BUILTIN_PHRASES"],"mappings":"mHA2EA,IAAMA,CAAAA,CAA+C,CACnD,SAAA,CAAW,GAAA,CACX,UAAW,GAAA,CACX,QAAA,CAAU,IAAM,CAAC,CACnB,CAAA,CAwBO,SAASC,CAAAA,CACdC,IACAC,CAAAA,CACAC,CAAAA,CACO,CACP,IAAMC,CAAAA,CAAQD,CAAAA,CAAa,CAAC,CAAA,CACtBE,EAAOF,CAAAA,C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AAA,CAAa,WAAA,CAKb,eAAA,CAAiB,aAAA,CACjB,aAAc,WACf","file":"chunk-5FO4PDIG.js","sourcesContent":["//#region ─── Module Overview ───────────────────────────────────────────────────\n\n/**\n * TokenNormalizer, post-lexer token normalization pass.\n *\n * ## Purpose\n * Applies domain-specific {@link NormalizerRule | NormalizerRules} to the raw\n * token stream produced by the {@link ExpressionLexer}. This keeps the lexer\n * slim and focused on single-token production, while multi-token pattern\n * matching (phrases, implicit operators, domain merges) lives here.\n *\n * ## What rules can do\n * - **Phrase fusion**: Merge consecutive words into compound tokens\n * (e.g., `IDENT + ... + IDENT` → `CARET`)\n * - **Implicit operator insertion**: Insert missing operators between tokens\n * (e.g., `NUMBER IDENT` → `NUMBER STAR IDENT`)\n * - **Domain-specific transformations**: Coalesce item names, currency pairs,\n * percentage syntax, etc.\n *\n * ## Architecture\n * Providers register NormalizerRules alongside Parselets and OpCode handlers\n * via {@link IEnginePackage.normalizerRules}. The normalizer applies them\n * greedily left-to-right in multiple passes with safety limits.\n *\n * @module TokenNormalizer\n */\n\n//#endregion\n//#region ─── Imports ──────────────────────────────────────────────────────────\n\nimport type { Token } from \"@solve-js/lexer/Token\";\nimport { tokenTypeId } from \"@solve-js/lexer/Token\";\nimport { LexerToken } from \"@solve-js/lexer/ExpressionLexer\";\nimport type { NormalizerRule, TokenFusion } from \"./NormalizerRule\";\nimport { PhraseTrie } from \"./PhraseTrie\";\nimport { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\n\n//#endregion\n//#region ─── NormalizerOptions, Configuration ────────────────────────────────\n\n/**\n * Configuration options for the normalization pass.\n *\n * These control safety limits and diagnostic callbacks. The defaults\n * are chosen to be generous enough for any realistic expression while\n * preventing runaway token expansion from recursive rules.\n */\nexport interface NormalizerOptions {\n /**\n * Maximum number of full passes over the token stream before bailing out.\n * Prevents infinite loops from recursive rule chains.\n * @default 100\n */\n maxPasses?: number;\n\n /**\n * Maximum number of tokens allowed after normalization.\n * If exceeded, an Error is thrown rather than passing a bloated stream\n * to the parser.\n * @default 10000\n */\n maxTokens?: number;\n\n /**\n * Callback invoked for each fusion event during normalization.\n * Used by diagnostic mode to populate {@link NormalizerOutput.fusions}.\n * When `undefined`, fusions are still tracked internally but no callbacks fire.\n */\n onFusion?: (fusion: TokenFusion) => void;\n}\n\n//#endregion\n//#region ─── Default Options ──────────────────────────────────────────────────\n\n/** Sensible defaults that catch infinite loops without limiting real expressions. */\nconst DEFAULT_OPTIONS: Required<NormalizerOptions> = {\n maxPasses: 100,\n maxTokens: 10000,\n onFusion: () => {},\n};\n\n//#endregion\n//#region ─── createFusedToken, Token Factory ──────────────────────────────────\n\n/**\n * Creates a new normalized token from fused source tokens.\n *\n * The fused token inherits position information (offset, line, column)\n * from the first source token, which preserves source-map accuracy\n * for error messages and diagnostic highlighting.\n *\n * It also records where the source text ENDS, on `sourceEnd`. The start alone\n * is not enough to describe the span a fusion covers, because `text` is the\n * replacement rather than the original: `10 frames` fuses into a FRAME_COUNT\n * whose text is `10`, and a timecode fuses into a token whose text is a\n * comma-separated tuple that appears nowhere in the line. Anything painting the\n * line needs both ends, and only this function is in a position to know them.\n *\n * @param type - The new token type (e.g., \"CARET\", \"TIMES_BY\")\n * @param text - The combined text representation (e.g., \"to the power of\")\n * @param sourceTokens - The original tokens being fused (at least 2)\n * @returns A new {@link LexerToken} with the fused type and combined text\n */\nexport function createFusedToken(\n type: string,\n text: string,\n sourceTokens: Token[]\n): Token {\n const first = sourceTokens[0];\n const last = sourceTokens[sourceTokens.length - 1];\n const token = new LexerToken(\n type,\n tokenTypeId(type),\n text,\n text,\n first.offset,\n first.lineBreaks ?? 0,\n first.line,\n first.col,\n );\n // `text`, not `value`: this is where the SOURCE ended, and the two differ\n // for a string literal, whose value is the payload without its quotes.\n token.sourceEnd = last.sourceEnd ?? last.offset + last.text.length;\n return token;\n}\n\n/**\n * Record, on a token that replaced several, where its source text ended.\n *\n * Called centrally rather than left to each rule. A rule that builds its\n * replacement by hand rather than through {@link createFusedToken} is doing\n * nothing wrong, and several do: the date-literal rule needs a token whose\n * value is an epoch and whose text is the source, which that factory cannot\n * express. Stamping here means every fusion carries its span, including ones\n * written after this was.\n *\n * Reads `sourceEnd` off the last source token when it has one, so a fusion of\n * a fusion still describes the original text rather than the intermediate.\n *\n * @param fused - The single token the rule produced.\n * @param sourceTokens - The tokens it consumed.\n */\nfunction recordSourceSpan(fused: Token, sourceTokens: Token[]): void {\n const last = sourceTokens[sourceTokens.length - 1];\n if (!last) return;\n fused.sourceEnd = last.sourceEnd ?? last.offset + last.text.length;\n}\n\n//#endregion\n//#region ─── NON_WORD_TOKEN_TYPES, Type-guard skip set ────────────────────────\n\n/**\n * Token types that can NEVER start a multi-word phrase.\n *\n * Used by {@link normalize} to skip the PhraseTrie walk entirely at\n * positions where the token type makes phrase matching impossible.\n * This avoids even the O(1) {@link PhraseTrie.canStart} check.\n *\n * Types NOT in this set (IDENT, KEYWORD, FUNC, UNIT, and any custom\n * types registered by packages) still pass through to the trie for\n * a full match attempt.\n */\n// ── Non-word type ID lookup table (flat Uint8Array, true O(1) array index) ──\n//\n// Index = token typeId, value = 1 if non-word (skip trie), 0 otherwise.\n// Array indexing avoids ALL hashing: no Set.has(), no Map.get(), no string ops.\n//\n// Custom types from packages get IDs beyond the table length, so the bounds\n// check `tid < TABLE.length` safely passes them through to the trie.\n//\n// Arithmetic operators (PLUS, MINUS, STAR, SLASH, CARET, MOD, PERCENT) are\n// intentionally excluded: in keyword locales the lexer maps \"times\"→STAR,\n// \"divide\"→SLASH etc., and those tokens CAN start phrases like \"times by\".\n/**\n * Token type names that can NEVER start a multi-word phrase.\n *\n * Exported for testing only, consumers should use the type-guard behavior\n * of {@link TokenNormalizer.normalize} rather than this list directly.\n */\nexport const NON_WORD_NAMES = [\n\t\"NUMBER\", \"HEX\", \"BIGINT\", \"FLOAT\",\n\t\"LSHIFT\", \"RSHIFT\", \"BIT_AND\", \"BIT_OR\", \"BIT_XOR\",\n\t\"LPAREN\", \"RPAREN\", \"LBRACKET\", \"RBRACKET\",\n\t\"COMMA\", \"COLON\", \"EQUALS\", \"THEREFORE\", \"PIPE\", \"AMPERSAND\", \"AT\",\n\t\"SEMICOLON\", \"QUESTION\", \"EXCLAMATION\",\n\t\"EOF\", \"WS\", \"NEWLINE\",\n] as const;\n\n/**\n * Flat Uint8Array lookup table: index = token typeId, value = 1 if non-word.\n *\n * Exported for testing only, consumers should not depend on the internal\n * table layout, as the set of non-word types may change.\n */\nexport const NON_WORD_TABLE: Uint8Array = (() => {\n\t// Resolve all non-word type names to their numeric IDs\n\tconst ids = NON_WORD_NAMES.map(n => tokenTypeId(n));\n\t// Size the table to cover the largest ID + 1\n\tconst len = Math.max(...ids) + 1;\n\tconst table = new Uint8Array(len);\n\t// Mark non-word type positions\n\tfor (const id of ids) table[id] = 1;\n\treturn table;\n})();\n\n//#endregion\n//#region ─── TokenNormalizer Class ─────────────────────────────────────────────\n\n/**\n * Token normalizer: applies {@link NormalizerRule | NormalizerRules} to a token stream.\n *\n * ## Lifecycle\n * 1. **Registration**: Rules are added via {@link register} and sorted by priority\n * 2. **Normalization**: {@link normalize} applies rules greedily left-to-right\n * 3. **Cleanup**: {@link clear} or {@link unregister} removes rules\n *\n * ## Normalization algorithm\n * The normalizer uses a greedy left-to-right multi-pass algorithm:\n * - At each token position, rules are tried in priority order (highest first)\n * - When a rule matches, matched tokens are consumed and replaced\n * - Processing continues from the replacement position\n * - Multiple passes handle cascading matches (one rule's output triggers another)\n * - Safety limits ({@link NormalizerOptions.maxPasses}) prevent infinite loops\n *\n * @example\n * ```ts\n * const normalizer = new TokenNormalizer();\n * normalizer.register(phraseRule); // \"to the power of\" → CARET\n * normalizer.register(implicitMultRule); // \"2 x\" → \"2 * x\"\n * const normalized = normalizer.normalize(rawTokens);\n * ```\n */\nexport class TokenNormalizer {\n /** Registered rules, unsorted, the source of truth. */\n private rules: NormalizerRule[] = [];\n\n /**\n * Priority-sorted copy of {@link rules}, rebuilt lazily on the next\n * {@link normalize} call after a mutation. Rules are registered once at\n * engine/package-registration time and essentially never change during a\n * session, but normalize() runs on every keystroke-driven evaluation, an\n * earlier version re-sorted a fresh copy of `rules` on every single call,\n * which meant every keystroke paid for an allocation + sort of a list that\n * had usually not changed since the last one. `null` means \"stale, rebuild\n * on next use\"; {@link register}/{@link unregister}/{@link clear} all\n * invalidate it.\n */\n private sortedRulesCache: NormalizerRule[] | null = null;\n\n /**\n * Phrase trie for single-pass multi-word phrase fusion.\n * Tried at each token position BEFORE other rules, the trie walk\n * is O(depth) vs O(R × W) for separate rule matching.\n */\n private phraseTrie = new PhraseTrie();\n\n /** Merged options with defaults applied. */\n private options: Required<NormalizerOptions>;\n\n // ── Constructor ──────────────────────────────────────────────────────────\n\n /**\n * @param options - Configuration overrides for safety limits and diagnostic callbacks\n */\n constructor(options: NormalizerOptions = {}) {\n this.options = { ...DEFAULT_OPTIONS, ...options };\n }\n\n // ── Rule Management ──────────────────────────────────────────────────────\n\n /**\n * Register a normalization rule.\n *\n * Rules are sorted by priority (descending) on each {@link normalize} call.\n * Multiple rules can share the same priority, they are tried in registration\n * order when priorities are equal.\n *\n * @param rule - The rule to register\n */\n register(rule: NormalizerRule): void {\n this.rules.push(rule);\n this.sortedRulesCache = null;\n }\n\n /**\n * Unregister a normalization rule by its {@link NormalizerRule.name | name}.\n *\n * If multiple rules share the same name, all are removed. This is safe to\n * call with a name that doesn't match any rule, it simply has no effect.\n *\n * @param ruleName - The name of the rule to remove\n */\n unregister(ruleName: string): void {\n this.rules = this.rules.filter(r => r.name !== ruleName);\n this.sortedRulesCache = null;\n }\n\n /**\n * Remove all registered rules, resetting the normalizer to its initial state.\n * Also clears the phrase trie.\n */\n clear(): void {\n this.rules = [];\n this.sortedRulesCache = null;\n this.phraseTrie = new PhraseTrie();\n }\n\n /**\n * Priority-sorted view of {@link rules} (descending priority; registration\n * order preserved for ties, since {@link Array.prototype.sort} is stable).\n * Cached until the next mutation. See {@link sortedRulesCache}.\n */\n private getSortedRules(): NormalizerRule[] {\n if (this.sortedRulesCache === null) {\n this.sortedRulesCache = [...this.rules].sort((a, b) => b.priority - a.priority);\n }\n return this.sortedRulesCache;\n }\n\n /**\n * Get the number of currently registered rules (excludes phrase trie entries).\n */\n get ruleCount(): number {\n return this.rules.length;\n }\n\n // ── Phrase Registration ────────────────────────────────────────────────\n\n /**\n * Register a multi-word phrase for fusion into a single compound token.\n *\n * This is the preferred way to add phrase patterns. It inserts into the\n * internal {@link PhraseTrie}, which collapses all phrase rules into a\n * single O(depth) trie walk per position, no separate rule scanning.\n *\n * @param phrase - Multi-word phrase (e.g., \"to the power of\", \"abyssal whip\")\n * @param tokenType - Target token type after fusion (e.g., \"CARET\", \"ITEM\")\n */\n addPhrase(phrase: string, tokenType: string): void {\n this.phraseTrie.addPhrase(phrase, tokenType);\n }\n\n /**\n * Check whether a word can start any registered phrase.\n *\n * Used by {@link implicitMultiplyRule} to suppress `*` insertion\n * before phrase-starting identifiers (e.g., \"2 power of 3\" → `2 ^ 3`,\n * not `2 * power of 3`). Delegates to {@link PhraseTrie.canStart}.\n */\n /**\n * Get all registered phrases and their target token types.\n *\n * Exposes the full phrase trie structure for diagnostic rendering\n * in the playground's NormalizerTab. Returns ALL registered phrases,\n * not just the ones that matched in the last evaluation.\n */\n getPhrases(): Record<string, string> {\n return this.phraseTrie.getAllPhrases();\n }\n\n canStartPhrase(word: string): boolean {\n return this.phraseTrie.canStart(word);\n }\n\n // ── Normalization ────────────────────────────────────────────────────────\n\n /**\n * Normalize a token stream by applying all registered rules.\n *\n * ## Algorithm\n * Applies rules greedily left-to-right in multiple passes:\n * 1. Sort rules by priority (descending)\n * 2. Walk the token stream left to right\n * 3. At each position, try rules in priority order\n * 4. On match: consume matched tokens, insert replacements, restart from insert point\n * 5. On no match: pass token through unchanged\n * 6. Repeat until a full pass produces no changes, or maxPasses is reached\n *\n * ## Fusion tracking\n * When a rule consumes more tokens than it produces, the normalizer calls\n * `onFusion` with a {@link TokenFusion} record for diagnostic collection.\n * This populates {@link NormalizerOutput.fusions} in the playground pipeline view.\n *\n * ## Safety\n * If the normalized token count exceeds {@link NormalizerOptions.maxTokens},\n * an Error is thrown to prevent memory exhaustion from runaway rule expansion.\n *\n * @param tokens - Raw tokens from the lexer\n * @param onFusion - Optional fusion callback (overrides {@link NormalizerOptions.onFusion})\n * @returns Normalized tokens ready for parsing\n * @throws {Error} If the normalized token count exceeds maxTokens\n */\n normalize(tokens: Token[], onFusion?: (fusion: TokenFusion) => void): Token[] {\n // ── Early exit: nothing to normalize ──\n if (tokens.length === 0) return tokens;\n\n // ── Priority-sorted rules, cached across calls, see getSortedRules() ──\n const sorted = this.getSortedRules();\n const fusionHandler = onFusion ?? this.options.onFusion;\n const maxPasses = this.options.maxPasses;\n const maxTokens = this.options.maxTokens;\n\n let current = tokens;\n let changed = true;\n let passCount = 0;\n\n // Multi-pass loop: rules may trigger cascading matches across passes\n while (changed && passCount < maxPasses) {\n changed = false;\n passCount++;\n\n const result: Token[] = [];\n let pos = 0;\n\n // Single-pass left-to-right greedy walk\n while (pos < current.length) {\n let matched = false;\n\n // ── Fast path: phrase trie (O(depth) single walk vs O(R × W) per rule) ──\n // O(1) type-guard: skip trie entirely for tokens that can't start phrases.\n // Flat Uint8Array indexed by typeId, no hashing, no Set lookup, true O(1).\n const tid = current[pos].typeId;\n if (tid >= NON_WORD_TABLE.length || NON_WORD_TABLE[tid] === 0) {\n const trieMatch = this.phraseTrie.matchAt(current, pos);\n if (trieMatch) {\n const sourceTokens = current.slice(pos, pos + trieMatch.consumed);\n for (const rt of trieMatch.replacement) {\n result.push(rt);\n }\n if (trieMatch.consumed > 1 && trieMatch.replacement.length === 1) {\n recordSourceSpan(trieMatch.replacement[0], sourceTokens);\n fusionHandler({\n rule: trieMatch.ruleName ?? \"phrase-trie\",\n sourceTokens,\n fusedToken: trieMatch.replacement[0],\n });\n }\n pos += trieMatch.consumed;\n changed = true;\n continue; // trie matched — skip other rules at this position (no need to set matched)\n }\n }\n\n // Try every rule in priority order at this position\n for (const rule of sorted) {\n const match = rule.match(current, pos);\n if (match) {\n // Collect source tokens for fusion tracking\n const sourceTokens = current.slice(pos, pos + match.consumed);\n\n // Insert replacement tokens into result\n for (const rt of match.replacement) {\n result.push(rt);\n }\n\n // Track fusion events for diagnostics:\n // - Multiple tokens → single token: classic fusion\n // - Multiple tokens → fewer tokens: partial fusion\n if (match.consumed > 1 && match.replacement.length === 1) {\n recordSourceSpan(match.replacement[0], sourceTokens);\n fusionHandler({\n rule: rule.name,\n sourceTokens,\n fusedToken: match.replacement[0],\n });\n } else if (match.consumed > 1 && match.replacement.length < match.consumed) {\n for (const rt of match.replacement) {\n fusionHandler({\n rule: rule.name,\n sourceTokens,\n fusedToken: rt,\n });\n }\n }\n\n // Advance position past consumed tokens\n pos += match.consumed;\n changed = true;\n matched = true;\n break; // Rule matched — restart at new position with highest-priority rules\n }\n }\n\n if (!matched) {\n // No rule matched at this position, pass token through unchanged\n result.push(current[pos]);\n pos++;\n }\n }\n\n // Safety: bail if token count explodes (runaway rule expansion)\n if (result.length > maxTokens) {\n // A raw Error here would bypass ThreeTierEvaluator's DAG-preservation\n // enrichment on compile failure (it specifically checks for\n // EngineError). Same reasoning as ExpressionEngineSafety.ts's\n // complexity/length checks, which this mirrors.\n throw ErrorFactory.validation(\n \"NORMALIZED_TOKEN_LIMIT_EXCEEDED\",\n `Normalized token count (${result.length}) exceeds safety limit (${maxTokens})`,\n { tokenCount: result.length, maxTokens }\n );\n }\n\n current = result;\n }\n\n return current;\n }\n}\n\n//#endregion\n","//#region ─── Module Overview ───────────────────────────────────────────────────\n\n/**\n * PhraseTrie, optimized word-level trie for multi-word phrase fusion.\n *\n * ## Problem\n * The normalizer previously applied N separate `phraseFusionRule` instances,\n * each scanning forward from the current token position. For R phrase rules\n * and W average phrase length, this cost O(N × R × W) per pass.\n *\n * ## Solution\n * A single trie walk per position collapses all phrase rules into O(D)\n * where D ≤ longest phrase depth (typically ≤ 5 words). The trie tracks\n * the deepest terminal node reached, implementing longest-match-wins\n * without priority sorting.\n *\n * ## Optimizations\n * 1. **Set<string> quick-reject**, the `startWords` set contains the first\n * word of every registered phrase. At each position, if the token's\n * lowercase value isn't in the set, we bail in O(1) without touching\n * the trie. ~80% of tokens (numbers, operators) hit this fast path.\n * 2. **Longest-match-wins**, the `matchAt()` walk continues past terminal\n * nodes, tracking the deepest one. Shorter overlapping phrases (e.g.,\n * \"power of\") don't need lower priority, the trie naturally prefers\n * the longer match.\n * 3. **Map-based children**, `Map<string, TrieNode>` gives O(1) amortized\n * child lookup per word, faster than array scanning for sparse branches.\n *\n * ## Package integration\n * Packages add phrases via {@link TokenNormalizer.addPhrase} (public API)\n * or the {@link IEnginePackage.phrases} declarative field. Each call to\n * `addPhrase()` inserts the phrase into this trie and updates `startWords`.\n *\n * @module PhraseTrie\n */\n\n//#endregion\n//#region ─── Imports ──────────────────────────────────────────────────────────\n\nimport type { Token } from \"@solve-js/lexer/Token\";\nimport type { NormalizerMatch } from \"./NormalizerRule\";\nimport { createFusedToken } from \"./TokenNormalizer\";\n\n//#endregion\n//#region ─── TrieNode ─────────────────────────────────────────────────────────\n\n/**\n * Internal trie node.\n *\n * Each node represents a matched word in a phrase. The path from root\n * to a node spells out a partial or complete phrase.\n */\ninterface TrieNode {\n\t/** Child nodes keyed by next word (all lowercase). */\n\tchildren: Map<string, TrieNode>;\n\t/**\n\t * If this node completes a phrase, the terminal metadata.\n\t * A node can be both terminal AND have children. This handles\n\t * overlapping phrases like \"power of\" and \"to the power of\".\n\t */\n\tterminal: TrieTerminal | null;\n}\n\n/** Metadata stored at terminal nodes for deferred token creation. */\ninterface TrieTerminal {\n\t/** The target token type after fusion (e.g., \"CARET\", \"TIMES_BY\"). */\n\ttokenType: string;\n\t/** The original phrase string (e.g., \"to the power of\"). */\n\tphrase: string;\n\t/** Number of tokens consumed by this phrase. */\n\tconsumed: number;\n}\n\n//#endregion\n//#region ─── PhraseTrie ─────────────────────────────────────────────────────\n\n/**\n * Word-level trie for single-pass multi-word phrase matching.\n *\n * @example\n * ```ts\n * const trie = new PhraseTrie();\n * trie.addPhrase(\"to the power of\", \"CARET\");\n * trie.addPhrase(\"power of\", \"CARET\");\n * trie.addPhrase(\"abyssal whip\", \"ITEM\");\n *\n * // At position 0 with tokens [\"to\",\"the\",\"power\",\"of\",\"3\"]\n * const match = trie.matchAt(tokens, 0);\n * // → { consumed: 4, replacement: [CARET(\"to the power of\")] }\n * ```\n */\nexport class PhraseTrie {\n\t/**\n\t * First words that can start any registered phrase (all lowercase).\n\t * O(1) quick-reject: if `tokens[pos].value.toLowerCase()` isn't here,\n\t * no phrase can match at this position.\n\t */\n\tprivate startWords = new Set<string>();\n\n\t/**\n\t * Root maps first word → child node.\n\t * Two-level root avoids an unnecessary intermediate TrieNode.\n\t */\n\tprivate root = new Map<string, TrieNode>();\n\n\t// ── Registration ──────────────────────────────────────────────────────\n\n\t/**\n\t * Register a phrase for fusion into a single compound token.\n\t *\n\t * @param phrase - Multi-word phrase (e.g., \"to the power of\")\n\t * @param tokenType - Target token type after fusion (e.g., \"CARET\")\n\t */\n\taddPhrase(phrase: string, tokenType: string): void {\n\t\tconst words = phrase.toLowerCase().trim().split(/\\s+/);\n\t\tif (words.length === 0 || words[0] === \"\") return;\n\n\t\tthis.startWords.add(words[0]);\n\n\t\tconst firstWord = words[0];\n\t\tlet node: TrieNode;\n\n\t\tif (this.root.has(firstWord)) {\n\t\t\tnode = this.root.get(firstWord)!;\n\t\t} else {\n\t\t\tnode = { children: new Map(), terminal: null };\n\t\t\tthis.root.set(firstWord, node);\n\t\t}\n\n\t\t// Single-word phrase: terminal at root's child\n\t\tif (words.length === 1) {\n\t\t\tnode.terminal = { tokenType, phrase, consumed: 1 };\n\t\t\treturn;\n\t\t}\n\n\t\t// Walk/insert remaining words\n\t\tfor (let i = 1; i < words.length; i++) {\n\t\t\tconst word = words[i];\n\t\t\tif (!node.children.has(word)) {\n\t\t\t\tnode.children.set(word, { children: new Map(), terminal: null });\n\t\t\t}\n\t\t\tnode = node.children.get(word)!;\n\t\t}\n\n\t\tnode.terminal = { tokenType, phrase, consumed: words.length };\n\t}\n\n\t// ── Matching ──────────────────────────────────────────────────────────\n\n\t/**\n\t * Attempt to match a phrase starting at `pos` in the token stream.\n\t *\n\t * Walks the trie one token at a time, tracking the deepest terminal\n\t * node reached. Returns the longest match found, or `null` if no\n\t * phrase starts at this position.\n\t *\n\t * @param tokens - The current token stream\n\t * @param pos - Position to attempt matching from\n\t * @returns The longest {@link NormalizerMatch}, or `null` on no match\n\t */\n\tmatchAt(tokens: Token[], pos: number): NormalizerMatch | null {\n\t\t// ── Bounds guard ──\n\t\tif (pos >= tokens.length) return null;\n\n\t\t// ── A tag token never takes part in phrase fusion (#197, #213) ──\n\t\t// A `#tag` is a typed token, not a bare word, so it must not start or\n\t\t// complete a phrase. The trie matches on written value alone, so without\n\t\t// this guard a tag whose name equals a phrase or a phrase-continuation\n\t\t// word (`1200 #assuming`, `total of #column`) is fused into that grammar\n\t\t// before the category-tag rules ever run, and the tag is lost.\n\t\t//\n\t\t// The guard also covers the fused aggregate tokens the tags package emits\n\t\t// (`TAG_SUM` / `TAG_COUNT` / `TAG_AVERAGE`), whose value is the tag NAME:\n\t\t// otherwise `total of #assuming` fuses correctly to TAG_SUM(\"assuming\"),\n\t\t// then the trie re-reads that value on the next pass and turns it back\n\t\t// into the finance ASSUMING keyword (#213). The whole `TAG` / `TAG_*`\n\t\t// namespace belongs to the tags package.\n\t\tconst startType = tokens[pos].type;\n\t\tif (startType === \"TAG\" || startType.startsWith(\"TAG_\")) return null;\n\n\t\t// ── O(1) quick-reject: first word not a phrase starter ──\n\t\tconst firstWord = tokens[pos].value.toLowerCase();\n\t\tif (!this.startWords.has(firstWord)) return null;\n\n\t\t// ── Walk trie, tracking deepest terminal ──\n\t\tlet node: TrieNode | undefined = this.root.get(firstWord);\n\t\tif (!node) return null;\n\n\t\tlet best: NormalizerMatch | null = null;\n\t\tlet depth = 1;\n\n\t\t// Check single-word phrase at first node\n\t\tif (node.terminal) {\n\t\t\tconst sourceTokens = tokens.slice(pos, pos + 1);\n\t\t\tbest = {\n\t\t\t\tconsumed: 1,\n\t\t\t\treplacement: [createFusedToken(node.terminal.tokenType, node.terminal.phrase, sourceTokens)],\n\t\t\t\truleName: node.terminal.phrase,\n\t\t\t};\n\t\t}\n\n\t\t// Walk deeper for multi-word phrases\n\t\tfor (let i = pos + 1; i < tokens.length && node?.children; i++) {\n\t\t\tconst contType = tokens[i].type;\n\t\t\tif (contType === \"TAG\" || contType.startsWith(\"TAG_\")) break; // a tag token can't continue a phrase (#197, #213)\n\t\t\tconst word = tokens[i].value.toLowerCase();\n\t\t\tnode = node.children.get(word);\n\t\t\tif (!node) break; // dead end\n\t\t\tdepth++;\n\n\t\t\tif (node.terminal) {\n\t\t\t\t// Deferred fused-token creation, only on deepest match found\n\t\t\t\tconst sourceTokens = tokens.slice(pos, pos + depth);\n\t\t\t\tbest = {\n\t\t\t\t\tconsumed: depth,\n\t\t\t\t\treplacement: [\n\t\t\t\t\t\tcreateFusedToken(node.terminal.tokenType, node.terminal.phrase, sourceTokens),\n\t\t\t\t\t],\n\t\t\t\t\truleName: node.terminal.phrase,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn best;\n\t}\n\n\t// ── Introspection ─────────────────────────────────────────────────────\n\n\t/** Number of unique first words (not total phrases). */\n\tget size(): number {\n\t\treturn this.root.size;\n\t}\n\n\t/**\n\t * Return all registered phrases and their target token types.\n\t *\n\t * Used by diagnostic mode to expose the complete trie structure to the\n\t * playground's NormalizerTab for rendering ALL registered phrases\n\t * (not just the ones that matched in this evaluation).\n\t */\n\tgetAllPhrases(): Record<string, string> {\n\t\tconst result: Record<string, string> = {};\n\n\t\tconst collect = (node: TrieNode, path: string[]): void => {\n\t\t\tif (node.terminal) {\n\t\t\t\tresult[path.join(' ')] = node.terminal.tokenType;\n\t\t\t}\n\t\t\tfor (const [word, child] of node.children) {\n\t\t\t\tcollect(child, [...path, word]);\n\t\t\t}\n\t\t};\n\n\t\tfor (const [firstWord, node] of this.root) {\n\t\t\tcollect(node, [firstWord]);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/** Check if any phrase starts with this word (case-insensitive). */\n\tcanStart(word: string): boolean {\n\t\treturn this.startWords.has(word.toLowerCase());\n\t}\n}\n\n//#endregion\n","//#region ─── Module Overview ───────────────────────────────────────────────────\n\n/**\n * Built-in normalization rules for the {@link TokenNormalizer}.\n *\n * These rules handle common expression patterns that span multiple tokens.\n * Phrase fusion (e.g., \"to the power of\" → CARET) is handled by the\n * internal {@link PhraseTrie}. See {@link TokenNormalizer.addPhrase}.\n * This module only exports non-phrase rules like {@link implicitMultiplyRule}.\n *\n * @module BuiltinNormalizerRules\n */\n\n//#endregion\n//#region ─── Imports ──────────────────────────────────────────────────────────\n\nimport type { Token } from \"@solve-js/lexer/Token\";\nimport { tokenTypeId } from \"@solve-js/lexer/Token\";\nimport { LexerToken } from \"@solve-js/lexer/ExpressionLexer\";\nimport type { NormalizerRule, NormalizerMatch } from \"./NormalizerRule\";\n\n//#endregion\n//#region ─── PHRASE_START_WORDS, Implicit Multiply Guard ─────────────────────\n\n/**\n * Words that can start multi-word phrases, hardcoded fallback.\n *\n * This is ONLY used as the default fallback in {@link implicitMultiplyRule}\n * when no `canStart` predicate is provided. In the recommended pattern,\n * the {@link PhraseTrie}'s live `canStart()` set is passed instead, keeping\n * the guard in sync with package-registered phrases.\n *\n * @see {@link TokenNormalizer.canStartPhrase}\n */\n/**\n * Words that introduce a rate denominator when a unit follows.\n *\n * Kept next to the implicit-multiplication rule because that is the only\n * thing they change here; the rate itself is built in the uom package.\n */\nconst RATE_DENOMINATOR_WORDS = new Set([\"per\", \"a\", \"an\", \"each\", \"every\"]);\n\nconst PHRASE_START_WORDS = new Set([\n \"to\", \"power\", \"increase\", \"decrease\", \"times\", \"multiply\", \"divide\", \"by\",\n]);\n\n//#endregion\n//#region ─── implicitMultiplyRule, Implicit Operator Insertion ────────────────\n\n/**\n * Creates a normalization rule that inserts an implicit multiplication operator\n * between adjacent tokens where multiplication is implied.\n *\n * ## When it fires\n * Inserts a STAR token between:\n * - `NUMBER IDENT` (e.g., \"2 x\" → \"2 * x\")\n * - `RPAREN IDENT` (e.g., \"(x+1)y\" → \"(x+1) * y\")\n * - `NUMBER LPAREN` (e.g., \"2(x+1)\" → \"2 * (x+1)\")\n * - `NUMBER PI` / `NUMBER E` (e.g., \"2π\" → \"2 * π\")\n *\n * ## When it doesn't fire\n * - When the following identifier starts a multi-word phrase\n * (checked against {@link PHRASE_START_WORDS})\n * - When the following token is not an identifier or parenthesized expression\n *\n * ## Priority\n * Default priority is 50, below phrase fusion so phrases match first.\n *\n * @param priority - Rule priority (default 50)\n * @returns A {@link NormalizerRule} that inserts implicit multiply operators\n */\nexport function implicitMultiplyRule(\n\tpriority: number = 50,\n\tcanStart?: (word: string) => boolean\n): NormalizerRule {\n\tconst phraseGuard = canStart ?? ((word: string) => PHRASE_START_WORDS.has(word.toLowerCase()));\n\n\treturn {\n name: \"implicit:multiply\",\n priority,\n match(tokens: Token[], pos: number): NormalizerMatch | null {\n // ── Need at least one token after the current position ──\n if (pos + 1 >= tokens.length) return null;\n\n const t = tokens[pos];\n const next = tokens[pos + 1];\n\n // ── Guard: suppress if the next identifier starts a phrase ──\n // Uses the trie's canStart when available, falls back to hardcoded set.\n // This prevents \"2 power of 3\" from becoming \"2 * power of 3\".\n const nextValue = next.value.toLowerCase();\n if (phraseGuard(nextValue)) return null;\n\n // ── Guard: a rate denominator, not a multiplication ──\n // \"99 per week\" is ninety-nine a week, not ninety-nine times something\n // called per. The trie guard above cannot cover this, because these are\n // not registered phrases; they are recognised by the uom package's\n // bare-denominator rule, which runs after this one and then finds its\n // fused token stranded in operand position. The slash spelling never had\n // the problem, which is what made it hard to see.\n if (RATE_DENOMINATOR_WORDS.has(nextValue) && tokens[pos + 2]?.type === \"UNIT\") return null;\n\n // ── Check trigger conditions ──\n const triggers =\n (t.type === \"NUMBER\" || t.type === \"RPAREN\") &&\n (next.type === \"IDENT\" || next.type === \"LPAREN\" || next.type === \"PI\" || next.type === \"E\");\n\n if (!triggers) return null;\n\n // ── Insert a STAR token at the next token's position ──\n const starToken = new LexerToken(\n \"STAR\", tokenTypeId(\"STAR\"), \"*\", \"*\",\n next.offset, 0, next.line, next.col,\n );\n\n // consumed = 1: only the current token is replaced with [current, STAR]\n // The next token is NOT consumed, it stays for the next iteration\n return { consumed: 1, replacement: [t, starToken] };\n },\n };\n}\n\n//#endregion\n//#region ─── isInsideRangeContext, Bracket/Call-Paren Context Guard ───────────\n\n/**\n * Whether token `pos` sits inside a context where a bare `NUMBER:NUMBER`\n * sequence means a Range, not a clock-time/laptime/video-timecode literal:\n * a matrix literal/index/slice (`[1,2,3]`, `a[0:3]`), OR a `map`/`reduce`/\n * `sum`/`prod` call's own argument-list parens (`map(f, 0:3)`, these\n * accept a bare Range argument directly, per the Calca spec's own\n * example). Scans backward from `pos` over the CURRENT pass's token array,\n * tracking `[`/`(` nesting depth, the same \"positional guard via\n * backward scan\" idiom already used elsewhere in this normalizer layer\n * (e.g. `LineRefNormalizerRule`'s previous-token check), generalized to\n * depth-tracking. An `LBRACKET` is unconditionally a range-safe opener; an\n * `LPAREN` is range-safe ONLY when immediately preceded by MAP/REDUCE/\n * SUM_FN/PROD_FN, an ordinary grouping/function-call paren is NOT, so\n * `(9:00) + 5` still means a clock time, not a range.\n *\n * Needed because the clock-time/laptime/video-timecode rules each match a\n * bare `NUMBER COLON NUMBER...` shape with ZERO context-awareness, a real\n * collision discovered when adding Range support, since e.g. \"0:3\" is\n * valid input to BOTH features. These contexts have no legitimate use for\n * a clock-time/laptime/timecode literal, so the carve-out costs the time\n * features nothing.\n *\n * IMPORTANT cross-pass-timing gotcha (a real bug found and fixed here,\n * not a hypothetical): the `LPAREN`-opener check deliberately tests the\n * RAW word text (`prev.value.toLowerCase()`), not `prev.type ===\n * \"MAP\"/\"REDUCE\"/...`. The normalizer's multi-pass loop hands every rule\n * the SAME frozen `tokens` snapshot for an entire pass, a rule scanning\n * a LATER position in that pass cannot see a fusion `mapReduceCallNormalizerRule`\n * performs at an EARLIER position in that SAME pass (fusion results only\n * become visible to other rules starting the NEXT pass). Checking the\n * fused token type here would miss exactly the case that matters most\n * `map(f, 0:3)` on its very first normalization pass, silently letting\n * `0:3` fuse into a clock time before `map(`'s own fusion ever lands.\n * Testing the raw word is immune to this: it's true from the very first\n * pass, regardless of whether `mapReduceCallNormalizerRule` has run yet.\n * (`LBRACKET` above has no equivalent issue, it's a genuine lexer token\n * from the start, never itself the product of a fusion.)\n */\nexport function isInsideRangeContext(tokens: Token[], pos: number): boolean {\n const safeStack: boolean[] = [];\n for (let i = 0; i < pos; i++) {\n const t = tokens[i];\n if (t.type === \"LBRACKET\") {\n safeStack.push(true);\n } else if (t.type === \"LPAREN\") {\n const prev = tokens[i - 1];\n const opensMapReduceCall = !!prev && (\n prev.type === \"MAP\" || prev.type === \"REDUCE\" || prev.type === \"SUM_FN\" || prev.type === \"PROD_FN\" ||\n (prev.type === \"IDENT\" && (prev.value.toLowerCase() === \"map\" || prev.value.toLowerCase() === \"reduce\" || prev.value.toLowerCase() === \"sum\" || prev.value.toLowerCase() === \"prod\"))\n );\n safeStack.push(opensMapReduceCall);\n } else if (t.type === \"RBRACKET\" || t.type === \"RPAREN\") {\n safeStack.pop();\n }\n }\n return safeStack.length > 0 && safeStack[safeStack.length - 1];\n}\n\n//#endregion\n//#region ─── createBuiltinNormalizerRules, All Built-in Rules ─────────────────\n\n/**\n * Creates built-in non-phrase normalization rules.\n *\n * Returns implicit multiply insertion (priority 50).\n *\n * **Prefer** calling {@link implicitMultiplyRule} directly with a\n * `canStart` predicate wired to the normalizer's phrase trie:\n * ```ts\n * normalizer.register(implicitMultiplyRule(50, (w) => normalizer.canStartPhrase(w)));\n * ```\n * Without the predicate, this function falls back to a hardcoded\n * {@link PHRASE_START_WORDS} set that won't reflect package-registered phrases.\n *\n * @returns An array of {@link NormalizerRule} instances ready for registration\n */\nexport function createBuiltinNormalizerRules(): NormalizerRule[] {\n return [\n // ── Implicit operator insertion (priority 50) ──\n implicitMultiplyRule(),\n ];\n}\n\n/**\n * Built-in phrase → tokenType mappings.\n *\n * These are registered into the engine's {@link PhraseTrie} during\n * construction. Tests that create a standalone {@link TokenNormalizer}\n * should register these via {@link TokenNormalizer.addPhrase}.\n */\nexport const BUILTIN_PHRASES: Record<string, string> = {\n\t\"to the power of\": \"CARET\",\n\t\"power of\": \"CARET\",\n\t\"increase by\": \"INCREASE_BY\",\n\t\"decrease by\": \"DECREASE_BY\",\n\t\"times by\": \"TIMES_BY\",\n\t\"multiply by\": \"MULTIPLY_BY\",\n\t\"divide by\": \"DIVIDE_BY\",\n\t// The past-tense spellings, which is how the operation is usually written\n\t// out: \"3 multiplied by 4\". Same tokens, so no new parselets. Both this\n\t// branch and the parity branch added \"multiplied by\" independently; the\n\t// merge kept both copies and the locale table rejected the duplicate key.\n\t\"multiplied by\": \"MULTIPLY_BY\",\n\t\"divided by\": \"DIVIDE_BY\",\n};\n\n//#endregion\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var R={NUMBER:"NUMBER",BIGINT:"BIGINT",STRING:"STRING",IDENT:"IDENT",PLUS:"PLUS",MINUS:"MINUS",PLUS_EQUALS:"PLUS_EQUALS",MINUS_EQUALS:"MINUS_EQUALS",STAR:"STAR",SLASH:"SLASH",PLUS_MINUS:"PLUS_MINUS",CARET:"CARET",PERCENT:"PERCENT",LSHIFT:"LSHIFT",RSHIFT:"RSHIFT",URSHIFT:"URSHIFT",LPAREN:"LPAREN",RPAREN:"RPAREN",LBRACKET:"LBRACKET",RBRACKET:"RBRACKET",LBRACE:"LBRACE",RBRACE:"RBRACE",COMMA:"COMMA",DOT:"DOT",COLON:"COLON",SEMICOLON:"SEMICOLON",EQUALS:"EQUALS",DOLLAR:"DOLLAR",POUND:"POUND",EURO:"EURO",YEN:"YEN",RUBLE:"RUBLE",WON:"WON",QUESTION:"QUESTION",BANG:"BANG",BIT_AND:"BIT_AND",BIT_OR:"BIT_OR",BIT_NOT:"BIT_NOT",KEYWORD:"KEYWORD",EOF:"EOF",ERROR:"ERROR",WS:"WS",NEWLINE:"NEWLINE",DATETIME_LITERAL:"DATETIME_LITERAL",DURATION:"DURATION",UNIT:"UNIT",ROLL:"ROLL",PI:"PI",E:"E",MOD:"MOD",AND_CONJ:"AND_CONJ",OF:"OF",INCREASE_BY:"INCREASE_BY",DECREASE_BY:"DECREASE_BY",OF_WHAT_IS:"OF_WHAT_IS",ON_WHAT_IS:"ON_WHAT_IS",OFF_WHAT_IS:"OFF_WHAT_IS",NOW:"NOW",TODAY:"TODAY",TOMORROW:"TOMORROW",YESTERDAY:"YESTERDAY",DURATION_DAY:"DURATION_DAY",DURATION_WEEK:"DURATION_WEEK",DURATION_MONTH:"DURATION_MONTH",DURATION_YEAR:"DURATION_YEAR",DURATION_HOUR:"DURATION_HOUR",DURATION_MINUTE:"DURATION_MINUTE",DURATION_SECOND:"DURATION_SECOND",FUNC:"FUNC",CONVERT:"CONVERT",TO:"TO",BEST:"BEST",NEXT:"NEXT",LAST:"LAST",UNTIL:"UNTIL",SINCE:"SINCE",BETWEEN:"BETWEEN",SPLIT:"SPLIT",SPLIT_WAYS:"SPLIT_WAYS",WAYS:"WAYS",PEOPLE:"PEOPLE",FROM:"FROM",INCREASE:"INCREASE",DECREASE:"DECREASE",UNICODE_MATH:"UNICODE_MATH",TIMES_BY:"TIMES_BY",MULTIPLY_BY:"MULTIPLY_BY",DIVIDE_BY:"DIVIDE_BY",NEQ:"NEQ",IN:"IN",BIT_XOR:"BIT_XOR",EQUALITY:"EQUALITY",GTE:"GTE",LTE:"LTE",LT:"LT",GT:"GT",LOGICAL_AND:"LOGICAL_AND",LOGICAL_OR:"LOGICAL_OR",OR:"OR",TRUE:"TRUE",FALSE:"FALSE",IF:"IF",THEN:"THEN",ELSE:"ELSE",AS:"AS",CONVERTER_NAME:"CONVERTER_NAME",ROUNDED:"ROUNDED",TO_NEAREST:"TO_NEAREST",DECIMAL_PLACES:"DECIMAL_PLACES",AVERAGE_OF:"AVERAGE_OF",MEDIAN_OF:"MEDIAN_OF",TOTAL_OF:"TOTAL_OF",COUNT_OF:"COUNT_OF",LARGER_OF:"LARGER_OF",SMALLER_OF:"SMALLER_OF",HALF_OF:"HALF_OF",MIDPOINT_BETWEEN:"MIDPOINT_BETWEEN",REMAINDER_OF:"REMAINDER_OF",NTH_ROOT:"NTH_ROOT",LOG_PHRASE:"LOG_PHRASE",LOG_BASE:"LOG_BASE",GCD_OF:"GCD_OF",LCM_OF:"LCM_OF",SQUARE_ROOT_OF:"SQUARE_ROOT_OF",CUBE_ROOT_OF:"CUBE_ROOT_OF",RANDOM_NUMBER:"RANDOM_NUMBER",IS_TO:"IS_TO",IS:"IS",PCT_ON:"PCT_ON",PCT_OFF:"PCT_OFF",PCT_UP:"PCT_UP",PCT_DOWN:"PCT_DOWN",OF_WHAT:"OF_WHAT",OFF_WHAT:"OFF_WHAT",ON_WHAT:"ON_WHAT",CLAMP:"CLAMP",MAP:"MAP",REDUCE:"REDUCE",SUM_FN:"SUM_FN",PROD_FN:"PROD_FN",EXPAND_FN:"EXPAND_FN",FACTOR_FN:"FACTOR_FN",SOLVE_FN:"SOLVE_FN",DER_FN:"DER_FN",INTEGRAL_FN:"INTEGRAL_FN",TAYLOR_FN:"TAYLOR_FN",JACOBIAN_FN:"JACOBIAN_FN",CONJ_FN:"CONJ_FN",RE_FN:"RE_FN",IM_FN:"IM_FN",CANCEL_FN:"CANCEL_FN",APART_FN:"APART_FN",IMAGINARY:"IMAGINARY",THEREFORE:"THEREFORE",TIME_IN:"TIME_IN",DATE_IN:"DATE_IN",TIME_DIFFERENCE_BETWEEN:"TIME_DIFFERENCE_BETWEEN",CITY_NAME:"CITY_NAME",BACKTICK_OPEN:"BACKTICK_OPEN",INLINE_SOLVE_START:"INLINE_SOLVE_START",COMMENT:"COMMENT",HEX_COLOUR:"HEX_COLOUR",TAG:"TAG",COLOUR_CALL:"COLOUR_CALL",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",FLOAT:"FLOAT",GLOBAL:"GLOBAL",OVER:"OVER",RATE_AT:"RATE_AT",AFTER:"AFTER",PRESENT_VALUE_OF:"PRESENT_VALUE_OF",ANNUAL_RETURN_ON:"ANNUAL_RETURN_ON",FOR_DURATION:"FOR_DURATION",COMPOUNDING:"COMPOUNDING",INVESTED:"INVESTED",RETURNED:"RETURNED",COMPOUND_INTEREST_ON:"COMPOUND_INTEREST_ON",INTEREST_ON:"INTEREST_ON",DAILY_REPAYMENT_ON:"DAILY_REPAYMENT_ON",MONTHLY_REPAYMENT_ON:"MONTHLY_REPAYMENT_ON",ANNUAL_REPAYMENT_ON:"ANNUAL_REPAYMENT_ON",TOTAL_REPAYMENT_ON:"TOTAL_REPAYMENT_ON",DAILY_LOAN_INTEREST_ON:"DAILY_LOAN_INTEREST_ON",MONTHLY_LOAN_INTEREST_ON:"MONTHLY_LOAN_INTEREST_ON",ANNUAL_LOAN_INTEREST_ON:"ANNUAL_LOAN_INTEREST_ON",TOTAL_LOAN_INTEREST_ON:"TOTAL_LOAN_INTEREST_ON",TAX_ON:"TAX_ON",TAX_OFF:"TAX_OFF",TAX_IN_PHRASE:"TAX_IN_PHRASE",WHAT_IS:"WHAT_IS",WHAT_WAS:"WHAT_WAS",VALUE_OF:"VALUE_OF",WORTH_IN:"WORTH_IN",SAVINGS_HOW_LONG:"SAVINGS_HOW_LONG",SAVINGS_HOW_MUCH:"SAVINGS_HOW_MUCH",ASSUMING:"ASSUMING",IN_YEAR_DOLLARS:"IN_YEAR_DOLLARS",INGREDIENT_NAME:"INGREDIENT_NAME",WORKDAYS_IN:"WORKDAYS_IN",WEEKDAY_ON:"WEEKDAY_ON",CURRENT_TIMESTAMP:"CURRENT_TIMESTAMP",TO_DATE:"TO_DATE",TO_TIMESTAMP:"TO_TIMESTAMP",WEEKDAY_IN:"WEEKDAY_IN",MONTH_ON:"MONTH_ON",MONTH_IN:"MONTH_IN",WEEK_ON:"WEEK_ON",DAYS_IN_PERIOD:"DAYS_IN_PERIOD",IN_TWO_UNITS:"IN_TWO_UNITS",PER_UNIT:"PER_UNIT",AT_RATE:"AT_RATE",WEEK_IN:"WEEK_IN",BETWEEN_UNIT:"BETWEEN_UNIT",WORKDAYS_AFTER:"WORKDAYS_AFTER",WORKDAYS_BEFORE:"WORKDAYS_BEFORE",WORKDAYS_BETWEEN:"WORKDAYS_BETWEEN",IS_WEEKEND:"IS_WEEKEND",IS_WORKDAY:"IS_WORKDAY",VIDEO_TIMECODE:"VIDEO_TIMECODE",FRAME_COUNT:"FRAME_COUNT",AT:"AT",CURRENCY_SYMBOL:"CURRENCY_SYMBOL",PREV:"PREV",LINE_REF:"LINE_REF",SUM_RANGE_CALL:"SUM_RANGE_CALL",AVERAGE_RANGE_CALL:"AVERAGE_RANGE_CALL",TOTAL_ABOVE:"TOTAL_ABOVE",SUM_ABOVE:"SUM_ABOVE",AVERAGE_ABOVE:"AVERAGE_ABOVE",GOAL_SEEK:"GOAL_SEEK"},I=0,T=new Map,O=new Map;function A(E){let _=T.get(E);if(_!==void 0)return _;let N=I++;return T.set(E,N),O.set(N,E),N}function L(E){return A(E)}function S(E){return O.get(E)??`UNKNOWN_${E}`}function D(){for(let E of Object.values(R))A(E);}exports.a=R;exports.b=A;exports.c=L;exports.d=S;exports.e=D;//# sourceMappingURL=chunk-5IJD5L3O.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-5IJD5L3O.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lexer/Token.ts"],"names":["TokenTypes","_nextTokenTypeId","_tokenTypeNameToId","_tokenTypeIdToName","registerTokenType","name","existing","id","tokenTypeId","tokenTypeName","registerAllTokenTypes"],"mappings":"aA0CO,IAAMA,CAAAA,CAAa,CACxB,MAAA,CAAQ,QAAA,CACR,MAAA,CAAQ,QAAA,CACR,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esContent":["/**\n * Lexer token produced by {@link ExpressionLexer} and consumed by parsers.\n *\n * Each token carries:\n * - `type`: string name (e.g. \"NUMBER\", \"PLUS\") for diagnostics and parselet lookup\n * - `typeId`: integer ID for O(1) comparison in parser hot paths\n * - `value`/`text`: the token's semantic value and raw source text\n * - `offset`/`line`/`col`: source position for error messages and highlighting\n */\nexport interface Token {\n\t/** String token type (e.g., \"NUMBER\", \"PLUS\", \"IDENT\"). Used by ParseletRegistry string-keyed maps and error messages. */\n\ttype: string;\n\t/** Integer token type ID for fast comparison in Parser hot path.\n\t * Populated by the Lexer via registerTokenType(). Use tokenTypeId(type) to get a type's ID. */\n\ttypeId: number;\n\tvalue: string;\n\ttext: string;\n\toffset: number;\n\tlineBreaks: number;\n\tline: number;\n\tcol: number;\n\t/**\n\t * End offset of the source text this token was fused from, exclusive.\n\t *\n\t * Only set on tokens the normalizer built by fusing several lexer tokens\n\t * into one, and only there because those are the tokens whose `value` no\n\t * longer describes the text they came from. `10 frames` fuses into a\n\t * FRAME_COUNT whose value is `10`, so `offset + value.length` would cover\n\t * two characters of a nine-character phrase.\n\t *\n\t * Evaluation never reads this. It exists so that a consumer painting a line\n\t * (see `LanguageService.getSemanticTokens`) can highlight a fused phrase as\n\t * the one thing the parser will see rather than as its parts.\n\t */\n\tsourceEnd?: number;\n}\n\n/**\n * Canonical token type name constants.\n * All token types used by the lexer, parser, and VM are defined here.\n * Custom/plugin token types should be registered via {@link registerTokenType}.\n */\nexport const TokenTypes = {\n NUMBER: \"NUMBER\",\n BIGINT: \"BIGINT\",\n STRING: \"STRING\",\n IDENT: \"IDENT\",\n PLUS: \"PLUS\",\n MINUS: \"MINUS\",\n // Compound assignment for running totals: `total += 100`, `total -= 40`.\n // Handled by the engine's compound-assignment interception, not a parselet.\n PLUS_EQUALS: \"PLUS_EQUALS\",\n MINUS_EQUALS: \"MINUS_EQUALS\",\n STAR: \"STAR\",\n SLASH: \"SLASH\",\n // The uncertainty operator, `±` (U+00B1) or the ASCII `+/-`. The symbol is\n // lexed directly (ExpressionLexer.ts, alongside `×`/`÷`), and the ASCII\n // spelling is fused from PLUS SLASH MINUS by a normalizer rule (see\n // packages/uncertainty/). Registered here rather than left to be lazily\n // minted so its id is stable, the same reasoning as the algebra verbs below.\n PLUS_MINUS: \"PLUS_MINUS\",\n CARET: \"CARET\",\n PERCENT: \"PERCENT\",\n LSHIFT: \"LSHIFT\",\n RSHIFT: \"RSHIFT\",\n URSHIFT: \"URSHIFT\",\n LPAREN: \"LPAREN\",\n RPAREN: \"RPAREN\",\n LBRACKET: \"LBRACKET\",\n RBRACKET: \"RBRACKET\",\n LBRACE: \"LBRACE\",\n RBRACE: \"RBRACE\",\n COMMA: \"COMMA\",\n DOT: \"DOT\",\n COLON: \"COLON\",\n SEMICOLON: \"SEMICOLON\",\n EQUALS: \"EQUALS\",\n DOLLAR: \"DOLLAR\",\n POUND: \"POUND\",\n EURO: \"EURO\",\n YEN: \"YEN\",\n RUBLE: \"RUBLE\",\n WON: \"WON\",\n QUESTION: \"QUESTION\",\n BANG: \"BANG\",\n BIT_AND: \"BIT_AND\",\n BIT_OR: \"BIT_OR\",\n BIT_NOT: \"BIT_NOT\",\n KEYWORD: \"KEYWORD\",\n EOF: \"EOF\",\n ERROR: \"ERROR\",\n WS: \"WS\",\n NEWLINE: \"NEWLINE\",\n DATETIME_LITERAL: \"DATETIME_LITERAL\",\n DURATION: \"DURATION\",\n UNIT: \"UNIT\",\n ROLL: \"ROLL\",\n PI: \"PI\",\n E: \"E\",\n MOD: \"MOD\",\n // The English word \"and\", which is NOT the same thing as \"+\" even though it\n // adds. It used to map straight onto PLUS in the locale keyword map, which\n // made \"3 and 4\" evaluate to 7 correctly and then quietly broke every phrase\n // that uses \"and\" as a list separator: \"average of 36, 42, 19 and 81\" parsed\n // its last argument as \"19 + 81\" and returned 178/3 rather than 178/4.\n //\n // Giving it its own type lets a parselet tell the two apart. It is still an\n // infix addition (see ArithmeticPackage.ts) so \"3 and 4\" is unchanged, but it\n // binds at BindingPower.Conjunction, looser than both Sum and Conditional, so\n // a phrase parselet can parse an argument at Conjunction and get \"1 + 2\"\n // whole while still stopping at \"and\", and so \"5 > 3 and 2 > 1\" reads as the\n // conjunction of two comparisons rather than \"5 > (3 and 2) > 1\".\n AND_CONJ: \"AND_CONJ\",\n OF: \"OF\",\n INCREASE_BY: \"INCREASE_BY\",\n DECREASE_BY: \"DECREASE_BY\",\n // Percentage solve-for-unknown (packages/percentage/), \"N% of what is\n // X\" solves N% * base = X for base. Fused as a full 3-word phrase (see\n // PercentagePackage.ts's `phrases` field) rather than a bare \"what\"\n // keyword, \"what\" is common enough as a variable name to be worth the\n // same phrase-fusion treatment this codebase gives \"total\"/\"average\"/etc.\n OF_WHAT_IS: \"OF_WHAT_IS\",\n // Sibling solve-for-unknown forms accounting for a +/-1 offset, \"N% on\n // what is X\" (increase) / \"N% off what is X\" (decrease). Same\n // phrase-fusion reasoning as OF_WHAT_IS above.\n ON_WHAT_IS: \"ON_WHAT_IS\",\n OFF_WHAT_IS: \"OFF_WHAT_IS\",\n NOW: \"NOW\",\n TODAY: \"TODAY\",\n TOMORROW: \"TOMORROW\",\n YESTERDAY: \"YESTERDAY\",\n DURATION_DAY: \"DURATION_DAY\",\n DURATION_WEEK: \"DURATION_WEEK\",\n DURATION_MONTH: \"DURATION_MONTH\",\n DURATION_YEAR: \"DURATION_YEAR\",\n DURATION_HOUR: \"DURATION_HOUR\",\n DURATION_MINUTE: \"DURATION_MINUTE\",\n DURATION_SECOND: \"DURATION_SECOND\",\n FUNC: \"FUNC\",\n CONVERT: \"CONVERT\",\n TO: \"TO\",\n BEST: \"BEST\",\n NEXT: \"NEXT\",\n LAST: \"LAST\",\n UNTIL: \"UNTIL\",\n SINCE: \"SINCE\",\n BETWEEN: \"BETWEEN\",\n // Bill split (finance package). Retyped from the ordinary words \"split\",\n // \"ways\" and \"people\" by BillSplitNormalizerRule, but only inside the full\n // split shape, so those words stay usable as variable names and prose\n // everywhere else (the same contextual-claim discipline as the recurring\n // schedule and at-rate rules).\n // The verb-first `split <amount> between N` form (prefix).\n SPLIT: \"SPLIT\",\n // The amount-first `<amount> split N ways` form (infix). A separate,\n // infix-only token so implicit multiplication does not read it as the start\n // of a new value and insert a `*` before it, which the dual-role SPLIT would.\n SPLIT_WAYS: \"SPLIT_WAYS\",\n WAYS: \"WAYS\",\n PEOPLE: \"PEOPLE\",\n FROM: \"FROM\",\n INCREASE: \"INCREASE\",\n DECREASE: \"DECREASE\",\n UNICODE_MATH: \"UNICODE_MATH\",\n TIMES_BY: \"TIMES_BY\",\n MULTIPLY_BY: \"MULTIPLY_BY\",\n DIVIDE_BY: \"DIVIDE_BY\",\n NEQ: \"NEQ\",\n IN: \"IN\",\n BIT_XOR: \"BIT_XOR\",\n EQUALITY: \"EQUALITY\",\n GTE: \"GTE\",\n LTE: \"LTE\",\n LT: \"LT\",\n GT: \"GT\",\n LOGICAL_AND: \"LOGICAL_AND\",\n LOGICAL_OR: \"LOGICAL_OR\",\n OR: \"OR\",\n TRUE: \"TRUE\",\n FALSE: \"FALSE\",\n IF: \"IF\",\n THEN: \"THEN\",\n ELSE: \"ELSE\",\n AS: \"AS\",\n CONVERTER_NAME: \"CONVERTER_NAME\",\n // Rounding (packages/converters/). \"rounded\" is a bare keyword: it is a\n // past participle with no plausible use as a :variableName, the same\n // accepted-risk category as \"between\"/\"from\". TO_NEAREST and\n // DECIMAL_PLACES are fused, since \"to\" already means percentage change.\n ROUNDED: \"ROUNDED\",\n TO_NEAREST: \"TO_NEAREST\",\n DECIMAL_PLACES: \"DECIMAL_PLACES\",\n // Fused two-word phrase tokens (see MathPhrasesPackage.ts's `phrases`\n // field), deliberately NOT bare single-word keywords: \"average\"\n // \"total\", \"count\", etc. are common variable names, and this codebase\n // has a tested policy that colon-prefixed variable names can't be\n // keyword-shaped words (see VariableParselet.ts's doc comment). Fusing\n // the full \"<word> of\"/\"<word> between\" phrase means the bare word\n // itself never becomes its own token type, so \":total = ...\" keeps\n // working exactly as before.\n AVERAGE_OF: \"AVERAGE_OF\",\n MEDIAN_OF: \"MEDIAN_OF\",\n TOTAL_OF: \"TOTAL_OF\",\n COUNT_OF: \"COUNT_OF\",\n LARGER_OF: \"LARGER_OF\",\n SMALLER_OF: \"SMALLER_OF\",\n HALF_OF: \"HALF_OF\",\n MIDPOINT_BETWEEN: \"MIDPOINT_BETWEEN\",\n REMAINDER_OF: \"REMAINDER_OF\",\n NTH_ROOT: \"NTH_ROOT\",\n LOG_PHRASE: \"LOG_PHRASE\",\n LOG_BASE: \"LOG_BASE\",\n GCD_OF: \"GCD_OF\",\n LCM_OF: \"LCM_OF\",\n SQUARE_ROOT_OF: \"SQUARE_ROOT_OF\",\n CUBE_ROOT_OF: \"CUBE_ROOT_OF\",\n RANDOM_NUMBER: \"RANDOM_NUMBER\",\n IS_TO: \"IS_TO\",\n // Bare \"is\", the trigger for the solve-for-the-unknown percentage family\n // (packages/percentage/IsWhatParselet.ts). Safe as a bare keyword: it is a\n // verb, not a plausible :variableName, and the \"is to\" proportion phrase is\n // fused earlier so it still wins.\n IS: \"IS\",\n PCT_ON: \"PCT_ON\",\n PCT_OFF: \"PCT_OFF\",\n // Successive percentage change (packages/percentage/UpDownParselet.ts):\n // `X up N%` grows, `X down N%` shrinks, chainable with `then` and\n // repeatable with `N times`. Retyped from a bare `up`/`down` IDENT only\n // when a percentage immediately follows (PercentUpDownNormalizerRule), so\n // prose that merely mentions the words is untouched. Declared here rather\n // than minted lazily for the same reason as the algebra verbs below: a\n // normalizer rule and its parselet must agree on the id.\n PCT_UP: \"PCT_UP\",\n PCT_DOWN: \"PCT_DOWN\",\n OF_WHAT: \"OF_WHAT\",\n OFF_WHAT: \"OFF_WHAT\",\n ON_WHAT: \"ON_WHAT\",\n // CLAMP stays a bare single-word keyword: \"clamp X between Y and Z\" has\n // the value X between the trigger and \"between\", so it can't be\n // phrase-fused like the others above (same structural reason\n // ClampParselet.ts is hand-written instead of PhrasePattern-based).\n // Matches this codebase's existing accepted risk for \"between\"/\"from\"/\n // \"next\"/\"last\"/\"best\", also bare, also can't be used as `:name`.\n CLAMP: \"CLAMP\",\n // map/reduce/sum/prod (packages/mapreduce/), bare single-word keywords\n // each with its own dedicated parselet (custom argument grammar: a bare\n // builtin/user-function name, an inline transform expression, or\n // `name=collection` zipped pairs, none of which fit the ordinary\n // FunctionCallParselet path, so these can't just reuse the generic FUNC\n // token type the way sqrt/abs/... do).\n MAP: \"MAP\",\n REDUCE: \"REDUCE\",\n SUM_FN: \"SUM_FN\",\n PROD_FN: \"PROD_FN\",\n // The algebra verbs (packages/symbolic/), fused from an ordinary IDENT only\n // when immediately followed by `(`, so `factor`/`solve`/`expand` stay usable\n // as variable names. Declared here rather than left to be minted on first use\n // by `tokenTypeId()`, which is what {@link registerAllTokenTypes} exists for:\n // a lazily-minted id depends on what else happened to be minted before it, so\n // in a single-process run the id a normalizer rule produces can stop matching\n // the id the parselet was registered under. Every token type a built-in\n // package relies on belongs in this table.\n EXPAND_FN: \"EXPAND_FN\",\n FACTOR_FN: \"FACTOR_FN\",\n SOLVE_FN: \"SOLVE_FN\",\n DER_FN: \"DER_FN\",\n INTEGRAL_FN: \"INTEGRAL_FN\",\n TAYLOR_FN: \"TAYLOR_FN\",\n JACOBIAN_FN: \"JACOBIAN_FN\",\n CONJ_FN: \"CONJ_FN\",\n RE_FN: \"RE_FN\",\n IM_FN: \"IM_FN\",\n CANCEL_FN: \"CANCEL_FN\",\n APART_FN: \"APART_FN\",\n // The imaginary-literal suffix, fused from a number followed immediately by\n // `i`. Same registration reasoning as the verbs above.\n IMAGINARY: \"IMAGINARY\",\n // `=>`, \"therefore\"/solve operator. The algebra itself lives in symbolic/;\n // packages/symbolic/ carries the grammar surface for the named operations.\n // A genuine 2-char lexer token (ExpressionLexer.ts's TWO_CHAR_OPS table),\n // same mechanism as ==/!=/>=/<=, not a normalizer-level fusion, \"=\" then\n // \">\" is the opposite char order from GTE's \">=\", so there's no collision.\n THEREFORE: \"THEREFORE\",\n // Timezone query phrases (see TimePackage.ts's `phrases` field). Same\n // phrase-fusion reasoning as above: \"time\"/\"date\"/\"difference\" are\n // common variable names, so the fused trigger is the full phrase.\n // CITY_NAME is the fused-token type for multi-word city/country names\n // (e.g. \"new york\"). See timezones/CityZones.ts's MULTI_WORD_CITY_ZONES.\n TIME_IN: \"TIME_IN\",\n DATE_IN: \"DATE_IN\",\n TIME_DIFFERENCE_BETWEEN: \"TIME_DIFFERENCE_BETWEEN\",\n CITY_NAME: \"CITY_NAME\",\n BACKTICK_OPEN: \"BACKTICK_OPEN\",\n INLINE_SOLVE_START: \"INLINE_SOLVE_START\",\n // Comment marker, `#` or `//` to end of line. Emitted by\n // ExpressionLexer.tokenizeComment()/tokenizeOperator() but never reaches\n // a parselet: ExpressionEngine.prepareExpression() filters COMMENT\n // tokens out of the stream before normalization/parsing (see\n // ExpressionEngine.ts's \"Filter COMMENT tokens\" comments). Listed here\n // for discoverability even though tokenTypeId() would lazily register\n // it anyway on first use.\n COMMENT: \"COMMENT\",\n // A `#hex` colour literal (`#ff0000`), recognised by the lexer where `#`\n // would otherwise be a heading/comment; the colour package's parselet turns\n // it into a colour value. See ExpressionLexer.matchHexColourEnd().\n HEX_COLOUR: \"HEX_COLOUR\",\n // A bounded mid-line `#tag` annotation (`1200 #housing`). Stripped from\n // evaluation by the tags package's strip rule, or consumed by its aggregate\n // rule (`total of #housing`). A line-start `#` is a heading, and `# ` (space)\n // or `//` is still a free-text comment.\n TAG: \"TAG\",\n // A colour function call fused by the colour package's normalizer, e.g.\n // `rgb(`/`lighten(`. Carries the function name; see ColourCallParselet.\n COLOUR_CALL: \"COLOUR_CALL\",\n // Vector types (referenced in locale keywordMap as vec2→VEC2, etc.)\n VEC2: \"VEC2\",\n VEC3: \"VEC3\",\n VEC4: \"VEC4\",\n FLOAT: \"FLOAT\",\n GLOBAL: \"GLOBAL\",\n // ── Finance (packages/finance/) ──\n // OVER/RATE_AT are bare single-word keywords (not phrase-fused): both are\n // prepositions with near-zero plausibility as a variable name (nobody\n // writes \":over = 5\" or \":at = 3\"), the same accepted-risk category as\n // this codebase's existing bare \"between\"/\"from\"/\"next\"/\"last\"/\"best\"\n // keywords (see VariableParselet.ts's doc comment). RATE_AT is deliberately\n // NOT named \"AT\", that name is already reserved (dormant) for a future\n // \"@\" symbol token in TokenNormalizer.NON_WORD_NAMES; reusing it here would\n // create an unintended coupling if \"@\" is ever wired up.\n OVER: \"OVER\",\n RATE_AT: \"RATE_AT\",\n // The investment grammar's connectives (packages/finance/), same\n // accepted-risk category as OVER/RATE_AT above. \"after\"/\"for\" are\n // prepositions; \"compounding\", \"invested\" and \"returned\" are participles,\n // and none is a plausible `:variableName`.\n //\n // \"after\" and \"for\" are the pivots Soulver's own documented syntax uses,\n // `$1,000 after 3 years at 7%` and `$1,000 for 3 years at 7% compounding\n // monthly`. This package originally substituted \"over\" for both and said so\n // in CompoundInterestParselet.ts's doc comment; the documented spellings now\n // work as well, and \"over\" is kept so nothing that already parsed stops.\n AFTER: \"AFTER\",\n PRESENT_VALUE_OF: \"PRESENT_VALUE_OF\",\n ANNUAL_RETURN_ON: \"ANNUAL_RETURN_ON\",\n FOR_DURATION: \"FOR_DURATION\",\n COMPOUNDING: \"COMPOUNDING\",\n INVESTED: \"INVESTED\",\n RETURNED: \"RETURNED\",\n // Fused phrase tokens (see FinancePackage.ts's `phrases` field)\n // deliberately NOT bare single-word keywords: \"interest\", \"tax\", \"vat\",\n // \"repayment\", \"principal\" etc. are all common, plausible variable names\n // (a shipped playground example uses \":total = :subtotal + :tax\". See\n // MathPhrasesPackage.ts's doc comment for the regression this caused\n // once already). Fusing the full \"<word> on\"/\"<word> off\" phrase means\n // the bare leading word itself never becomes its own token type, so\n // \":tax = ...\" keeps working exactly as before.\n COMPOUND_INTEREST_ON: \"COMPOUND_INTEREST_ON\",\n INTEREST_ON: \"INTEREST_ON\",\n DAILY_REPAYMENT_ON: \"DAILY_REPAYMENT_ON\",\n MONTHLY_REPAYMENT_ON: \"MONTHLY_REPAYMENT_ON\",\n ANNUAL_REPAYMENT_ON: \"ANNUAL_REPAYMENT_ON\",\n TOTAL_REPAYMENT_ON: \"TOTAL_REPAYMENT_ON\",\n DAILY_LOAN_INTEREST_ON: \"DAILY_LOAN_INTEREST_ON\",\n MONTHLY_LOAN_INTEREST_ON: \"MONTHLY_LOAN_INTEREST_ON\",\n ANNUAL_LOAN_INTEREST_ON: \"ANNUAL_LOAN_INTEREST_ON\",\n TOTAL_LOAN_INTEREST_ON: \"TOTAL_LOAN_INTEREST_ON\",\n TAX_ON: \"TAX_ON\",\n TAX_OFF: \"TAX_OFF\",\n TAX_IN_PHRASE: \"TAX_IN_PHRASE\",\n // Inflation-adjusted value (packages/finance/) -- fused phrase\n // tokens (see FinancePackage.ts's `phrases` field), same reasoning\n // as the tax/interest phrases above: \"what\"/\"was\"/\"value\"/\"worth\"\n // are all plausible variable names, so only the full phrases are\n // ever claimed as keywords, never the bare leading word.\n WHAT_IS: \"WHAT_IS\",\n WHAT_WAS: \"WHAT_WAS\",\n VALUE_OF: \"VALUE_OF\",\n WORTH_IN: \"WORTH_IN\",\n // Savings goals (finance). Fused whole-phrase triggers, so \"how\", \"much\",\n // \"save\" and \"reach\" stay ordinary variable names, the same reason as the\n // other finance phrases above.\n SAVINGS_HOW_LONG: \"SAVINGS_HOW_LONG\",\n SAVINGS_HOW_MUCH: \"SAVINGS_HOW_MUCH\",\n // Bare single-word keyword (not phrase-fused) -- \"assuming\" has\n // near-zero plausibility as a variable name, the same accepted-risk\n // category as this codebase's existing bare \"over\"/\"at\" keywords\n // (see the OVER/RATE_AT comment above). Registered so its bare word\n // is a recognized phrase-starter (`canStartPhrase`), which suppresses\n // implicit-multiply insertion between the futureYear NUMBER and this\n // word in \"value of $X in <year> assuming N% inflation\" -- without\n // this, \"<year> assuming\" was silently rewritten to \"<year> *\n // assuming\" before parsing ever ran.\n ASSUMING: \"ASSUMING\",\n // Fused by a custom NormalizerRule (not `phrases`), carrying the\n // year as its value -- see\n // finance/normalizer/InYearDollarsNormalizerRule.ts.\n IN_YEAR_DOLLARS: \"IN_YEAR_DOLLARS\",\n // Cooking/UoM (packages/uom/) -- fused ingredient name (single- or\n // multi-word, e.g. \"butter\"/\"olive oil\") carrying the matched name\n // as its value. NOT a bare-word phrase-trie keyword -- see\n // uom/normalizer/IngredientNameNormalizerRule.ts's doc comment for\n // why this is a context-sensitive NormalizerRule instead (so a bare\n // `:butter = 5` variable definition is completely unaffected).\n INGREDIENT_NAME: \"INGREDIENT_NAME\",\n // ── Datetime, workdays/weekdays/timestamps (packages/datetime/) ──\n // Fused phrase tokens (see DatetimePackage.ts's `phrases` field)\n // deliberately NOT bare single-word keywords: \"workdays\"/\"weekday\"/\n // \"timestamp\"/\"date\" are all plausible variable names, same\n // reasoning/regression risk as MathPhrasesPackage.ts's \"total\" note and\n // FinancePackage.ts's \"tax\" note above. Fusing the full phrase means the\n // bare leading word itself never becomes its own token type, so e.g.\n // \":timestamp = 5\" keeps working.\n WORKDAYS_IN: \"WORKDAYS_IN\",\n WEEKDAY_ON: \"WEEKDAY_ON\",\n CURRENT_TIMESTAMP: \"CURRENT_TIMESTAMP\",\n TO_DATE: \"TO_DATE\",\n TO_TIMESTAMP: \"TO_TIMESTAMP\",\n // Natural-question forms over the same date fields, \"what day is it in\n // 30 days\", \"what month is it on 25/12/2026\", \"what week is it\". Each is\n // a fully-fused phrase for the same reason as WEEKDAY_ON above: claiming\n // bare \"day\"/\"month\"/\"week\" as keywords would break \":day = 5\" and\n // collide with the UNIT tokens of the same name.\n WEEKDAY_IN: \"WEEKDAY_IN\",\n MONTH_ON: \"MONTH_ON\",\n MONTH_IN: \"MONTH_IN\",\n WEEK_ON: \"WEEK_ON\",\n DAYS_IN_PERIOD: \"DAYS_IN_PERIOD\",\n IN_TWO_UNITS: \"IN_TWO_UNITS\",\n PER_UNIT: \"PER_UNIT\",\n AT_RATE: \"AT_RATE\",\n WEEK_IN: \"WEEK_IN\",\n // `<unit> between <date> and <date>`, fused UNIT+BETWEEN, exactly like\n // UNTIL_UNIT/SINCE_UNIT above.\n BETWEEN_UNIT: \"BETWEEN_UNIT\",\n // Business-day arithmetic in words, \"N working/business days after|from|\n // before <date>\" (infix, the count is the left operand) and \"working/\n // business days between <date> and <date>\" (prefix). Full phrases for the\n // same reason as WORKDAYS_IN above: \"working\"/\"business\" are ordinary words,\n // so only the complete phrase is claimed, never the bare leading word. See\n // WorkdayOffsetParselet.ts / WorkdaysBetweenParselet.ts.\n WORKDAYS_AFTER: \"WORKDAYS_AFTER\",\n WORKDAYS_BEFORE: \"WORKDAYS_BEFORE\",\n WORKDAYS_BETWEEN: \"WORKDAYS_BETWEEN\",\n // Postfix day-type predicates, \"<date> is a weekend\" / \"is a workday\".\n IS_WEEKEND: \"IS_WEEKEND\",\n IS_WORKDAY: \"IS_WORKDAY\",\n // ── Time, video timecode (packages/time/) ──\n // Fused from a raw `HH:MM:SS:FF` token sequence (see\n // packages/time/normalizer/VideoTimecodeNormalizerRule.ts) and from\n // `NUMBER frames` (see FrameCountNormalizerRule.ts), not a bare-keyword\n // collision risk the way the datetime tokens above are, since neither\n // fusion claims a plain English word as its own token type.\n VIDEO_TIMECODE: \"VIDEO_TIMECODE\",\n FRAME_COUNT: \"FRAME_COUNT\",\n // \"@\". See ExpressionLexer.ts's OP_MAP entry for why this was\n // previously dormant/unproduced despite being anticipated by name here\n // and in TokenNormalizer.ts's NON_WORD_NAMES.\n AT: \"AT\",\n // Generic token for every currency symbol added AFTER the original\n // DOLLAR/POUND/EURO/YEN/RUBLE/WON set (each of which kept its own\n // specific token type for backward compatibility). See\n // uom/CurrencyAliases.ts's CURRENCY_SYMBOL_ALIASES and\n // ExpressionLexer.ts's dispatch for the full symbol list. One shared\n // type avoids needing a new TokenTypes entry + TokenCategoryMap entry +\n // CurrencyPackage.ts prefixParselets entry per additional symbol.\n CURRENCY_SYMBOL: \"CURRENCY_SYMBOL\",\n // ── Cross-line data access (packages/lines/) ──\n // \"prev\" -- bare keyword (nothing to phrase-fuse against, same shape as\n // CLAMP -- accepted collision risk per that package's own precedent).\n PREV: \"PREV\",\n // \"line1\" / \"line 1\" / \"l1\" -- fused by LineRefNormalizerRule (never a\n // bare lexer keyword, so \":line = 5\"/\":l = 5\" stay untouched). Carries\n // the parsed line number as its .value.\n LINE_REF: \"LINE_REF\",\n // \"sum(\" / \"total(\" -- fused ONLY when immediately followed by LPAREN\n // (see LineRefNormalizerRule's lookahead guard), so \":sum = 100\" and\n // MathPhrases' \"total of X, Y\" (no paren after \"of\") are unaffected.\n SUM_RANGE_CALL: \"SUM_RANGE_CALL\",\n AVERAGE_RANGE_CALL: \"AVERAGE_RANGE_CALL\",\n // \"total above\" / \"sum above\" / \"average above\" -- phrase-fused (see\n // LinesPackage.ts's `phrases` field), a deliberate departure from\n // Numi/Numbr's bare \"total\"/\"sum\" wording to avoid the exact bare-\n // keyword collision this codebase already regressed on once.\n TOTAL_ABOVE: \"TOTAL_ABOVE\",\n SUM_ABOVE: \"SUM_ABOVE\",\n AVERAGE_ABOVE: \"AVERAGE_ABOVE\",\n // ── Goal seek (packages/goalseek/) ──\n // \"solve line 4 for rate = 900\" -- fused by GoalSeekNormalizerRule when the\n // bare word \"solve\" is immediately followed by a LINE_REF (never a bare\n // lexer keyword, so \":solve = 2\" and the existing \"solve(...)\" call form\n // both stay untouched, since neither is \"solve\" directly before a LINE_REF).\n GOAL_SEEK: \"GOAL_SEEK\",\n} as const;\n\n/**\n * A token's kind, as a string.\n *\n * Deliberately open rather than an enum: a package registers its own token\n * types at runtime, and a closed set would make that impossible.\n */\nexport type TokenType = (typeof TokenTypes)[keyof typeof TokenTypes];\n\n// ── Integer Token Type ID System ──────────────────────────────────────────────\n// Enables O(1) integer comparison in Parser hot path instead of string hashing.\n\n/** Auto-incrementing integer ID for each token type. */\nlet _nextTokenTypeId = 0;\n\n/** String → integer ID lookup. Populated lazily via registerTokenType(). */\nconst _tokenTypeNameToId = new Map<string, number>();\n\n/** Integer ID → string lookup. For debug/error messages. */\nconst _tokenTypeIdToName = new Map<number, string>();\n\n/**\n * Register a token type name and get back its integer ID.\n * Idempotent, returns existing ID if already registered.\n * Call once per token type at module initialization time.\n */\nexport function registerTokenType(name: string): number {\n\tconst existing = _tokenTypeNameToId.get(name);\n\tif (existing !== undefined) return existing;\n\tconst id = _nextTokenTypeId++;\n\t_tokenTypeNameToId.set(name, id);\n\t_tokenTypeIdToName.set(id, name);\n\treturn id;\n}\n\n/**\n * Get the integer ID for a token type name.\n * Lazily registers unknown token types on first access, enabling plugin providers\n * to define custom token types (VEC2, VEC3, etc.) without pre-registration.\n * All built-in TokenTypes are pre-registered via registerAllTokenTypes().\n */\nexport function tokenTypeId(name: string): number {\n\treturn registerTokenType(name); // registerTokenType is idempotent\n}\n\n/**\n * Get the string name for a token type ID (for error messages and debugging).\n * Returns `UNKNOWN_${id}` if the ID is not registered.\n */\nexport function tokenTypeName(id: number): string {\n\treturn _tokenTypeIdToName.get(id) ?? `UNKNOWN_${id}`;\n}\n\n/**\n * Bootstrap all known token types from TokenTypes at module load.\n * Call this once after TokenTypes is defined.\n */\nexport function registerAllTokenTypes(): void {\n\tfor (const name of Object.values(TokenTypes)) {\n\t\tregisterTokenType(name);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e={code:"en",label:"English",keywordMap:{pi:"PI",e:"E",plus:"PLUS",add:"PLUS",and:"AND_CONJ",with:"PLUS",minus:"MINUS",subtract:"MINUS",remove:"MINUS",take:"MINUS",without:"MINUS",times:"STAR",multiply:"STAR",mul:"STAR",divide:"SLASH",modulo:"MOD",mod:"MOD",exponent:"CARET",prime:"CARET",xor:"BIT_XOR",of:"OF",now:"NOW",today:"TODAY",tomorrow:"TOMORROW",yesterday:"YESTERDAY",roll:"ROLL",sqrt:"FUNC",abs:"FUNC",sin:"FUNC",cos:"FUNC",tan:"FUNC",log:"FUNC",ceil:"FUNC",floor:"FUNC",round:"FUNC",min:"FUNC",max:"FUNC",asin:"FUNC",acos:"FUNC",atan:"FUNC",atan2:"FUNC",arcsin:"FUNC",arccos:"FUNC",arctan:"FUNC",sinh:"FUNC",cosh:"FUNC",tanh:"FUNC",asinh:"FUNC",acosh:"FUNC",atanh:"FUNC",cbrt:"FUNC",clz32:"FUNC",expm1:"FUNC",exp:"FUNC",root:"FUNC",fact:"FUNC",factorial:"FUNC",fround:"FUNC",hypot:"FUNC",imul:"FUNC",sind:"FUNC",cosd:"FUNC",tand:"FUNC",asind:"FUNC",acosd:"FUNC",atand:"FUNC",log10:"FUNC",log1p:"FUNC",log2:"FUNC",pow:"FUNC",random:"FUNC",sign:"FUNC",trunc:"FUNC",degtorad:"FUNC",radtodeg:"FUNC",gcd:"FUNC",lcm:"FUNC",permutation:"FUNC",combination:"FUNC",hex:"FUNC",bin:"FUNC",int:"FUNC",compoundinterest:"FUNC",interestearned:"FUNC",compoundinterestrate:"FUNC",compoundinterestyears:"FUNC",loanrepayment:"FUNC",loaninterest:"FUNC",monthlypayment:"FUNC",taxadd:"FUNC",taxremove:"FUNC",inflationadjust:"FUNC",transpose:"FUNC",det:"FUNC",inv:"FUNC",dot:"FUNC",clamp:"CLAMP",convert:"CONVERT",to:"TO",best:"BEST",in:"IN",into:"IN",next:"NEXT",last:"LAST",until:"UNTIL",since:"SINCE",sunday:"SUNDAY",monday:"MONDAY",tuesday:"TUESDAY",wednesday:"WEDNESDAY",thursday:"THURSDAY",friday:"FRIDAY",saturday:"SATURDAY",between:"BETWEEN",from:"FROM",increase:"INCREASE",decrease:"DECREASE",over:"OVER",at:"RATE_AT",rounded:"ROUNDED",is:"IS",after:"AFTER",for:"FOR_DURATION",compounding:"COMPOUNDING",invested:"INVESTED",returned:"RETURNED",by:"BY",vec2:"VEC2",vec3:"VEC3",vec4:"VEC4",float:"FLOAT",global:"GLOBAL",or:"OR",true:"TRUE",false:"FALSE",if:"IF",then:"THEN",else:"ELSE",as:"AS",percent:"CONVERTER_NAME",percentage:"CONVERTER_NAME",decimal:"CONVERTER_NAME",dec:"CONVERTER_NAME",number:"CONVERTER_NAME",fraction:"CONVERTER_NAME",multiplier:"CONVERTER_NAME",sci:"CONVERTER_NAME",scientific:"CONVERTER_NAME",binary:"CONVERTER_NAME",octal:"CONVERTER_NAME",oct:"CONVERTER_NAME"},display:{resultPrefix:"= ",dateFormat:"default",decimalSeparator:".",thousandsSeparator:",",vectorFormat:"[{values}]",percentageSuffix:"%"}};var a={code:"de",label:"Deutsch",keywordMap:{pi:"PI",e:"E",plus:"PLUS",add:"PLUS",und:"AND_CONJ",minus:"MINUS",subtract:"MINUS",entfernen:"MINUS",nehmen:"MINUS",mal:"STAR",multiplizieren:"STAR",teilen:"SLASH",modulo:"MOD",mod:"MOD",exponent:"CARET",potenz:"CARET",von:"OF",jetzt:"NOW",heute:"TODAY",morgen:"TOMORROW",gestern:"YESTERDAY",rollen:"ROLL",wurzel:"FUNC",abs:"FUNC",sin:"FUNC",cos:"FUNC",tan:"FUNC",log:"FUNC",aufrunden:"FUNC",abrunden:"FUNC",runden:"FUNC",min:"FUNC",max:"FUNC",asin:"FUNC",acos:"FUNC",atan:"FUNC",atan2:"FUNC",sinh:"FUNC",cosh:"FUNC",tanh:"FUNC",asinh:"FUNC",acosh:"FUNC",atanh:"FUNC",kubikwurzel:"FUNC",clz32:"FUNC",expm1:"FUNC",exp:"FUNC",fround:"FUNC",hypot:"FUNC",imul:"FUNC",log10:"FUNC",log1p:"FUNC",log2:"FUNC",pow:"FUNC",zufall:"FUNC",zeichen:"FUNC",ganzzahl:"FUNC",degtorad:"FUNC",radtodeg:"FUNC",konvertieren:"CONVERT",in:"TO",amBesten:"BEST",naechste:"NEXT",letzte:"LAST",bis:"UNTIL",seit:"SINCE",sonntag:"SUNDAY",montag:"MONDAY",dienstag:"TUESDAY",mittwoch:"WEDNESDAY",donnerstag:"THURSDAY",freitag:"FRIDAY",samstag:"SATURDAY",zwischen:"BETWEEN",von_ab:"FROM",erhoehen:"INCREASE",verringern:"DECREASE",vec2:"VEC2",vec3:"VEC3",vec4:"VEC4"},display:{resultPrefix:"= ",dateFormat:"default",decimalSeparator:",",thousandsSeparator:".",vectorFormat:"[{values}]",percentageSuffix:"%"}};var t={code:"fr",label:"Fran\xE7ais",keywordMap:{pi:"PI",e:"E",plus:"PLUS",ajouter:"PLUS",et:"AND_CONJ",moins:"MINUS",soustraire:"MINUS",enlever:"MINUS",fois:"STAR",multiplier:"STAR",diviser:"SLASH",modulo:"MOD",mod:"MOD",exposant:"CARET",puissance:"CARET",xor:"BIT_XOR",maintenant:"NOW",aujourdhui:"TODAY",demain:"TOMORROW",hier:"YESTERDAY",lancer:"ROLL",abs:"FUNC",sin:"FUNC",cos:"FUNC",tan:"FUNC",log:"FUNC",min:"FUNC",max:"FUNC",convertir:"CONVERT",prochain:"NEXT",dernier:"LAST",dimanche:"SUNDAY",lundi:"MONDAY",mardi:"TUESDAY",mercredi:"WEDNESDAY",jeudi:"THURSDAY",vendredi:"FRIDAY",samedi:"SATURDAY",entre:"BETWEEN",augmenter:"INCREASE",diminuer:"DECREASE",vec2:"VEC2",vec3:"VEC3",vec4:"VEC4",vrai:"TRUE",faux:"FALSE",si:"IF",alors:"THEN",sinon:"ELSE"},display:{resultPrefix:"= ",dateFormat:"default",decimalSeparator:",",thousandsSeparator:" ",vectorFormat:"[{values}]",percentageSuffix:"%"}};var o={en:e,de:a,fr:t};function s(N){return o[N]||e}export{s as a};//# sourceMappingURL=chunk-62LMTO4F.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-62LMTO4F.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants/locales/en.ts","../src/constants/locales/de.ts","../src/constants/locales/fr.ts","../src/constants/locales/index.ts"],"names":["enLocale","deLocale","frLocale","locales","getLocale","code"],"mappings":"AAgBO,IAAMA,EAAoB,CAC/B,IAAA,CAAM,IAAA,CACN,KAAA,CAAO,UACP,UAAA,CAAY,CACV,EAAA,CAAI,IAAA,CAAM,EAAG,GAAA,CACb,I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A,CAAK,MAAA,CAAQ,IAAK,MAAA,CAC/B,SAAA,CAAW,SAAA,CACX,QAAA,CAAU,OAAQ,OAAA,CAAS,MAAA,CAC3B,QAAA,CAAU,QAAA,CAAU,MAAO,QAAA,CAAU,KAAA,CAAO,SAAA,CAAW,QAAA,CAAU,YACjE,KAAA,CAAO,UAAA,CAAY,QAAA,CAAU,QAAA,CAAU,OAAQ,UAAA,CAC/C,KAAA,CAAO,SAAA,CACP,SAAA,CAAW,WAAY,QAAA,CAAU,UAAA,CACjC,IAAA,CAAM,MAAA,CAAQ,KAAM,MAAA,CAAQ,IAAA,CAAM,OAClC,IAAA,CAAM,MAAA,CAAQ,KAAM,OAAA,CACpB,EAAA,CAAI,IAAA,CAAM,KAAA,CAAO,OAAQ,KAAA,CAAO,MAClC,CAAA,CACA,OAAA,CAAS,CACP,YAAA,CAAc,IAAA,CACd,UAAA,CAAY,SAAA,CACZ,iBAAkB,GAAA,CAClB,kBAAA,CAAoB,IACpB,YAAA,CAAc,YAAA,CACd,iBAAkB,GACpB,CACF,CAAA,CC7DA,IAAMC,EAAmC,CACvC,EAAA,CAAIH,CAAAA,CACJ,EAAA,CAAIC,EACJ,EAAA,CAAIC,CACN,CAAA,CAUO,SAASE,EAAUC,CAAAA,CAAuB,CAC/C,OAAOF,CAAAA,CAAQE,CAAI,GAAKL,CAC1B","file":"chunk-62LMTO4F.js","sourcesContent":["/** What a locale supplies: keywords, units, and number formatting conventions. */\nexport interface ILocale {\n code: string;\n label: string;\n keywordMap: Record<string, string>;\n display: {\n resultPrefix: string;\n dateFormat: string;\n decimalSeparator: string;\n thousandsSeparator: string;\n vectorFormat: string;\n percentageSuffix: string;\n };\n}\n\n/** English keywords, units and number formatting. The default and the fallback. */\nexport const enLocale: ILocale = {\n code: \"en\",\n label: \"English\",\n keywordMap: {\n pi: \"PI\", e: \"E\",\n plus: \"PLUS\", add: \"PLUS\", and: \"AND_CONJ\", with: \"PLUS\",\n minus: \"MINUS\", subtract: \"MINUS\", remove: \"MINUS\", take: \"MINUS\",\n without: \"MINUS\",\n times: \"STAR\", multiply: \"STAR\", mul: \"STAR\",\n divide: \"SLASH\",\n modulo: \"MOD\", mod: \"MOD\",\n exponent: \"CARET\", prime: \"CARET\",\n xor: \"BIT_XOR\",\n of: \"OF\",\n now: \"NOW\", today: \"TODAY\", tomorrow: \"TOMORROW\", yesterday: \"YESTERDAY\",\n roll: \"ROLL\",\n sqrt: \"FUNC\", abs: \"FUNC\", sin: \"FUNC\", cos: \"FUNC\", tan: \"FUNC\",\n log: \"FUNC\", ceil: \"FUNC\", floor: \"FUNC\", round: \"FUNC\", min: \"FUNC\", max: \"FUNC\",\n asin: \"FUNC\", acos: \"FUNC\", atan: \"FUNC\", atan2: \"FUNC\",\n // Long-form aliases for asin/acos/atan (Numi/older-calculator naming\n // convention). Same FunctionCallParselet indices, not new behavior.\n arcsin: \"FUNC\", arccos: \"FUNC\", arctan: \"FUNC\",\n sinh: \"FUNC\", cosh: \"FUNC\", tanh: \"FUNC\",\n asinh: \"FUNC\", acosh: \"FUNC\", atanh: \"FUNC\",\n cbrt: \"FUNC\", clz32: \"FUNC\", expm1: \"FUNC\", exp: \"FUNC\",\n // root(n, x) -- n-th root; fact/factorial(n) -- factorial. Bare FUNC\n // keywords, matching gcd/lcm/cbrt's precedent above (technical,\n // call-syntax-only names, not plausible :variableName choices).\n root: \"FUNC\", fact: \"FUNC\", factorial: \"FUNC\",\n fround: \"FUNC\", hypot: \"FUNC\", imul: \"FUNC\",\n sind: \"FUNC\", cosd: \"FUNC\", tand: \"FUNC\",\n asind: \"FUNC\", acosd: \"FUNC\", atand: \"FUNC\",\n log10: \"FUNC\", log1p: \"FUNC\", log2: \"FUNC\",\n pow: \"FUNC\", random: \"FUNC\", sign: \"FUNC\", trunc: \"FUNC\",\n degtorad: \"FUNC\", radtodeg: \"FUNC\",\n gcd: \"FUNC\", lcm: \"FUNC\", permutation: \"FUNC\", combination: \"FUNC\",\n // hex/bin double as CONVERTER_NAME below (\"255 as hex\") AND as FUNC\n // call-syntax (\"hex(255)\"), a word can only have one lexer token\n // type, so these win FUNC (removed from the CONVERTER_NAME list\n // below) and AsConverterParselet.ts's \"as <name>\" check was widened\n // to also accept a FUNC-typed token, preserving \"as hex\"/\"as bin\"\n // unchanged. See AsConverterParselet.ts's class doc for the full\n // reasoning.\n hex: \"FUNC\", bin: \"FUNC\", int: \"FUNC\",\n // Finance (packages/finance/) function-call forms. Bare keywords, not\n // phrase-fused, these are camelCase call-only names (e.g.\n // \"compoundInterest(...)\"), not natural-language words a user would\n // plausibly choose as a variable name, so the bare-keyword collision\n // risk that blocks \"interest\"/\"tax\"/\"principal\" etc. doesn't apply here\n // (matches \"gcd\"/\"lcm\"/... above, not \"clamp\" below).\n compoundinterest: \"FUNC\", interestearned: \"FUNC\",\n compoundinterestrate: \"FUNC\", compoundinterestyears: \"FUNC\",\n loanrepayment: \"FUNC\", loaninterest: \"FUNC\", monthlypayment: \"FUNC\",\n taxadd: \"FUNC\", taxremove: \"FUNC\",\n // Inflation-adjusted value function-call form (packages/finance/).\n inflationadjust: \"FUNC\",\n // Matrix (packages/matrix/) function-call forms -- also reachable via\n // `^T`/`^-1` operator syntax and `|a|` (see FunctionCallParselet.ts's\n // builtinNameToIndex comment for indices 63-66).\n transpose: \"FUNC\", det: \"FUNC\", inv: \"FUNC\", dot: \"FUNC\",\n // map/reduce/sum/prod (packages/mapreduce/) are NOT bare keywordMap\n // entries. See packages/mapreduce/normalizer/MapReduceCallNormalizerRule.ts\n // which fuses them ONLY when immediately followed by \"(\" (same\n // \"conditional-on-LPAREN\" pattern as packages/lines/'s own\n // sum(/total(/average( fusion), so `:map = [...]`/`:sum = 100`/etc.\n // keep working as ordinary variable names.\n clamp: \"CLAMP\",\n // `into` is a third spelling of the conversion operator, alongside `to` and\n // `in`. It reads better before a unit than either (\"300 cm into m\"), and\n // costs nothing: it is not a plausible variable name and has no other\n // meaning in the grammar.\n convert: \"CONVERT\", to: \"TO\", best: \"BEST\", in: \"IN\", into: \"IN\",\n next: \"NEXT\", last: \"LAST\", until: \"UNTIL\", since: \"SINCE\",\n sunday: \"SUNDAY\", monday: \"MONDAY\", tuesday: \"TUESDAY\", wednesday: \"WEDNESDAY\",\n thursday: \"THURSDAY\", friday: \"FRIDAY\", saturday: \"SATURDAY\",\n between: \"BETWEEN\", from: \"FROM\",\n increase: \"INCREASE\", decrease: \"DECREASE\",\n // Finance (packages/finance/) phrase-grammar connectors. Bare\n // prepositions, same accepted-risk category as \"between\"/\"from\" above\n // see Token.ts's OVER/RATE_AT doc comment.\n over: \"OVER\", at: \"RATE_AT\",\n // Only \"rounded\". Bare \"round\" is already the round(x) function above.\n rounded: \"ROUNDED\",\n is: \"IS\",\n // The investment grammar (packages/finance/). See Token.ts.\n after: \"AFTER\", for: \"FOR_DURATION\", compounding: \"COMPOUNDING\",\n invested: \"INVESTED\", returned: \"RETURNED\",\n by: \"BY\",\n vec2: \"VEC2\", vec3: \"VEC3\", vec4: \"VEC4\",\n float: \"FLOAT\",\n global: \"GLOBAL\",\n or: \"OR\",\n true: \"TRUE\", false: \"FALSE\",\n if: \"IF\", then: \"THEN\", else: \"ELSE\",\n as: \"AS\",\n percent: \"CONVERTER_NAME\", percentage: \"CONVERTER_NAME\",\n decimal: \"CONVERTER_NAME\", dec: \"CONVERTER_NAME\", number: \"CONVERTER_NAME\",\n fraction: \"CONVERTER_NAME\",\n multiplier: \"CONVERTER_NAME\",\n sci: \"CONVERTER_NAME\", scientific: \"CONVERTER_NAME\",\n // hex/bin are FUNC (see above), not CONVERTER_NAME, \"as hex\"/\"as bin\"\n // still work via AsConverterParselet.ts's widened token-type check.\n binary: \"CONVERTER_NAME\",\n octal: \"CONVERTER_NAME\", oct: \"CONVERTER_NAME\",\n },\n display: {\n resultPrefix: \"= \",\n dateFormat: \"default\",\n decimalSeparator: \".\",\n thousandsSeparator: \",\",\n vectorFormat: \"[{values}]\",\n percentageSuffix: \"%\",\n },\n};\n","import { ILocale } from \"./en\";\n\n/** German keywords, units and number formatting. */\nexport const deLocale: ILocale = {\n code: \"de\",\n label: \"Deutsch\",\n keywordMap: {\n pi: \"PI\", e: \"E\",\n plus: \"PLUS\", add: \"PLUS\", und: \"AND_CONJ\",\n minus: \"MINUS\", subtract: \"MINUS\", entfernen: \"MINUS\", nehmen: \"MINUS\",\n mal: \"STAR\", multiplizieren: \"STAR\",\n teilen: \"SLASH\",\n modulo: \"MOD\", mod: \"MOD\",\n exponent: \"CARET\", potenz: \"CARET\",\n von: \"OF\",\n jetzt: \"NOW\", heute: \"TODAY\", morgen: \"TOMORROW\", gestern: \"YESTERDAY\",\n rollen: \"ROLL\",\n wurzel: \"FUNC\", abs: \"FUNC\", sin: \"FUNC\", cos: \"FUNC\", tan: \"FUNC\",\n log: \"FUNC\", aufrunden: \"FUNC\", abrunden: \"FUNC\", runden: \"FUNC\", min: \"FUNC\", max: \"FUNC\",\n asin: \"FUNC\", acos: \"FUNC\", atan: \"FUNC\", atan2: \"FUNC\",\n sinh: \"FUNC\", cosh: \"FUNC\", tanh: \"FUNC\",\n asinh: \"FUNC\", acosh: \"FUNC\", atanh: \"FUNC\",\n kubikwurzel: \"FUNC\", clz32: \"FUNC\", expm1: \"FUNC\", exp: \"FUNC\",\n fround: \"FUNC\", hypot: \"FUNC\", imul: \"FUNC\",\n log10: \"FUNC\", log1p: \"FUNC\", log2: \"FUNC\",\n pow: \"FUNC\", zufall: \"FUNC\", zeichen: \"FUNC\", ganzzahl: \"FUNC\",\n degtorad: \"FUNC\", radtodeg: \"FUNC\",\n konvertieren: \"CONVERT\", in: \"TO\", amBesten: \"BEST\",\n naechste: \"NEXT\", letzte: \"LAST\", bis: \"UNTIL\", seit: \"SINCE\",\n sonntag: \"SUNDAY\", montag: \"MONDAY\", dienstag: \"TUESDAY\", mittwoch: \"WEDNESDAY\",\n donnerstag: \"THURSDAY\", freitag: \"FRIDAY\", samstag: \"SATURDAY\",\n zwischen: \"BETWEEN\",\n von_ab: \"FROM\",\n erhoehen: \"INCREASE\", verringern: \"DECREASE\",\n vec2: \"VEC2\", vec3: \"VEC3\", vec4: \"VEC4\",\n },\n display: {\n resultPrefix: \"= \",\n dateFormat: \"default\",\n decimalSeparator: \",\",\n thousandsSeparator: \".\",\n vectorFormat: \"[{values}]\",\n percentageSuffix: \"%\",\n },\n};","import { ILocale } from \"./en\";\n\n/**\n * French locale. See GitHub issue #77 (\"Please allow for localized day\n * of the week\"). Matches `de.ts`'s scope, not `en.ts`'s full coverage: a\n * confident, reviewed core set (arithmetic words, date keywords, weekday\n * names, a handful of common functions), not a guess at every FUNC/phrase\n * keyword across every package. Widening this is a good first issue for\n * a native French speaker, PRs welcome, same as this project's existing\n * convention for locale gaps.\n *\n * \"aujourd'hui\" (today) is deliberately spelled without its apostrophe\n * here (`aujourdhui`), `ExpressionLexer`'s identifier reader only\n * accepts `[a-zA-Z_][a-zA-Z0-9_]*` plus Unicode, so the standard spelling\n * can't lex as a single IDENT token at all. This is a real, disclosed\n * limitation, not a translation choice, anyone typing the standard\n * apostrophed spelling won't get a match today.\n */\nexport const frLocale: ILocale = {\n code: \"fr\",\n label: \"Français\",\n keywordMap: {\n pi: \"PI\", e: \"E\",\n plus: \"PLUS\", ajouter: \"PLUS\", et: \"AND_CONJ\",\n moins: \"MINUS\", soustraire: \"MINUS\", enlever: \"MINUS\",\n fois: \"STAR\", multiplier: \"STAR\",\n diviser: \"SLASH\",\n modulo: \"MOD\", mod: \"MOD\",\n exposant: \"CARET\", puissance: \"CARET\",\n xor: \"BIT_XOR\",\n maintenant: \"NOW\",\n // \"aujourd'hui\". See this file's own doc comment for why the\n // apostrophe is dropped here.\n aujourdhui: \"TODAY\",\n demain: \"TOMORROW\", hier: \"YESTERDAY\",\n lancer: \"ROLL\",\n // Same spellings as English on purpose, not a translation gap: the\n // FUNC token's NAME is looked up in a separate, locale-independent\n // dispatch table (FunctionCallParselet.ts's builtinNameToIndex) that\n // only knows English names, \"racine\" (root) would lex fine as a\n // FUNC token via this keywordMap but then fail at call time with\n // \"Unknown function\", so it's deliberately left out rather than\n // shipped half-working. Widening that dispatch table to be\n // locale-aware is a separate, larger change (it would need the same\n // fix for German too, \"wurzel\" has this identical problem today).\n abs: \"FUNC\", sin: \"FUNC\", cos: \"FUNC\", tan: \"FUNC\",\n log: \"FUNC\", min: \"FUNC\", max: \"FUNC\",\n convertir: \"CONVERT\",\n prochain: \"NEXT\", dernier: \"LAST\",\n dimanche: \"SUNDAY\", lundi: \"MONDAY\", mardi: \"TUESDAY\", mercredi: \"WEDNESDAY\",\n jeudi: \"THURSDAY\", vendredi: \"FRIDAY\", samedi: \"SATURDAY\",\n entre: \"BETWEEN\",\n augmenter: \"INCREASE\", diminuer: \"DECREASE\",\n vec2: \"VEC2\", vec3: \"VEC3\", vec4: \"VEC4\",\n vrai: \"TRUE\", faux: \"FALSE\",\n si: \"IF\", alors: \"THEN\", sinon: \"ELSE\",\n },\n display: {\n resultPrefix: \"= \",\n dateFormat: \"default\",\n decimalSeparator: \",\",\n thousandsSeparator: \" \",\n vectorFormat: \"[{values}]\",\n percentageSuffix: \"%\",\n },\n};\n","import { enLocale, type ILocale } from \"./en\";\nimport { deLocale } from \"./de\";\nimport { frLocale } from \"./fr\";\n\nconst locales: Record<string, ILocale> = {\n en: enLocale,\n de: deLocale,\n fr: frLocale,\n};\n\n/**\n * Look up a locale by code.\n *\n * @param code - Locale code, for example `\"en\"` or `\"de\"`.\n * @returns The locale, or English when the code is unknown. Falling back\n * rather than throwing means an unrecognised code degrades to a working engine\n * instead of a dead one.\n */\nexport function getLocale(code: string): ILocale {\n return locales[code] || enLocale;\n}\n\n/**\n * Add a locale, or replace one already registered under the same code.\n *\n * @param code - Locale code to register under.\n * @param locale - Keywords, units and formatting for that locale.\n */\nexport function registerLocale(code: string, locale: ILocale): void {\n locales[code] = locale;\n}\n\nexport { enLocale, deLocale, frLocale, type ILocale };"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b}from'./chunk-YAYBVVG2.js';import {n}from'./chunk-EVAOPEO4.js';var _=[10,11,12,13,14,16,60,61,62,63,150,159,95,96],E=[50,51,151,152],m=[157,158],D=(()=>{let r=new Array(256).fill(0);for(let e of _)r[e]=1;for(let e of E)r[e]=2;for(let e of m)r[e]=3;return r})();[..._,...E,...m];function C(r,e){return e+1+(D[r[e]]??0)}var R="currency",A=class{constructor(e){this.namespace=R;this.exchange=e??b;}preflight(e,N,U,S,y){let{opcodes:c,strings:l}=N,f=c.length,o=0,i=-1,p=-1;for(;o<f;){let t=c[o];if(t===13&&(p=i,i=c[o+1]),(t===84||t===81||t===20||t===21||t===22||t===23)&&p>=0&&i>=0){let n$1=l[p],s=l[i];if(this.exchange.isCurrency(n$1)&&this.exchange.isCurrency(s)&&n$1.toUpperCase()!==s.toUpperCase()&&this.exchange.getRateSync(n$1,s)===null){let d=n$1.toUpperCase(),g=s.toUpperCase(),a=[R,d,g];if(y.getQueryData(a)!==void 0){o++;continue}let h=y.fetchQuery({queryKey:a,queryFn:({signal:I})=>this.exchange.getRate(n$1,s,I).then(T=>n(T)),staleTime:300*1e3});return {queryKey:a.join(":"),resolver:h,packageId:U,signal:S,metadata:{fromUnit:n$1,toUnit:s}}}}o=C(c,o);}return null}destroy(){}};export{C as a,A as b};//# sourceMappingURL=chunk-6G3PMEPA.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-6G3PMEPA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/parser/OperandWidth.ts","../src/uom/CurrencyResolver.ts"],"names":["ONE_OPERAND","TWO_OPERANDS","THREE_OPERANDS","OPERAND_BYTES","widths","op","nextInstruction","opcodes","index","CURRENCY_NS","CurrencyAsyncResolver","exchange","currencyExchangeService","_tokens","bytecode","packageId","signal","queryClient","strings","len","i","lastStrIdx","prevStrIdx","fromUnit","toUnit","fromUpper","toUpper","cacheKey","resolver","qSignal","rate","numberValue"],"mappings":"wEAwBA,IAAMA,CAAAA,CAAiC,CAAA,EAAA,CAA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,IAAMQ,CAAAA,CAAWX,CAAAA,CAAY,UAAA,CAAW,CACvC,QAAA,CAAUU,CAAAA,CACV,OAAA,CAAS,CAAC,CAAE,MAAA,CAAQE,CAAQ,IACpB,IAAA,CAAK,QAAA,CAAS,OAAA,CAAQN,GAAAA,CAAUC,CAAAA,CAAQK,CAAO,CAAA,CAAE,IAAA,CAAMC,CAAAA,EAASC,CAAAA,CAAYD,CAAI,CAAC,CAAA,CAEzF,SAAA,CAAW,GAAA,CAAS,GACrB,CAAC,CAAA,CAED,OAAO,CAAE,QAAA,CAAUH,CAAAA,CAAS,IAAA,CAAK,GAAG,CAAA,CAAG,QAAA,CAAAC,CAAAA,CAAU,SAAA,CAAAb,CAAAA,CAAW,MAAA,CAAAC,CAAAA,CAAQ,QAAA,CAAU,CAAE,SAAAO,GAAAA,CAAU,MAAA,CAAAC,CAAO,CAAE,CACpG,CAEF,CAKDJ,CAAAA,CAAId,EAAgBC,CAAAA,CAASa,CAAC,EAC/B,CAEA,OAAO,IACR,CAEA,OAAA,EAAgB,CAEhB,CACD","file":"chunk-6G3PMEPA.js","sourcesContent":["/**\n * How many operand bytes follow each opcode, and how to step over one.\n *\n * Anything walking a bytecode stream without executing it needs this: the\n * resolver preflight scanners look for specific opcodes and must skip past\n * everything else without mistaking an operand byte for an instruction.\n *\n * It used to be a hand-copied switch in each of those scanners. They had\n * already drifted: two counted `CALL_PLUGIN` as three bytes wide and the third\n * omitted it from that arm, so a stream containing one desynchronised there and\n * every opcode after it was read at the wrong offset. Adding an opcode meant\n * remembering every copy, and nothing checked that you had.\n *\n * `__tests__/parser/OperandWidth.spec.ts` asserts every opcode has a width, so\n * a new one fails a test rather than silently defaulting to zero operands.\n */\n\nimport { OpCode } from \"@solve-js/parser/OpCode\";\n\n/**\n * Opcodes taking one operand byte.\n *\n * A constant-pool index, or a variable-name index.\n */\nconst ONE_OPERAND: readonly OpCode[] = [\n\tOpCode.PUSH_NUMBER,\n\tOpCode.PUSH_BIGINT,\n\tOpCode.PUSH_HEX,\n\tOpCode.PUSH_STRING,\n\tOpCode.PUSH_BOOLEAN,\n\t// Its operand is a string-pool index holding the exact decimal text, so a\n\t// scanner must step over one byte exactly as it does for PUSH_STRING.\n\tOpCode.PUSH_DECIMAL,\n\tOpCode.LOAD_VAR,\n\tOpCode.STORE_VAR,\n\tOpCode.LOAD_GLOBAL_VAR,\n\tOpCode.STORE_GLOBAL_VAR,\n\tOpCode.DEFINE_USER_FUNCTION,\n\tOpCode.BIND_UNKNOWN,\n\t// Its operand is a constant-pool index, like PUSH_NUMBER's: the epoch-ms\n\t// was resolved at parse time and stored in `numbers`. Omitting it made\n\t// every scanner read that index byte as an opcode, so an ordinary date\n\t// literal desynchronised the whole preflight walk.\n\tOpCode.DATE_LITERAL,\n\t// One byte, the offset direction (0 forward, 1 backward) for \"N working\n\t// days after/before/from <date>\". See WorkdayOffsetParselet. DATE_WORKDAYS_BETWEEN\n\t// takes no operand and so is not listed here.\n\tOpCode.DATE_WORKDAY_OFFSET,\n];\n\n/**\n * Opcodes taking two operand bytes.\n *\n * A callable index plus an argument count, or a matrix's row and column counts.\n */\nconst TWO_OPERANDS: readonly OpCode[] = [\n\tOpCode.CALL_PLUGIN,\n\tOpCode.CALL_BUILTIN,\n\tOpCode.CALL_USER_FUNCTION,\n\tOpCode.MAT_NEW,\n];\n\n/**\n * Opcodes taking three operand bytes.\n *\n * The map and reduce invocations, which carry a body index alongside their\n * other operands.\n */\nconst THREE_OPERANDS: readonly OpCode[] = [OpCode.MAP_INVOKE, OpCode.REDUCE_INVOKE];\n\n/**\n * Operand byte count for every opcode, indexed by opcode value.\n *\n * A dense array rather than a map, because the preflight scanners run on every\n * keystroke and this is read once per instruction.\n */\nexport const OPERAND_BYTES: readonly number[] = (() => {\n\tconst widths = new Array<number>(256).fill(0);\n\tfor (const op of ONE_OPERAND) widths[op] = 1;\n\tfor (const op of TWO_OPERANDS) widths[op] = 2;\n\tfor (const op of THREE_OPERANDS) widths[op] = 3;\n\treturn widths;\n})();\n\n/**\n * Every opcode that takes at least one operand.\n *\n * Exported so a test can assert the table stays complete as opcodes are added.\n */\nexport const OPCODES_WITH_OPERANDS: readonly OpCode[] = [\n\t...ONE_OPERAND,\n\t...TWO_OPERANDS,\n\t...THREE_OPERANDS,\n];\n\n/**\n * Offset of the instruction after the one at `index`.\n *\n * @param opcodes - The bytecode stream.\n * @param index - Offset of an opcode, not of an operand byte. Passing an\n * operand offset yields nonsense, which is the failure mode this exists to\n * prevent: a caller stepping by hand and getting one width wrong reads the rest\n * of the stream misaligned.\n * @returns Offset of the next opcode. May be past the end when the instruction\n * at `index` is the last one, so callers loop while it is under `opcodes.length`.\n */\nexport function nextInstruction(opcodes: Uint8Array, index: number): number {\n\treturn index + 1 + (OPERAND_BYTES[opcodes[index]] ?? 0);\n}\n","/**\n * Currency async resolver, bridges CurrencyExchangeService to the\n * IAsyncResolver interface for the Suspense architecture.\n *\n * Uses TanStack Query (injected via queryClient) as the single cache layer.\n */\nimport type { QueryClient } from \"@tanstack/query-core\";\nimport type { Token } from \"@solve-js/lexer\";\nimport type { BytecodeProgram } from \"@solve-js/parser/BytecodeBuilder\";\nimport { OpCode } from \"@solve-js/parser/OpCode\";\nimport { numberValue } from \"@solve-js/vm/Value\";\nimport {\n\tcurrencyExchangeService,\n\tCurrencyExchangeService,\n} from \"@solve-js/uom/CurrencyExchange\";\nimport type { IAsyncResolver, AsyncCheckResult } from \"@solve-js/resolvers/ResolverRegistry\";\nimport { nextInstruction } from \"@solve-js/parser/OperandWidth\";\n\nconst CURRENCY_NS = \"currency\";\n\n/**\n * Fetches exchange rates before the VM runs, so a conversion has real numbers.\n *\n * Until rates arrive the line evaluates to a pending value rather than a\n * guessed one, and re-evaluates when they land.\n */\nexport class CurrencyAsyncResolver implements IAsyncResolver {\n\treadonly namespace = CURRENCY_NS;\n\n\tprivate exchange: CurrencyExchangeService;\n\n\tconstructor(exchange?: CurrencyExchangeService) {\n\t\tthis.exchange = exchange ?? currencyExchangeService;\n\t}\n\n\tpreflight(_tokens: Token[], bytecode: BytecodeProgram, packageId: string, signal: AbortSignal, queryClient: QueryClient): AsyncCheckResult | null {\n\t\tconst { opcodes, strings } = bytecode;\n\t\tconst len = opcodes.length;\n\t\tlet i = 0;\n\n\t\tlet lastStrIdx = -1;\n\t\tlet prevStrIdx = -1;\n\n\t\twhile (i < len) {\n\t\t\tconst op = opcodes[i] as OpCode;\n\n\t\t\tif (op === OpCode.PUSH_STRING) {\n\t\t\t\tprevStrIdx = lastStrIdx;\n\t\t\t\tlastStrIdx = opcodes[i + 1];\n\t\t\t}\n\n\t\t\t// Explicit \"X to Y\"/\"X in Y\" conversions (UOM_CONVERT_IN/_TO) are\n\t\t\t// the obvious case, but arithmetic directly on two differently-\n\t\t\t// denominated currency literals, \"0.01 BTC + 1 ETH\", needs the\n\t\t\t// exact same preflight fetch and previously never got it: this\n\t\t\t// scanner only looked for the CONVERT opcodes, so ADD/SUB/MUL/DIV\n\t\t\t// between two currency UOMs skipped preflight entirely, ran with\n\t\t\t// no cached rate, and fell through to the VM's silent-wrong-math\n\t\t\t// fallback instead of ever reaching a network fetch.\n\t\t\tconst isCurrencyCombiningOp =\n\t\t\t\top === OpCode.UOM_CONVERT_IN || op === OpCode.UOM_CONVERT_TO ||\n\t\t\t\top === OpCode.ADD || op === OpCode.SUB || op === OpCode.MUL || op === OpCode.DIV;\n\t\t\tif (isCurrencyCombiningOp) {\n\t\t\t\tif (prevStrIdx >= 0 && lastStrIdx >= 0) {\n\t\t\t\t\tconst fromUnit = strings[prevStrIdx];\n\t\t\t\t\tconst toUnit = strings[lastStrIdx];\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.exchange.isCurrency(fromUnit) &&\n\t\t\t\t\t\tthis.exchange.isCurrency(toUnit) &&\n\t\t\t\t\t\tfromUnit.toUpperCase() !== toUnit.toUpperCase()\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst syncRate = this.exchange.getRateSync(fromUnit, toUnit);\n\t\t\t\t\t\tif (syncRate === null) {\n\t\t\t\t\t\t\tconst fromUpper = fromUnit.toUpperCase();\n\t\t\t\t\t\t\tconst toUpper = toUnit.toUpperCase();\n\n\t\t\t\t\t\t\t// Check TanStack Query cache\n\t\t\t\t\t\t\tconst cacheKey = [CURRENCY_NS, fromUpper, toUpper];\n\t\t\t\t\t\t\tif (queryClient.getQueryData(cacheKey) !== undefined) {\n\t\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Fetch via TanStack Query (dedup + retry automatic)\n\t\t\t\t\t\t\tconst resolver = queryClient.fetchQuery({\n\t\t\t\t\t\t\t\tqueryKey: cacheKey,\n\t\t\t\t\t\t\t\tqueryFn: ({ signal: qSignal }) => {\n\t\t\t\t\t\t\t\t\treturn this.exchange.getRate(fromUnit, toUnit, qSignal).then((rate) => numberValue(rate));\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tstaleTime: 5 * 60 * 1000,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\treturn { queryKey: cacheKey.join(\":\"), resolver, packageId, signal, metadata: { fromUnit, toUnit } };\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Step over this instruction and its operands. Shared table, because\n\t\t\t// three hand-copied versions of this had already drifted.\n\t\t\ti = nextInstruction(opcodes, i);\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tdestroy(): void {\n\t\t// Cache cleared by ResolverRegistry.unregister() via removeQueries({ queryKey: [\"currency\"] })\n\t}\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunk4BZIYU7S_cjs=require('./chunk-4BZIYU7S.cjs'),chunkPS272DZJ_cjs=require('./chunk-PS272DZJ.cjs');var _=[10,11,12,13,14,16,60,61,62,63,150,159,95,96],E=[50,51,151,152],m=[157,158],D=(()=>{let r=new Array(256).fill(0);for(let e of _)r[e]=1;for(let e of E)r[e]=2;for(let e of m)r[e]=3;return r})();[..._,...E,...m];function C(r,e){return e+1+(D[r[e]]??0)}var R="currency",A=class{constructor(e){this.namespace=R;this.exchange=e??chunk4BZIYU7S_cjs.b;}preflight(e,N,U,S,y){let{opcodes:c,strings:l}=N,f=c.length,o=0,i=-1,p=-1;for(;o<f;){let t=c[o];if(t===13&&(p=i,i=c[o+1]),(t===84||t===81||t===20||t===21||t===22||t===23)&&p>=0&&i>=0){let n=l[p],s=l[i];if(this.exchange.isCurrency(n)&&this.exchange.isCurrency(s)&&n.toUpperCase()!==s.toUpperCase()&&this.exchange.getRateSync(n,s)===null){let d=n.toUpperCase(),g=s.toUpperCase(),a=[R,d,g];if(y.getQueryData(a)!==void 0){o++;continue}let h=y.fetchQuery({queryKey:a,queryFn:({signal:I})=>this.exchange.getRate(n,s,I).then(T=>chunkPS272DZJ_cjs.n(T)),staleTime:300*1e3});return {queryKey:a.join(":"),resolver:h,packageId:U,signal:S,metadata:{fromUnit:n,toUnit:s}}}}o=C(c,o);}return null}destroy(){}};exports.a=C;exports.b=A;//# sourceMappingURL=chunk-6INX773F.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-6INX773F.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/parser/OperandWidth.ts","../src/uom/CurrencyResolver.ts"],"names":["ONE_OPERAND","TWO_OPERANDS","THREE_OPERANDS","OPERAND_BYTES","widths","op","nextInstruction","opcodes","index","CURRENCY_NS","CurrencyAsyncResolver","exchange","currencyExchangeService","_tokens","bytecode","packageId","signal","queryClient","strings","len","i","lastStrIdx","prevStrIdx","fromUnit","toUnit","fromUpper","toUpper","cacheKey","resolver","qSignal","rate","numberValue"],"mappings":"qHAwBA,IAAMA,CAAAA,CAAiC,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EA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AAE,MAAA,CAAQE,CAAQ,IACpB,IAAA,CAAK,QAAA,CAAS,OAAA,CAAQN,CAAAA,CAAUC,CAAAA,CAAQK,CAAO,CAAA,CAAE,IAAA,CAAMC,CAAAA,EAASC,mBAAAA,CAAYD,CAAI,CAAC,CAAA,CAEzF,SAAA,CAAW,GAAA,CAAS,GACrB,CAAC,CAAA,CAED,OAAO,CAAE,QAAA,CAAUH,CAAAA,CAAS,IAAA,CAAK,GAAG,CAAA,CAAG,QAAA,CAAAC,CAAAA,CAAU,SAAA,CAAAb,CAAAA,CAAW,MAAA,CAAAC,CAAAA,CAAQ,QAAA,CAAU,CAAE,SAAAO,CAAAA,CAAU,MAAA,CAAAC,CAAO,CAAE,CACpG,CAEF,CAKDJ,CAAAA,CAAId,EAAgBC,CAAAA,CAASa,CAAC,EAC/B,CAEA,OAAO,IACR,CAEA,OAAA,EAAgB,CAEhB,CACD","file":"chunk-6INX773F.cjs","sourcesContent":["/**\n * How many operand bytes follow each opcode, and how to step over one.\n *\n * Anything walking a bytecode stream without executing it needs this: the\n * resolver preflight scanners look for specific opcodes and must skip past\n * everything else without mistaking an operand byte for an instruction.\n *\n * It used to be a hand-copied switch in each of those scanners. They had\n * already drifted: two counted `CALL_PLUGIN` as three bytes wide and the third\n * omitted it from that arm, so a stream containing one desynchronised there and\n * every opcode after it was read at the wrong offset. Adding an opcode meant\n * remembering every copy, and nothing checked that you had.\n *\n * `__tests__/parser/OperandWidth.spec.ts` asserts every opcode has a width, so\n * a new one fails a test rather than silently defaulting to zero operands.\n */\n\nimport { OpCode } from \"@solve-js/parser/OpCode\";\n\n/**\n * Opcodes taking one operand byte.\n *\n * A constant-pool index, or a variable-name index.\n */\nconst ONE_OPERAND: readonly OpCode[] = [\n\tOpCode.PUSH_NUMBER,\n\tOpCode.PUSH_BIGINT,\n\tOpCode.PUSH_HEX,\n\tOpCode.PUSH_STRING,\n\tOpCode.PUSH_BOOLEAN,\n\t// Its operand is a string-pool index holding the exact decimal text, so a\n\t// scanner must step over one byte exactly as it does for PUSH_STRING.\n\tOpCode.PUSH_DECIMAL,\n\tOpCode.LOAD_VAR,\n\tOpCode.STORE_VAR,\n\tOpCode.LOAD_GLOBAL_VAR,\n\tOpCode.STORE_GLOBAL_VAR,\n\tOpCode.DEFINE_USER_FUNCTION,\n\tOpCode.BIND_UNKNOWN,\n\t// Its operand is a constant-pool index, like PUSH_NUMBER's: the epoch-ms\n\t// was resolved at parse time and stored in `numbers`. Omitting it made\n\t// every scanner read that index byte as an opcode, so an ordinary date\n\t// literal desynchronised the whole preflight walk.\n\tOpCode.DATE_LITERAL,\n\t// One byte, the offset direction (0 forward, 1 backward) for \"N working\n\t// days after/before/from <date>\". See WorkdayOffsetParselet. DATE_WORKDAYS_BETWEEN\n\t// takes no operand and so is not listed here.\n\tOpCode.DATE_WORKDAY_OFFSET,\n];\n\n/**\n * Opcodes taking two operand bytes.\n *\n * A callable index plus an argument count, or a matrix's row and column counts.\n */\nconst TWO_OPERANDS: readonly OpCode[] = [\n\tOpCode.CALL_PLUGIN,\n\tOpCode.CALL_BUILTIN,\n\tOpCode.CALL_USER_FUNCTION,\n\tOpCode.MAT_NEW,\n];\n\n/**\n * Opcodes taking three operand bytes.\n *\n * The map and reduce invocations, which carry a body index alongside their\n * other operands.\n */\nconst THREE_OPERANDS: readonly OpCode[] = [OpCode.MAP_INVOKE, OpCode.REDUCE_INVOKE];\n\n/**\n * Operand byte count for every opcode, indexed by opcode value.\n *\n * A dense array rather than a map, because the preflight scanners run on every\n * keystroke and this is read once per instruction.\n */\nexport const OPERAND_BYTES: readonly number[] = (() => {\n\tconst widths = new Array<number>(256).fill(0);\n\tfor (const op of ONE_OPERAND) widths[op] = 1;\n\tfor (const op of TWO_OPERANDS) widths[op] = 2;\n\tfor (const op of THREE_OPERANDS) widths[op] = 3;\n\treturn widths;\n})();\n\n/**\n * Every opcode that takes at least one operand.\n *\n * Exported so a test can assert the table stays complete as opcodes are added.\n */\nexport const OPCODES_WITH_OPERANDS: readonly OpCode[] = [\n\t...ONE_OPERAND,\n\t...TWO_OPERANDS,\n\t...THREE_OPERANDS,\n];\n\n/**\n * Offset of the instruction after the one at `index`.\n *\n * @param opcodes - The bytecode stream.\n * @param index - Offset of an opcode, not of an operand byte. Passing an\n * operand offset yields nonsense, which is the failure mode this exists to\n * prevent: a caller stepping by hand and getting one width wrong reads the rest\n * of the stream misaligned.\n * @returns Offset of the next opcode. May be past the end when the instruction\n * at `index` is the last one, so callers loop while it is under `opcodes.length`.\n */\nexport function nextInstruction(opcodes: Uint8Array, index: number): number {\n\treturn index + 1 + (OPERAND_BYTES[opcodes[index]] ?? 0);\n}\n","/**\n * Currency async resolver, bridges CurrencyExchangeService to the\n * IAsyncResolver interface for the Suspense architecture.\n *\n * Uses TanStack Query (injected via queryClient) as the single cache layer.\n */\nimport type { QueryClient } from \"@tanstack/query-core\";\nimport type { Token } from \"@solve-js/lexer\";\nimport type { BytecodeProgram } from \"@solve-js/parser/BytecodeBuilder\";\nimport { OpCode } from \"@solve-js/parser/OpCode\";\nimport { numberValue } from \"@solve-js/vm/Value\";\nimport {\n\tcurrencyExchangeService,\n\tCurrencyExchangeService,\n} from \"@solve-js/uom/CurrencyExchange\";\nimport type { IAsyncResolver, AsyncCheckResult } from \"@solve-js/resolvers/ResolverRegistry\";\nimport { nextInstruction } from \"@solve-js/parser/OperandWidth\";\n\nconst CURRENCY_NS = \"currency\";\n\n/**\n * Fetches exchange rates before the VM runs, so a conversion has real numbers.\n *\n * Until rates arrive the line evaluates to a pending value rather than a\n * guessed one, and re-evaluates when they land.\n */\nexport class CurrencyAsyncResolver implements IAsyncResolver {\n\treadonly namespace = CURRENCY_NS;\n\n\tprivate exchange: CurrencyExchangeService;\n\n\tconstructor(exchange?: CurrencyExchangeService) {\n\t\tthis.exchange = exchange ?? currencyExchangeService;\n\t}\n\n\tpreflight(_tokens: Token[], bytecode: BytecodeProgram, packageId: string, signal: AbortSignal, queryClient: QueryClient): AsyncCheckResult | null {\n\t\tconst { opcodes, strings } = bytecode;\n\t\tconst len = opcodes.length;\n\t\tlet i = 0;\n\n\t\tlet lastStrIdx = -1;\n\t\tlet prevStrIdx = -1;\n\n\t\twhile (i < len) {\n\t\t\tconst op = opcodes[i] as OpCode;\n\n\t\t\tif (op === OpCode.PUSH_STRING) {\n\t\t\t\tprevStrIdx = lastStrIdx;\n\t\t\t\tlastStrIdx = opcodes[i + 1];\n\t\t\t}\n\n\t\t\t// Explicit \"X to Y\"/\"X in Y\" conversions (UOM_CONVERT_IN/_TO) are\n\t\t\t// the obvious case, but arithmetic directly on two differently-\n\t\t\t// denominated currency literals, \"0.01 BTC + 1 ETH\", needs the\n\t\t\t// exact same preflight fetch and previously never got it: this\n\t\t\t// scanner only looked for the CONVERT opcodes, so ADD/SUB/MUL/DIV\n\t\t\t// between two currency UOMs skipped preflight entirely, ran with\n\t\t\t// no cached rate, and fell through to the VM's silent-wrong-math\n\t\t\t// fallback instead of ever reaching a network fetch.\n\t\t\tconst isCurrencyCombiningOp =\n\t\t\t\top === OpCode.UOM_CONVERT_IN || op === OpCode.UOM_CONVERT_TO ||\n\t\t\t\top === OpCode.ADD || op === OpCode.SUB || op === OpCode.MUL || op === OpCode.DIV;\n\t\t\tif (isCurrencyCombiningOp) {\n\t\t\t\tif (prevStrIdx >= 0 && lastStrIdx >= 0) {\n\t\t\t\t\tconst fromUnit = strings[prevStrIdx];\n\t\t\t\t\tconst toUnit = strings[lastStrIdx];\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.exchange.isCurrency(fromUnit) &&\n\t\t\t\t\t\tthis.exchange.isCurrency(toUnit) &&\n\t\t\t\t\t\tfromUnit.toUpperCase() !== toUnit.toUpperCase()\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst syncRate = this.exchange.getRateSync(fromUnit, toUnit);\n\t\t\t\t\t\tif (syncRate === null) {\n\t\t\t\t\t\t\tconst fromUpper = fromUnit.toUpperCase();\n\t\t\t\t\t\t\tconst toUpper = toUnit.toUpperCase();\n\n\t\t\t\t\t\t\t// Check TanStack Query cache\n\t\t\t\t\t\t\tconst cacheKey = [CURRENCY_NS, fromUpper, toUpper];\n\t\t\t\t\t\t\tif (queryClient.getQueryData(cacheKey) !== undefined) {\n\t\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Fetch via TanStack Query (dedup + retry automatic)\n\t\t\t\t\t\t\tconst resolver = queryClient.fetchQuery({\n\t\t\t\t\t\t\t\tqueryKey: cacheKey,\n\t\t\t\t\t\t\t\tqueryFn: ({ signal: qSignal }) => {\n\t\t\t\t\t\t\t\t\treturn this.exchange.getRate(fromUnit, toUnit, qSignal).then((rate) => numberValue(rate));\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tstaleTime: 5 * 60 * 1000,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\treturn { queryKey: cacheKey.join(\":\"), resolver, packageId, signal, metadata: { fromUnit, toUnit } };\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Step over this instruction and its operands. Shared table, because\n\t\t\t// three hand-copied versions of this had already drifted.\n\t\t\ti = nextInstruction(opcodes, i);\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tdestroy(): void {\n\t\t// Cache cleared by ResolverRegistry.unregister() via removeQueries({ queryKey: [\"currency\"] })\n\t}\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
function e(n){return n.startsWith('"')&&n.endsWith('"')&&n.length>=2?n.slice(1,-1):n}function s(n,i=Number.MAX_SAFE_INTEGER){let t=1,r=n.indexOf(`
|
|
2
|
+
`);for(;r!==-1;){if(++t>i)return t;r=n.indexOf(`
|
|
3
|
+
`,r+1);}return t}export{e as a,s as b};//# sourceMappingURL=chunk-76F3LCIL.js.map
|
|
4
|
+
//# sourceMappingURL=chunk-76F3LCIL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utilities/Strings.ts"],"names":["stripQuotes","value","countLines","text","stopAfter","count","index"],"mappings":"AASO,SAASA,CAAAA,CAAYC,CAAAA,CAAuB,CAClD,OAAOA,EAAM,UAAA,CAAW,GAAG,CAAA,EAAKA,CAAAA,CAAM,SAAS,GAAG,CAAA,EAAKA,CAAAA,CAAM,MAAA,EAAU,EACpEA,CAAAA,CAAM,KAAA,CAAM,CAAA,CAAG,EAAE,CAAA,CACjBA,CACJ,CAeO,SAASC,EAAWC,CAAAA,CAAcC,CAAAA,CAAoB,MAAA,CAAO,gBAAA,CAA0B,CAC7F,IAAIC,CAAAA,CAAQ,CAAA,CACRC,CAAAA,CAAQH,EAAK,OAAA,CAAQ;AAAA,CAAI,CAAA,CAC7B,KAAOG,CAAAA,GAAU,EAAA,EAAI,CACpB,GAAI,EAAED,CAAAA,CAAQD,CAAAA,CAAW,OAAOC,CAAAA,CAChCC,CAAAA,CAAQH,EAAK,OAAA,CAAQ;AAAA,CAAA,CAAMG,CAAAA,CAAQ,CAAC,EACrC,CACA,OAAOD,CACR","file":"chunk-76F3LCIL.js","sourcesContent":["/**\n * Strips a single layer of matching double quotes from a string, if present.\n * Returns the input unchanged if it isn't fully wrapped in quotes.\n *\n * Was needed for STRING token values, which the lexer used to emit with their\n * surrounding `\"...\"` quotes still attached. `tokenizeString()` now strips them\n * when it builds the token, so on that path this is a no-op kept as a defence\n * against text arriving from somewhere else already quoted.\n */\nexport function stripQuotes(value: string): string {\n\treturn value.startsWith('\"') && value.endsWith('\"') && value.length >= 2\n\t\t? value.slice(1, -1)\n\t\t: value;\n}\n\n/**\n * How many lines `text` has, without splitting it into an array.\n *\n * `split(\"\\n\").length` answers the same question and allocates the whole\n * document to do it, which is the wrong shape for a caller whose next move may\n * be to refuse the document for being too large. Counting stops as soon as the\n * answer is \"more than the caller cares about\".\n *\n * @param text - The document.\n * @param stopAfter - Stop counting once past this many lines.\n * @returns The line count, or `stopAfter + 1` for anything longer. A document\n * with no newline in it is one line, matching `split`.\n */\nexport function countLines(text: string, stopAfter: number = Number.MAX_SAFE_INTEGER): number {\n\tlet count = 1;\n\tlet index = text.indexOf(\"\\n\");\n\twhile (index !== -1) {\n\t\tif (++count > stopAfter) return count;\n\t\tindex = text.indexOf(\"\\n\", index + 1);\n\t}\n\treturn count;\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunk4QVBSG6B_cjs=require('./chunk-4QVBSG6B.cjs'),chunk2LFLR3VZ_cjs=require('./chunk-2LFLR3VZ.cjs'),chunk5IJD5L3O_cjs=require('./chunk-5IJD5L3O.cjs'),chunkSOMGSIO4_cjs=require('./chunk-SOMGSIO4.cjs');var I=class{constructor(){this.category="Symbolic";}parse(o,t,e){o.consume("LPAREN"),o.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,e),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(67),e.emitIndex(1);}};var x=class{constructor(){this.category="Symbolic";}parse(o,t,e){o.consume("LPAREN"),o.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,e),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(68),e.emitIndex(1);}};function l(r,o){let t=r.peek();if(!t||t.type!=="IDENT"&&t.type!=="UNIT")throw chunkSOMGSIO4_cjs.c.parsing("SYMBOLIC_REQUIRES_VARIABLE_NAME",`${o} needs the name of an unknown here, as in ${o}(x^2, x).`,{found:t?.type??"end of input"});return r.consume(),t.value}function s(r,o){r.emitOpcode(13),r.emitString(o);}function a(r,o,t){let e=new chunk4QVBSG6B_cjs.d(o.pluginIndexMap);r.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,e),r.setBuilder(o);let i=e.build();if(i.hasAsync)throw chunkSOMGSIO4_cjs.c.parsing("SYMBOLIC_ARGUMENT_MUST_BE_SYNCHRONOUS",`${t}'s expression must be synchronous (no weather/stocks/currency calls).`);return i}function p(r,o,t){let e=r.emitAnonymousBody([t],o);r.emitOpcode(159),r.emitIndex(e);}var B=class{constructor(){this.category="Symbolic";}parse(o,t,e){o.consume("LPAREN");let i=a(o,e,"solve"),n=o.match("EQUALS")?a(o,e,"solve"):null;o.consume("COMMA");let c=o.peek();if(!c||c.type!=="IDENT"&&c.type!=="UNIT")throw chunkSOMGSIO4_cjs.c.parsing("SOLVE_REQUIRES_VARIABLE_NAME","solve's second argument must be the name of the unknown to solve for, as in solve(x^2-4=0, x).",{found:c?.type??"end of input"});o.consume(),p(e,i,c.value),n?p(e,n,c.value):(e.emitOpcode(10),e.emitNumber(0)),s(e,c.value),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(69),e.emitIndex(3);}};var y=class{constructor(){this.category="Symbolic";}parse(o,t,e){o.consume("LPAREN");let i=a(o,e,"der");o.consume("COMMA");let n=l(o,"der");p(e,i,n),s(e,n),o.match("COMMA")?o.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,e):(e.emitOpcode(10),e.emitNumber(1)),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(70),e.emitIndex(3);}};var P=class{constructor(){this.category="Symbolic";}parse(o,t,e){o.consume("LPAREN");let i=a(o,e,"integral");o.consume("COMMA");let n=l(o,"integral");p(e,i,n),s(e,n),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(71),e.emitIndex(2);}};var L=class{constructor(){this.category="Symbolic";}parse(o,t,e){o.consume("LPAREN");let i=a(o,e,"taylor");o.consume("COMMA");let n=l(o,"taylor");p(e,i,n),s(e,n),o.consume("EQUALS"),o.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,e),o.consume("COMMA"),o.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,e),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(72),e.emitIndex(4);}};var _=class{constructor(){this.category="Symbolic";}parse(o,t,e){o.consume("LPAREN");let i=0;do o.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,e),i++;while(o.match("COMMA"));o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(73),e.emitIndex(i);}};var T=class{constructor(){this.category="Symbolic";}parse(o,t,e){e.emitOpcode(10),e.emitNumber(Number(t.value)),e.emitOpcode(51),e.emitIndex(74),e.emitIndex(1);}};var u=class{constructor(){this.category="Symbolic";}parse(o,t,e){o.consume("LPAREN"),o.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,e),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(75),e.emitIndex(1);}};var A=class{constructor(){this.category="Symbolic";}parse(o,t,e){o.consume("LPAREN"),o.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,e),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(76),e.emitIndex(1);}};var E=class{constructor(){this.category="Symbolic";}parse(o,t,e){o.consume("LPAREN"),o.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,e),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(77),e.emitIndex(1);}};var O=class{constructor(){this.category="Symbolic";}parse(o,t,e){o.consume("LPAREN"),o.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,e),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(78),e.emitIndex(1);}};var R=class{constructor(){this.category="Symbolic";}parse(o,t,e){o.consume("LPAREN"),o.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,e),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(79),e.emitIndex(1);}};function g(r=75){return {name:"symbolic:imaginary-literal",priority:r,match(o,t){let e=o[t];if(!e||e.type!=="NUMBER")return null;let i=o[t+1];return !i||i.type!=="IDENT"||i.value!=="i"||i.offset!==e.offset+e.value.length||o[t+2]?.type==="LPAREN"?null:{consumed:2,replacement:[new chunk2LFLR3VZ_cjs.a("IMAGINARY",chunk5IJD5L3O_cjs.c("IMAGINARY"),e.value,e.value,e.offset,0,e.line,e.col)],ruleName:"symbolic:imaginary-literal"}}}}var b={expand:"EXPAND_FN",factor:"FACTOR_FN",solve:"SOLVE_FN",der:"DER_FN",derivative:"DER_FN",integral:"INTEGRAL_FN",taylor:"TAYLOR_FN",jacobian:"JACOBIAN_FN",conj:"CONJ_FN",re:"RE_FN",im:"IM_FN",cancel:"CANCEL_FN",apart:"APART_FN"};function k(r=80){return {name:"symbolic:call",priority:r,match(o,t){let e=o[t];if(!e||e.type!=="IDENT")return null;let i=b[e.value.toLowerCase()];return !i||o[t+1]?.type!=="LPAREN"?null:{consumed:1,replacement:[new chunk2LFLR3VZ_cjs.a(i,chunk5IJD5L3O_cjs.c(i),e.value,e.value,e.offset,0,e.line,e.col)],ruleName:"symbolic:call"}}}}var S=[{word:"expand",tokenType:"EXPAND_FN",builtinIndex:67,example:"expand((x+1)*(x+2))",expected:"x^2+3x+2",docPage:"algebra.md"},{word:"factor",tokenType:"FACTOR_FN",builtinIndex:68,example:"factor(x^2-4)",expected:"(x-2)*(x+2)",docPage:"algebra.md"},{word:"solve",tokenType:"SOLVE_FN",builtinIndex:69,example:"solve(x^2-4=0, x)",expected:"= [-2, 2]",docPage:"algebra.md"},{word:"der",tokenType:"DER_FN",builtinIndex:70,example:"der(x^3, x)",expected:"3x^2",docPage:"calculus.md"},{word:"integral",tokenType:"INTEGRAL_FN",builtinIndex:71,example:"integral(x^2, x)",expected:"1/3x^3",docPage:"calculus.md"},{word:"taylor",tokenType:"TAYLOR_FN",builtinIndex:72,example:"taylor(exp(x), x=0, 3)",expected:"1/6x^3+0.5x^2+x+1",docPage:"calculus.md"},{word:"jacobian",tokenType:"JACOBIAN_FN",builtinIndex:73,example:"jacobian(x*y, x+y)",expected:"= [y, x; 1, 1]",docPage:"calculus.md"},{word:"conj",tokenType:"CONJ_FN",builtinIndex:75,example:"conj(2+3i)",expected:"2-3i",docPage:"complex.md"},{word:"re",tokenType:"RE_FN",builtinIndex:76,example:"re(2+3i)",expected:"= 2",docPage:"complex.md"},{word:"im",tokenType:"IM_FN",builtinIndex:77,example:"im(2+3i)",expected:"= 3",docPage:"complex.md"},{word:"cancel",tokenType:"CANCEL_FN",builtinIndex:78,example:"cancel((x^2-1)/(x-1))",expected:"x+1",docPage:"algebra.md"},{word:"apart",tokenType:"APART_FN",builtinIndex:79,example:"apart((3x+5)/(x^2-1))",expected:"4/(x-1)-1/(x+1)",docPage:"algebra.md"}],j={name:"solve-symbolic",normalizerRules:[k(),g()],prefixParselets:{EXPAND_FN:new I,FACTOR_FN:new x,SOLVE_FN:new B,DER_FN:new y,INTEGRAL_FN:new P,TAYLOR_FN:new L,JACOBIAN_FN:new _,IMAGINARY:new T,CONJ_FN:new u,RE_FN:new A,IM_FN:new E,CANCEL_FN:new O,APART_FN:new R},tokenCategories:{EXPAND_FN:"keyword",FACTOR_FN:"keyword",SOLVE_FN:"keyword",DER_FN:"keyword",INTEGRAL_FN:"keyword",TAYLOR_FN:"keyword",JACOBIAN_FN:"keyword",IMAGINARY:"number",CONJ_FN:"keyword",RE_FN:"keyword",IM_FN:"keyword",CANCEL_FN:"keyword",APART_FN:"keyword"}},X=new Set(S.map(r=>r.tokenType));function H(r){return r.some(o=>X.has(o.type))}exports.a=j;exports.b=H;//# sourceMappingURL=chunk-7BXPCWKM.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-7BXPCWKM.cjs.map
|