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