solve-engine 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BytecodeBuilder-B0xskcv5.d.cts → BytecodeBuilder-Bp9xeTmX.d.cts} +4 -0
- package/dist/{BytecodeBuilder-B0xskcv5.d.ts → BytecodeBuilder-Bp9xeTmX.d.ts} +4 -0
- package/dist/{Configuration-B-G5gTRn.d.cts → Configuration-C9W8tJv_.d.cts} +53 -1
- package/dist/{Configuration-B-G5gTRn.d.ts → Configuration-C9W8tJv_.d.ts} +53 -1
- package/dist/{EngineError-LU7W7AgI.d.cts → EngineError-B61GS1jp.d.cts} +14 -0
- package/dist/{EngineError-LU7W7AgI.d.ts → EngineError-B61GS1jp.d.ts} +14 -0
- package/dist/FormattingSettings-CJHyxcYu.d.cts +27 -0
- package/dist/FormattingSettings-CJHyxcYu.d.ts +27 -0
- package/dist/{Lexer-DpjdaQ98.d.cts → Lexer-BOs7euZe.d.cts} +28 -1
- package/dist/{Lexer-CNmWxabg.d.ts → Lexer-CSI_lwbW.d.ts} +28 -1
- package/dist/PackageCompatibility-B-7rK1TD.d.cts +76 -0
- package/dist/PackageCompatibility-Dh59eF-X.d.ts +76 -0
- package/dist/{PackageRegistry-zuzqt51V.d.cts → PackageRegistry-BHWJP83F.d.cts} +449 -11
- package/dist/{PackageRegistry-ClIFXxAe.d.ts → PackageRegistry-_8rDlvxI.d.ts} +449 -11
- package/dist/{Parselet-BaySkMV3.d.ts → Parselet-BBT8riYh.d.ts} +12 -3
- package/dist/{Parselet-DuI1Pjiq.d.cts → Parselet-BHcgK9S7.d.cts} +12 -3
- package/dist/{ScopeManager-B6GzdhVG.d.cts → ScopeManager-8vf02dwj.d.cts} +56 -5
- package/dist/{ScopeManager-udv4Twwq.d.ts → ScopeManager-CxA24W5n.d.ts} +56 -5
- package/dist/{Token-BzG5G4ja.d.cts → Token-B1hdkedD.d.cts} +9 -0
- package/dist/{Token-BzG5G4ja.d.ts → Token-B1hdkedD.d.ts} +9 -0
- package/dist/{TokenNormalizer-t_GotBxr.d.ts → TokenNormalizer-C6VzZgHa.d.ts} +1 -1
- package/dist/{TokenNormalizer-DGVa24Q-.d.cts → TokenNormalizer-DRc1Js1V.d.cts} +1 -1
- package/dist/{VMCheckpoints-DwLjivM7.d.cts → VMCheckpoints-ELYqITdF.d.cts} +3 -3
- package/dist/{VMCheckpoints-BiaIlOOY.d.ts → VMCheckpoints-MK--EBH2.d.ts} +3 -3
- package/dist/{Value-CXJqDH9J.d.cts → Value-BUi1RA3S.d.cts} +124 -5
- package/dist/{Value-CXJqDH9J.d.ts → Value-BUi1RA3S.d.ts} +124 -5
- package/dist/WorkerError-_-RkoQ5P.d.ts +75 -0
- package/dist/WorkerError-gzmaopj2.d.cts +75 -0
- package/dist/{chunk-GQCOSXMG.js → chunk-267JPOTF.js} +43 -5
- package/dist/chunk-267JPOTF.js.map +1 -0
- package/dist/{chunk-JMXUNXQS.cjs → chunk-2TZKENDH.cjs} +51 -8
- package/dist/chunk-2TZKENDH.cjs.map +1 -0
- package/dist/chunk-3OWCDIPN.js +215 -0
- package/dist/chunk-3OWCDIPN.js.map +1 -0
- package/dist/{chunk-VB37OC6I.js → chunk-4D6NIHE2.js} +40 -3
- package/dist/chunk-4D6NIHE2.js.map +1 -0
- package/dist/{chunk-TY3TLZAW.cjs → chunk-536WPM2V.cjs} +18 -2
- package/dist/chunk-536WPM2V.cjs.map +1 -0
- package/dist/chunk-5HRB36DK.js +405 -0
- package/dist/chunk-5HRB36DK.js.map +1 -0
- package/dist/chunk-5ON7PUAZ.js +12 -0
- package/dist/chunk-5ON7PUAZ.js.map +1 -0
- package/dist/{chunk-KV7UW6T6.js → chunk-7KYSUDQO.js} +12 -5
- package/dist/chunk-7KYSUDQO.js.map +1 -0
- package/dist/{chunk-6WFMPTGB.cjs → chunk-7ZX6B7SY.cjs} +774 -528
- package/dist/chunk-7ZX6B7SY.cjs.map +1 -0
- package/dist/chunk-ALYRJ72W.cjs +434 -0
- package/dist/chunk-ALYRJ72W.cjs.map +1 -0
- package/dist/{chunk-5KMIY374.cjs → chunk-B4HBEFTB.cjs} +17 -2
- package/dist/chunk-B4HBEFTB.cjs.map +1 -0
- package/dist/chunk-B7NLZMQ3.cjs +74 -0
- package/dist/chunk-B7NLZMQ3.cjs.map +1 -0
- package/dist/{chunk-UQ3UIZJC.js → chunk-BLI4NIQY.js} +6 -2
- package/dist/chunk-BLI4NIQY.js.map +1 -0
- package/dist/{chunk-T556MJDZ.cjs → chunk-C75AFGVD.cjs} +11 -11
- package/dist/{chunk-T556MJDZ.cjs.map → chunk-C75AFGVD.cjs.map} +1 -1
- package/dist/{chunk-G535KJEG.js → chunk-CCBZZQAE.js} +2 -2
- package/dist/{chunk-G535KJEG.js.map → chunk-CCBZZQAE.js.map} +1 -1
- package/dist/chunk-CKQMXMHR.cjs +219 -0
- package/dist/chunk-CKQMXMHR.cjs.map +1 -0
- package/dist/{chunk-PFUESQTW.cjs → chunk-EJ3ILXX6.cjs} +48 -2
- package/dist/chunk-EJ3ILXX6.cjs.map +1 -0
- package/dist/{chunk-526PMQOA.js → chunk-ENKKJYD3.js} +10 -4
- package/dist/chunk-ENKKJYD3.js.map +1 -0
- package/dist/{chunk-5X2PTP6F.cjs → chunk-ENRIK36Q.cjs} +2 -12
- package/dist/chunk-ENRIK36Q.cjs.map +1 -0
- package/dist/{chunk-3D7V24DG.js → chunk-ERCOHGXD.js} +17 -2
- package/dist/chunk-ERCOHGXD.js.map +1 -0
- package/dist/{chunk-IF532O7C.js → chunk-FD5ZZHEU.js} +3 -12
- package/dist/chunk-FD5ZZHEU.js.map +1 -0
- package/dist/{chunk-7FSDNNNC.js → chunk-G7Z4HJQA.js} +11 -5
- package/dist/chunk-G7Z4HJQA.js.map +1 -0
- package/dist/{chunk-FQGX2PA2.js → chunk-GQMUHVE3.js} +115 -4
- package/dist/chunk-GQMUHVE3.js.map +1 -0
- package/dist/chunk-GUG7SNSV.js +1764 -0
- package/dist/chunk-GUG7SNSV.js.map +1 -0
- package/dist/{chunk-UM6BVY2S.cjs → chunk-HIQ5HSZL.cjs} +175 -43
- package/dist/chunk-HIQ5HSZL.cjs.map +1 -0
- package/dist/{chunk-HVQFNJKE.cjs → chunk-HVRVSI2Z.cjs} +104 -86
- package/dist/chunk-HVRVSI2Z.cjs.map +1 -0
- package/dist/{chunk-3LAEG75D.js → chunk-I4GAWIPW.js} +24 -6
- package/dist/chunk-I4GAWIPW.js.map +1 -0
- package/dist/{chunk-PA4VC73I.cjs → chunk-J45BCEZ4.cjs} +33 -27
- package/dist/chunk-J45BCEZ4.cjs.map +1 -0
- package/dist/{chunk-NG2JHZHE.js → chunk-JIPATHVY.js} +1853 -2640
- package/dist/chunk-JIPATHVY.js.map +1 -0
- package/dist/{chunk-IP7ASJEW.js → chunk-JJIXHXFQ.js} +5 -5
- package/dist/{chunk-IP7ASJEW.js.map → chunk-JJIXHXFQ.js.map} +1 -1
- package/dist/chunk-L2TE7PMO.cjs +14 -0
- package/dist/chunk-L2TE7PMO.cjs.map +1 -0
- package/dist/{chunk-HBVFFBRR.cjs → chunk-MG6Q3DUO.cjs} +1962 -2748
- package/dist/chunk-MG6Q3DUO.cjs.map +1 -0
- package/dist/{chunk-R3PY4G7J.js → chunk-MVTOCRV2.js} +48 -3
- package/dist/chunk-MVTOCRV2.js.map +1 -0
- package/dist/{chunk-Y7FT4IQT.js → chunk-NKW7LKYU.js} +266 -28
- package/dist/chunk-NKW7LKYU.js.map +1 -0
- package/dist/{chunk-O3ANBHSA.js → chunk-NNQ2TYDF.js} +123 -5
- package/dist/chunk-NNQ2TYDF.js.map +1 -0
- package/dist/{chunk-AA3KTWTX.js → chunk-OADDUPT3.js} +4 -4
- package/dist/{chunk-AA3KTWTX.js.map → chunk-OADDUPT3.js.map} +1 -1
- package/dist/{chunk-SESSWASV.cjs → chunk-OTN6SZOD.cjs} +1868 -393
- package/dist/chunk-OTN6SZOD.cjs.map +1 -0
- package/dist/{chunk-5LI5EPGJ.cjs → chunk-QFTDTX6K.cjs} +40 -3
- package/dist/chunk-QFTDTX6K.cjs.map +1 -0
- package/dist/{chunk-YXCTLWOH.js → chunk-RRLHC37V.js} +1530 -57
- package/dist/chunk-RRLHC37V.js.map +1 -0
- package/dist/chunk-SNHVVOJK.cjs +1768 -0
- package/dist/chunk-SNHVVOJK.cjs.map +1 -0
- package/dist/{chunk-HDP7VK3C.cjs → chunk-SRGQ72IR.cjs} +649 -349
- package/dist/chunk-SRGQ72IR.cjs.map +1 -0
- package/dist/{chunk-4B2CNWQU.cjs → chunk-SSV46KFA.cjs} +14 -7
- package/dist/chunk-SSV46KFA.cjs.map +1 -0
- package/dist/{chunk-AJA6LUI7.js → chunk-UO6BUV6K.js} +18 -2
- package/dist/chunk-UO6BUV6K.js.map +1 -0
- package/dist/chunk-WWQEY7BV.js +67 -0
- package/dist/chunk-WWQEY7BV.js.map +1 -0
- package/dist/{chunk-5WVP4YHP.js → chunk-WXEHD6TT.js} +333 -33
- package/dist/chunk-WXEHD6TT.js.map +1 -0
- package/dist/{chunk-47LRVGOT.cjs → chunk-XA4CKRML.cjs} +2 -2
- package/dist/{chunk-47LRVGOT.cjs.map → chunk-XA4CKRML.cjs.map} +1 -1
- package/dist/{chunk-6KFYJ6TD.cjs → chunk-XIYYHA65.cjs} +6 -2
- package/dist/chunk-XIYYHA65.cjs.map +1 -0
- package/dist/{chunk-FE23VSSA.cjs → chunk-XJGJCF2R.cjs} +6 -6
- package/dist/{chunk-FE23VSSA.cjs.map → chunk-XJGJCF2R.cjs.map} +1 -1
- package/dist/{chunk-R7YVBHCV.cjs → chunk-YTIYVHL7.cjs} +184 -73
- package/dist/chunk-YTIYVHL7.cjs.map +1 -0
- package/dist/{chunk-TMA4RCEN.js → chunk-Z7XGGLI2.js} +3 -3
- package/dist/{chunk-TMA4RCEN.js.map → chunk-Z7XGGLI2.js.map} +1 -1
- package/dist/{chunk-A2N2GFCG.cjs → chunk-ZVTWQLK4.cjs} +10 -10
- package/dist/{chunk-A2N2GFCG.cjs.map → chunk-ZVTWQLK4.cjs.map} +1 -1
- package/dist/{chunk-524F3ATQ.cjs → chunk-ZXCESUJS.cjs} +15 -9
- package/dist/chunk-ZXCESUJS.cjs.map +1 -0
- package/dist/constants.cjs +5 -5
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +2 -2
- package/dist/engine.cjs +52 -35
- package/dist/engine.d.cts +13 -13
- package/dist/engine.d.ts +13 -13
- package/dist/engine.js +26 -21
- package/dist/errors.cjs +44 -19
- package/dist/errors.d.cts +3 -2
- package/dist/errors.d.ts +3 -2
- package/dist/errors.js +2 -1
- package/dist/format.cjs +19 -169
- package/dist/format.cjs.map +1 -1
- package/dist/format.d.cts +18 -26
- package/dist/format.d.ts +18 -26
- package/dist/format.js +7 -171
- package/dist/format.js.map +1 -1
- package/dist/index.cjs +250 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +110 -74
- package/dist/index.d.ts +110 -74
- package/dist/index.js +228 -23
- package/dist/index.js.map +1 -1
- package/dist/language.cjs +9 -9
- package/dist/language.d.cts +12 -12
- package/dist/language.d.ts +12 -12
- package/dist/language.js +3 -3
- package/dist/lexer.cjs +16 -16
- package/dist/lexer.d.cts +3 -3
- package/dist/lexer.d.ts +3 -3
- package/dist/lexer.js +5 -5
- package/dist/normalizer.cjs +10 -10
- package/dist/normalizer.d.cts +3 -3
- package/dist/normalizer.d.ts +3 -3
- package/dist/normalizer.js +4 -4
- package/dist/packages.cjs +45 -36
- package/dist/packages.d.cts +135 -31
- package/dist/packages.d.ts +135 -31
- package/dist/packages.js +14 -13
- package/dist/parser.cjs +16 -16
- package/dist/parser.d.cts +6 -5
- package/dist/parser.d.ts +6 -5
- package/dist/parser.js +6 -6
- package/dist/{pipeline-BEb3hujr.d.cts → pipeline-CtfJtPQc.d.cts} +3 -3
- package/dist/{pipeline-B6k5lCB7.d.ts → pipeline-DCd5M6Gk.d.ts} +3 -3
- package/dist/resolvers.d.cts +3 -3
- package/dist/resolvers.d.ts +3 -3
- package/dist/testing.cjs +478 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +271 -0
- package/dist/testing.d.ts +271 -0
- package/dist/testing.js +470 -0
- package/dist/testing.js.map +1 -0
- package/dist/uom.cjs +16 -16
- package/dist/uom.d.cts +3 -3
- package/dist/uom.d.ts +3 -3
- package/dist/uom.js +6 -6
- package/dist/utilities.cjs +6 -5
- package/dist/utilities.js +2 -1
- package/dist/vm.cjs +34 -34
- package/dist/vm.d.cts +8 -8
- package/dist/vm.d.ts +8 -8
- package/dist/vm.js +9 -9
- package/dist/worker.cjs +493 -0
- package/dist/worker.cjs.map +1 -0
- package/dist/worker.d.cts +509 -0
- package/dist/worker.d.ts +509 -0
- package/dist/worker.js +484 -0
- package/dist/worker.js.map +1 -0
- package/package.json +21 -1
- package/dist/chunk-3D7V24DG.js.map +0 -1
- package/dist/chunk-3LAEG75D.js.map +0 -1
- package/dist/chunk-4B2CNWQU.cjs.map +0 -1
- package/dist/chunk-524F3ATQ.cjs.map +0 -1
- package/dist/chunk-526PMQOA.js.map +0 -1
- package/dist/chunk-5KMIY374.cjs.map +0 -1
- package/dist/chunk-5LI5EPGJ.cjs.map +0 -1
- package/dist/chunk-5WVP4YHP.js.map +0 -1
- package/dist/chunk-5X2PTP6F.cjs.map +0 -1
- package/dist/chunk-6KFYJ6TD.cjs.map +0 -1
- package/dist/chunk-6WFMPTGB.cjs.map +0 -1
- package/dist/chunk-7FSDNNNC.js.map +0 -1
- package/dist/chunk-AJA6LUI7.js.map +0 -1
- package/dist/chunk-FQGX2PA2.js.map +0 -1
- package/dist/chunk-GQCOSXMG.js.map +0 -1
- package/dist/chunk-HBVFFBRR.cjs.map +0 -1
- package/dist/chunk-HDP7VK3C.cjs.map +0 -1
- package/dist/chunk-HVQFNJKE.cjs.map +0 -1
- package/dist/chunk-IF532O7C.js.map +0 -1
- package/dist/chunk-JMXUNXQS.cjs.map +0 -1
- package/dist/chunk-KV7UW6T6.js.map +0 -1
- package/dist/chunk-NG2JHZHE.js.map +0 -1
- package/dist/chunk-O3ANBHSA.js.map +0 -1
- package/dist/chunk-PA4VC73I.cjs.map +0 -1
- package/dist/chunk-PFUESQTW.cjs.map +0 -1
- package/dist/chunk-R3PY4G7J.js.map +0 -1
- package/dist/chunk-R7YVBHCV.cjs.map +0 -1
- package/dist/chunk-SESSWASV.cjs.map +0 -1
- package/dist/chunk-TY3TLZAW.cjs.map +0 -1
- package/dist/chunk-UM6BVY2S.cjs.map +0 -1
- package/dist/chunk-UQ3UIZJC.js.map +0 -1
- package/dist/chunk-VB37OC6I.js.map +0 -1
- package/dist/chunk-Y7FT4IQT.js.map +0 -1
- package/dist/chunk-YXCTLWOH.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors/EngineError.ts","../src/errors/Result.ts","../src/errors/ErrorCode.ts"],"names":["ErrorCategory"],"mappings":";;;AA6BO,IAAK,aAAA,qBAAAA,cAAAA,KAAL;AAEL,EAAAA,eAAA,SAAA,CAAA,GAAU,SAAA;AAEV,EAAAA,eAAA,WAAA,CAAA,GAAY,WAAA;AAEZ,EAAAA,eAAA,YAAA,CAAA,GAAa,YAAA;AAEb,EAAAA,eAAA,UAAA,CAAA,GAAW,UAAA;AAEX,EAAAA,eAAA,UAAA,CAAA,GAAW,UAAA;AAEX,EAAAA,eAAA,QAAA,CAAA,GAAS,QAAA;AAZC,EAAA,OAAAA,cAAAA;AAAA,CAAA,EAAA,aAAA,IAAA,EAAA;AAmEL,IAAM,WAAA,GAAN,MAAM,YAAA,SAAoB,KAAA,CAAM;AAAA,EAsBrC,WAAA,CAAY,UAAyB,IAAA,EAAuB;AAC1D,IAAA,KAAA,CAAM,KAAK,OAAO,CAAA;AAClB,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AACZ,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAChB,IA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EAEjC,8BAAA,EAAgC,gCAAA;AAAA;AAAA,EAEhC,uBAAA,EAAyB,yBAAA;AAAA;AAAA,EAGzB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,sBAAA,EAAwB,wBAAA;AAAA;AAAA,EAExB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,+BAAA,EAAiC,iCAAA;AAAA;AAAA,EAEjC,6BAAA,EAA+B,+BAAA;AAAA;AAAA,EAE/B,2BAAA,EAA6B,6BAAA;AAAA;AAAA,EAE7B,oBAAA,EAAsB,sBAAA;AAAA;AAAA,EAGtB,qBAAA,EAAuB,uBAAA;AAAA,EACvB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,yBAAA,EAA2B,2BAAA;AAAA;AAAA,EAG3B,yBAAA,EAA2B,2BAAA;AAAA,EAC3B,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,qBAAA,EAAuB,uBAAA;AAAA;AAAA,EAEvB,+BAAA,EAAiC,iCAAA;AAAA;AAAA,EAEjC,oCAAA,EAAsC,sCAAA;AAAA;AAAA,EAEtC,qBAAA,EAAuB,uBAAA;AAAA;AAAA,EAEvB,oCAAA,EAAsC,sCAAA;AAAA;AAAA,EAGtC,iBAAA,EAAmB,mBAAA;AAAA,EACnB,qBAAA,EAAuB,uBAAA;AAAA;AAAA,EAGvB,gBAAA,EAAkB,kBAAA;AAAA,EAClB,aAAA,EAAe;AACjB","file":"chunk-5KMIY374.cjs","sourcesContent":["/**\n * The engine's structured error type, the \"Rust/Go-style, verbose, easy to\n * tell the issue\" half of the error-handling redesign (the other half is\n * `Result.ts`).\n *\n * Historical note: an earlier version of this class (`UnifiedErrorFramework.ts`,\n * still the import path most of the codebase uses. See that file, now a\n * pure re-export barrel) had a much larger field set (`severity`,\n * `recovery`, a 5-value enum, `ErrorRecoveryManager`) that was almost\n * entirely dead: nothing downstream ever read `.severity`/`.recovery`,\n * only `.message` reliably survived to a caller. This version is smaller\n * and deliberately keeps only fields something actually consumes.\n */\n\nimport type { ErrorCode } from \"@solve-js/errors/ErrorCode\";\n\n/** A character-offset (and optional line/col) span into the original expression text, for a future \"underline the offending token\" UI, not yet wired to one. */\nexport interface SourceSpan {\n start: number;\n end: number;\n line?: number;\n col?: number;\n}\n\n/**\n * Error classification, kept from the original framework, now actually\n * consulted: it's the `format()` header and lets host code group errors\n * by pipeline stage without string-matching `.code`.\n */\nexport enum ErrorCategory {\n /** Errors during expression parsing. */\n PARSING = \"PARSING\",\n /** Errors during bytecode execution. */\n EXECUTION = \"EXECUTION\",\n /** Errors from input validation (safety limits, config). */\n VALIDATION = \"VALIDATION\",\n /** Errors from external services/APIs (currency rates, weather, stocks). */\n EXTERNAL = \"EXTERNAL\",\n /** Internal engine invariant violations. See `recoverable`'s doc comment. */\n INTERNAL = \"INTERNAL\",\n /** Configuration errors. */\n CONFIG = \"CONFIG\",\n}\n\n/** Fields accepted when constructing an {@link EngineError}. */\nexport interface EngineErrorInit {\n /** Catalog code. See `errors/ErrorCode.ts`. Not a free string: every code used by a BUILT-IN package should be registered there so `ErrorCodeCatalog.spec.ts` can catch collisions/typos. Third-party packages may still use any string here, `EngineError.code`'s runtime type is `string`. */\n code: ErrorCode | (string & {});\n /** Short, single-line, `Error.message`-compatible. Existing `.toThrow(/pattern/)`/`.message` assertions keep working against this field, richer detail goes in `expected`/`found`/`suggestion`, not crammed into this string. */\n message: string;\n /** What the parser/validator/VM expected to see, in plain words, e.g. \"a city name\", \"a 4-digit year\", \"end of expression\". */\n expected?: string;\n /** What was actually found instead, e.g. \"end of expression\", `NUMBER \"5\"`, the offending token's literal text. */\n found?: string;\n /** An actionable, worked-example fix, e.g. `e.g. \"weather in London\"`. Mirrors this codebase's best existing messages (`WEATHER_EXPECTED_CITY`, `AS_CONVERTER_EXPECTED_NAME`). */\n suggestion?: string;\n /**\n * Whether this engine instance is still usable. `true` for everything that\n * went wrong on ONE line, whether the line's fault (bad syntax, an unknown\n * variable, a safety limit exceeded), the environment's (an external API\n * down), or the engine's own (corrupted bytecode, a stack underflow from a\n * buggy plugin). `false` is for the far rarer case where there is no working\n * engine to go on with: a configuration or package-registration failure,\n * which is what `ErrorFactory.config()` is for and the only factory method\n * that still defaults to it.\n *\n * The category answers a different question, and the two used to be answered\n * as one. Category INTERNAL says whose fault this is, the engine's, worth\n * reporting as a bug. `recoverable` says whether the host may carry on, and\n * after an internal slip on one line it may:\n * `__tests__/hardening/RobustnessEngineLifecycle.spec.ts` alternates a\n * throwing line with a good one five hundred times and every answer stays\n * correct. Reporting that as `isFatal()` told a host the opposite, and a host\n * that honours the name would tear a document down over one bad line.\n *\n * This has never gated \"does evaluation of the rest of the document\n * continue\"; with this engine's per-line containment it always does, even for\n * a `recoverable: false` error (see `ARCHITECTURE.md`'s async-batcher/Tier-2\n * hardening notes). It gates what a host is TOLD. See\n * {@link EngineError.isFatal}.\n */\n recoverable?: boolean;\n /** Character-offset span into the source expression, when available. Not yet threaded through every call site, populate opportunistically, don't block on retrofitting every existing throw site. */\n span?: SourceSpan;\n /** Free-form structured context. The one field the pre-existing framework's real consumer (`ThreeTierEvaluator.ts`'s DAG-preservation-on-compile-error path) actually reads, kept name- and shape-compatible on purpose. */\n context?: Record<string, unknown>;\n /** The underlying error this one wraps, if any, passed straight through to native `Error.cause` (ES2022), so Node's default printer, most loggers, and `instanceof Error` tooling understand the chain for free. */\n cause?: unknown;\n}\n\n/**\n * The engine's structured error type. Still a real `Error` subclass (so\n * `throw`/`catch`/`instanceof Error` all keep working exactly as before),\n * but now every field except the removed `severity`/`recovery` pair is\n * something real code reads.\n */\nexport class EngineError extends Error {\n readonly category: ErrorCategory;\n readonly code: string;\n readonly expected?: string;\n readonly found?: string;\n readonly suggestion?: string;\n readonly recoverable: boolean;\n readonly span?: SourceSpan;\n readonly context?: Record<string, unknown>;\n readonly timestamp: Date;\n /**\n * Set explicitly (not via `super(message, {cause})`). This repo's\n * `tsconfig.json` targets ES6/ES5-ES7 lib, which predates TypeScript's\n * ES2022 `Error` constructor `cause`-option overload. `Error.prototype.cause`\n * is still a real runtime feature in every target this engine actually\n * runs in (Node 16.9+, all evergreen browsers, Electron/Obsidian's\n * bundled Chromium) regardless of the TS lib target used to type-check\n * against it, assigning it directly gets the same Node-printer/logger\n * interop with no build-config change needed.\n */\n readonly cause?: unknown;\n\n constructor(category: ErrorCategory, init: EngineErrorInit) {\n super(init.message);\n this.name = \"EngineError\";\n this.category = category;\n this.code = init.code;\n this.expected = init.expected;\n this.found = init.found;\n this.suggestion = init.suggestion;\n this.recoverable = init.recoverable ?? true;\n this.span = init.span;\n this.context = init.context;\n this.cause = init.cause;\n this.timestamp = new Date();\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, EngineError);\n }\n }\n\n /** `!recoverable`. See `EngineErrorInit.recoverable`'s doc comment for what this actually gates (message framing/telemetry, not whether evaluation continues). */\n isFatal(): boolean {\n return !this.recoverable;\n }\n\n /** Walk `.cause` repeatedly, collecting the full chain (this error first). */\n causeChain(): unknown[] {\n const chain: unknown[] = [this];\n let current: unknown = this.cause;\n while (current !== undefined && current !== null) {\n chain.push(current);\n current = current instanceof Error ? (current as Error & { cause?: unknown }).cause : undefined;\n }\n return chain;\n }\n\n /**\n * Rust/Go-style multi-line renderer, the NEW thing a host/CLI/test\n * reaches for when it wants the full, verbose picture, as distinct from\n * `.message` (kept short and stable for existing assertions). Example:\n *\n * ```\n * error[WEATHER_EXPECTED_CITY]: Expected a city name after \"weather in\"\n * expected: a city name\n * found: end of expression\n * suggestion: e.g. \"weather in London\"\n * ```\n */\n format(): string {\n const lines = [`error[${this.code}]: ${this.message}`];\n if (this.expected) lines.push(` expected: ${this.expected}`);\n if (this.found) lines.push(` found: ${this.found}`);\n if (this.suggestion) lines.push(` suggestion: ${this.suggestion}`);\n return lines.join(\"\\n\");\n }\n\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n category: this.category,\n code: this.code,\n message: this.message,\n expected: this.expected,\n found: this.found,\n suggestion: this.suggestion,\n recoverable: this.recoverable,\n span: this.span,\n context: this.context,\n timestamp: this.timestamp.toISOString(),\n };\n }\n}\n\n/**\n * Factory for creating classified `EngineError`s. Every method accepts\n * EITHER the original, minimal 3-arg shape (`code, message, context?`\n * every existing call site across the codebase keeps compiling unchanged)\n * OR the richer `EngineErrorInit` object (for `expected`/`found`/\n * `suggestion`/`recoverable`/`span`/`cause`), upgrade a call site to the\n * richer form only when you're already touching it, no separate churn\n * pass required.\n */\nexport class ErrorFactory {\n private static build(\n category: ErrorCategory,\n defaultRecoverable: boolean,\n codeOrInit: string | EngineErrorInit,\n message?: string,\n context?: Record<string, unknown>,\n ): EngineError {\n const init: EngineErrorInit =\n typeof codeOrInit === \"string\"\n ? { code: codeOrInit, message: message!, context }\n : codeOrInit;\n return new EngineError(category, { recoverable: defaultRecoverable, ...init });\n }\n\n static validation(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static validation(init: EngineErrorInit): EngineError;\n static validation(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.VALIDATION, true, codeOrInit, message, context);\n }\n\n static parsing(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static parsing(init: EngineErrorInit): EngineError;\n static parsing(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.PARSING, true, codeOrInit, message, context);\n }\n\n static execution(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static execution(init: EngineErrorInit): EngineError;\n static execution(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.EXECUTION, true, codeOrInit, message, context);\n }\n\n static external(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static external(init: EngineErrorInit): EngineError;\n static external(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.EXTERNAL, true, codeOrInit, message, context);\n }\n\n /**\n * Reserve for genuine engine-internal invariant violations (corrupted\n * bytecode, a stack underflow from a buggy plugin, an \"impossible\" state),\n * not for user-input errors: the category is a bug report.\n *\n * Defaults `recoverable: true` all the same, because every one of these sites\n * is an invariant that failed on ONE line and none of them leaves the engine\n * unusable. This used to default to `false`, which conflated \"the engine's\n * fault\" with \"the engine is finished\" and told a host to tear a document\n * down over a line it could simply have shown an error against. A site that\n * has looked at its own case and concluded the instance really is gone can\n * still pass `recoverable: false` explicitly. See {@link\n * EngineErrorInit.recoverable}.\n */\n static internal(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static internal(init: EngineErrorInit): EngineError;\n static internal(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.INTERNAL, true, codeOrInit, message, context);\n }\n\n /** Defaults `recoverable: false`, and is now the only method that does: a configuration or package-registration failure is the one class that leaves no working engine to carry on with, rather than one bad line in a document. */\n static config(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static config(init: EngineErrorInit): EngineError;\n static config(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.CONFIG, false, codeOrInit, message, context);\n }\n}\n\n/**\n * Normalize any thrown value into an `EngineError`, an `EngineError`\n * passes through as-is; a plain `Error` gets wrapped (message preserved,\n * original attached via `cause`); anything else becomes a generic\n * \"unknown error\" wrapping the stringified value. Used at every\n * throw-space/Result-space boundary (`Result.tryCatch`'s default\n * `normalize`, the VM's outer execution try/catch, `AsyncResolutionBatcher`'s\n * per-line containment) so a raw `TypeError` from a genuine engine bug\n * still surfaces as a structured, catalogued error instead of an opaque\n * uncaught exception.\n *\n * Both branches state RECOVERABLE explicitly, while keeping the INTERNAL\n * category. The two fields answer different questions and were previously\n * answering the same one:\n *\n * category INTERNAL whose fault is this? The engine's. Worth reporting.\n * recoverable is this engine instance still usable? Yes.\n *\n * Everything reaching here is by definition something the engine did not\n * anticipate on ONE line, and per-line containment means the next line\n * evaluates normally, which `__tests__/hardening/RobustnessEngineLifecycle`\n * demonstrates over hundreds of alternating failure/success pairs. Reporting\n * that as `isFatal()` told a host the opposite, and a host that honours the\n * name would tear a document down over a single bad line. The \"this is an\n * engine bug rather than your syntax\" signal a caller wants for telemetry is\n * the CATEGORY, which is unchanged.\n *\n * The flag is written out here rather than inherited from\n * `ErrorFactory.internal()`, which now defaults the same way, so that this\n * function's contract survives a future change to that default.\n */\nexport function normalizeUnknownError(error: unknown): EngineError {\n if (error instanceof EngineError) return error;\n if (error instanceof Error) {\n return ErrorFactory.internal({\n code: \"UNEXPECTED_ERROR\",\n message: error.message,\n context: { originalErrorName: error.name },\n cause: error,\n recoverable: true,\n });\n }\n return ErrorFactory.internal({\n code: \"UNKNOWN_ERROR\",\n message: \"An unknown error occurred\",\n context: { error: String(error) },\n recoverable: true,\n });\n}\n","import { type EngineError, normalizeUnknownError } from \"@solve-js/errors/EngineError\";\n\n/**\n * A Rust-style `Result<T, E>`, the value half of this engine's error-handling\n * redesign. `E` defaults to `EngineError` (this engine's structured error\n * type) but every combinator here is generic over `E`, so `Result` works\n * equally well for a domain that isn't `EngineError`-shaped.\n *\n * This exact shape used to live in `errors/UnifiedErrorFramework.ts` (kept\n * there as a barrel re-export for backward compatibility), moved here as\n * its own module because it's genuinely generic (no dependency on\n * `EngineError` beyond the default type parameter) and because the engine\n * is migrating callers to it incrementally: parsing/VM/package code that\n * expects \"a failure is a possibility, not an exception\" returns\n * `Result<T, EngineError>` instead of throwing; two explicit adapters\n * {@link throwIfErr} and {@link tryCatch}, are the sanctioned way to cross\n * the boundary between Result-based code and still-throw-based code during\n * the migration (and permanently, at the public API boundary. See\n * `ExpressionEngine.evaluateExpression()`'s documented throw contract).\n */\nexport type Result<T, E = EngineError> =\n | { ok: true; value: T }\n | { ok: false; error: E };\n\n/** Wrap a successful value. */\nexport function ok<T>(value: T): Result<T, never> {\n return { ok: true, value };\n}\n\n/** Wrap a failure. */\nexport function err<E>(error: E): Result<never, E> {\n return { ok: false, error };\n}\n\n/**\n * Narrow a {@link Result} to its success arm.\n *\n * @param r - The result to test.\n * @returns True when it succeeded, narrowing `r` so `r.value` is reachable.\n */\nexport function isOk<T, E>(r: Result<T, E>): r is { ok: true; value: T } {\n return r.ok;\n}\n\n/**\n * Narrow a {@link Result} to its failure arm.\n *\n * @param r - The result to test.\n * @returns True when it failed, narrowing `r` so `r.error` is reachable.\n */\nexport function isErr<T, E>(r: Result<T, E>): r is { ok: false; error: E } {\n return !r.ok;\n}\n\n/** Transform the success value; a failure passes through untouched. */\nexport function map<T, U, E>(r: Result<T, E>, fn: (value: T) => U): Result<U, E> {\n return r.ok ? ok(fn(r.value)) : r;\n}\n\n/** Transform the error; a success passes through untouched. */\nexport function mapErr<T, E, F>(r: Result<T, E>, fn: (error: E) => F): Result<T, F> {\n return r.ok ? r : err(fn(r.error));\n}\n\n/** Chain a Result-returning operation onto a success (a.k.a. flatMap/bind). */\nexport function andThen<T, U, E>(r: Result<T, E>, fn: (value: T) => Result<U, E>): Result<U, E> {\n return r.ok ? fn(r.value) : r;\n}\n\n/** Unwrap a success, or return `fallback` for a failure. Never throws. */\nexport function unwrapOr<T, E>(r: Result<T, E>, fallback: T): T {\n return r.ok ? r.value : fallback;\n}\n\n/** Exhaustive pattern-match, the `match`/`switch` a Rust enum gets for free. */\nexport function match<T, E, R>(r: Result<T, E>, arms: { ok: (value: T) => R; err: (error: E) => R }): R {\n return r.ok ? arms.ok(r.value) : arms.err(r.error);\n}\n\n/**\n * Combine several Results into one, succeeds with a tuple of all values\n * iff every input succeeded; otherwise fails with the FIRST error\n * encountered (left-to-right), matching this codebase's existing\n * fail-fast convention elsewhere (e.g. `BytecodeBuilder`'s constant-pool\n * limit checks).\n */\nexport function combine<T extends readonly unknown[], E>(\n results: { [K in keyof T]: Result<T[K], E> },\n): Result<T, E> {\n const values: unknown[] = [];\n for (const r of results as readonly Result<unknown, E>[]) {\n if (!r.ok) return r;\n values.push(r.value);\n }\n return ok(values as unknown as T);\n}\n\n/**\n * Cross from Result-space back to throw-space, the sanctioned boundary\n * adapter for callers (public API surface, older not-yet-migrated code,\n * tests) that still want exception-based control flow. Throws `r.error`\n * as-is (an `EngineError` is already a real `Error` subclass, so this\n * needs no wrapping).\n */\nexport function throwIfErr<T, E>(r: Result<T, E>): T {\n if (r.ok) return r.value;\n throw r.error;\n}\n\n/**\n * Cross from throw-space into Result-space, runs `fn`, converting any\n * thrown value into a Result via `normalize` (defaults to\n * {@link normalizeUnknownError}). The inverse of {@link throwIfErr}; the\n * pairing that lets Result-based and throw-based code interoperate during\n * an incremental migration instead of requiring a single flag-day rewrite.\n */\nexport function tryCatch<T>(\n fn: () => T,\n normalize: (e: unknown) => EngineError = normalizeUnknownError,\n): Result<T, EngineError> {\n try {\n return ok(fn());\n } catch (e) {\n return err(normalize(e));\n }\n}\n\n/** Async sibling of {@link tryCatch}. */\nexport async function tryCatchAsync<T>(\n fn: () => Promise<T>,\n normalize: (e: unknown) => EngineError = normalizeUnknownError,\n): Promise<Result<T, EngineError>> {\n try {\n return ok(await fn());\n } catch (e) {\n return err(normalize(e));\n }\n}\n","/**\n * The built-in error-code catalog, one typed const object per domain\n * unioned together here for autocomplete/exhaustiveness in core engine\n * code. Deliberately NOT one central enum: `IEnginePackage` is documented\n * public SDK surface for third-party packages (see `api/PackageRegistry.ts`),\n * and a closed enum would block an external package author from defining\n * their own codes without editing this file. `EngineError.code`'s runtime\n * type stays `string` for exactly that reason. This catalog is for the\n * codes THIS repo owns and wants collision/typo checking on (see\n * `__tests__/errors/ErrorCodeCatalog.spec.ts`), not a hard runtime\n * whitelist.\n *\n * As each package migrates to `Result<void, EngineError>` (see this\n * session's error-handling-refactor plan, Phase 5), it should export its\n * own small `XxxErrorCodes` const object co-located with its parselets\n * exactly like `CoreErrorCodes` below, just scoped to one domain, and get\n * unioned into `ErrorCode` here. Until a package migrates, its existing\n * free-string codes keep working (ErrorFactory accepts any string); they\n * just aren't caught by the catalog's uniqueness/orphan checks yet.\n */\n\n/**\n * Codes used directly by the parser/VM/engine/errors layers themselves\n * confirmed against the current source, not aspirational. Grouped by\n * pipeline stage via the comments, not a naming prefix (these predate any\n * naming convention and renaming them is out of scope for introducing the\n * catalog, only NEW codes need to follow a scoped/prefixed style, see\n * `STACK_UNDERFLOW` etc. below).\n */\nexport const CoreErrorCodes = {\n // ── Parser (parser/PrecedenceParser.ts, parser/BytecodeBuilder.ts, parser/PhrasePattern.ts) ──\n INVALID_NUMBER_LITERAL: \"INVALID_NUMBER_LITERAL\",\n /** A `\"` that never meets its closing partner (`lexer/ExpressionLexer.ts`'s `tokenizeString()`). Previously the tokenizer ran off the end of the input and returned what it had, so `\"abc` lexed to an ordinary String and an unterminated literal was indistinguishable from a terminated one. */\n UNTERMINATED_STRING: \"UNTERMINATED_STRING\",\n NO_PREFIX_PARSELET: \"NO_PREFIX_PARSELET\",\n UNEXPECTED_END_OF_INPUT: \"UNEXPECTED_END_OF_INPUT\",\n UNEXPECTED_TOKEN_TYPE: \"UNEXPECTED_TOKEN_TYPE\",\n NESTING_DEPTH_EXCEEDED: \"NESTING_DEPTH_EXCEEDED\",\n UNEXPECTED_END: \"UNEXPECTED_END\",\n UNEXPECTED_TRAILING_TOKEN: \"UNEXPECTED_TRAILING_TOKEN\",\n PARSE_ERROR: \"PARSE_ERROR\",\n TOO_MANY_NUMERIC_CONSTANTS: \"TOO_MANY_NUMERIC_CONSTANTS\",\n TOO_MANY_STRING_CONSTANTS: \"TOO_MANY_STRING_CONSTANTS\",\n NO_MATCHING_PHRASE_ALTERNATIVE: \"NO_MATCHING_PHRASE_ALTERNATIVE\",\n INVALID_PHRASE_PATTERN: \"INVALID_PHRASE_PATTERN\",\n PHRASE_KEYWORD_MISMATCH: \"PHRASE_KEYWORD_MISMATCH\",\n /** User-defined-function definition parsing (`f(x, y) = ...`), an invalid token where a parameter name was expected. */\n USER_FUNCTION_INVALID_PARAM_NAME: \"USER_FUNCTION_INVALID_PARAM_NAME\",\n /** `f() = ...` with zero parameters, indistinguishable from a plain no-arg function call, so rejected at definition time. */\n USER_FUNCTION_NO_PARAMS: \"USER_FUNCTION_NO_PARAMS\",\n /** A user-defined function body calling an async plugin (weather/stocks/currency/...), rejected at definition time; v1 scope excludes async function bodies. */\n FUNCTION_BODY_MUST_BE_SYNCHRONOUS: \"FUNCTION_BODY_MUST_BE_SYNCHRONOUS\",\n /** `BytecodeBuilder`'s `userFunctionBodies` side-table exceeding its capacity. Same class as `TOO_MANY_NUMERIC_CONSTANTS`/`TOO_MANY_STRING_CONSTANTS` below. */\n TOO_MANY_FUNCTION_DEFINITIONS: \"TOO_MANY_FUNCTION_DEFINITIONS\",\n /** `BytecodeBuilder`'s `anonymousBodies` side-table (map/reduce inline transform bodies) exceeding its capacity. Same class as `TOO_MANY_FUNCTION_DEFINITIONS` above. */\n TOO_MANY_ANONYMOUS_BODIES: \"TOO_MANY_ANONYMOUS_BODIES\",\n\n // ── VM (vm/VM.ts, vm/OpRegistry.ts, vm/VMBuiltins.ts) ──\n EVALUATION_ERROR: \"EVALUATION_ERROR\",\n INSTRUCTION_LIMIT_EXCEEDED: \"INSTRUCTION_LIMIT_EXCEEDED\",\n STACK_LIMIT_EXCEEDED: \"STACK_LIMIT_EXCEEDED\",\n /** One evaluation asking for more elements (collection Values, matrix cells) than `vm.maxAllocatedElements` allows. The counter the two limits above cannot be: both are checked between opcodes, so neither can see what a single opcode allocates inside a loop of its own. See `vm/AllocationBudget.ts`. Recoverable, since it describes this expression rather than the engine. */\n ALLOCATION_LIMIT_EXCEEDED: \"ALLOCATION_LIMIT_EXCEEDED\",\n /** New this phase. See `VM.ts`'s `safePop()`: a stack-underflow (corrupted bytecode, a buggy plugin) is now a controlled EngineError instead of a raw TypeError. Category INTERNAL, since it is an engine or plugin fault rather than a typed line, but recoverable: it happened on one line and the engine is still usable. */\n STACK_UNDERFLOW: \"STACK_UNDERFLOW\",\n UNDEFINED_VARIABLE: \"UNDEFINED_VARIABLE\",\n /** New this phase, the Tier-2/`LOAD_GLOBAL_VAR` hardening: a global variable read before its async preflight resolved, surfaced as a controlled error instead of pushing `undefined`. */\n GLOBAL_VARIABLE_NOT_RESOLVED: \"GLOBAL_VARIABLE_NOT_RESOLVED\",\n UNKNOWN_FUNCTION: \"UNKNOWN_FUNCTION\",\n /** `unwrapEvalResult()`'s pending-when-expecting-value case, a caller-contract violation, not user-input. */\n UNEXPECTED_PENDING_RESULT: \"UNEXPECTED_PENDING_RESULT\",\n /** User-defined-function call/definition errors (`CALL_USER_FUNCTION`/`DEFINE_USER_FUNCTION` opcodes), calling a name with no matching definition, calling with the wrong argument count, and the deliberate v1 restriction that a function body can't itself contain async work. */\n UNDEFINED_FUNCTION: \"UNDEFINED_FUNCTION\",\n FUNCTION_ARITY_MISMATCH: \"FUNCTION_ARITY_MISMATCH\",\n /** The same mistake against a BUILT-IN rather than a user-defined function (`sqrt()`, `atan2(1)`, `sqrt(1,2,3)`). Separate from `FUNCTION_ARITY_MISMATCH` above because the two are raised by different opcodes and a host may want to word them differently. Checked at the `CALL_BUILTIN` dispatch against `vm/VMBuiltinArity.ts`; recoverable, since it is a typo in the line, not an engine fault. */\n BUILTIN_ARITY_MISMATCH: \"BUILTIN_ARITY_MISMATCH\",\n USER_FUNCTION_ASYNC_UNSUPPORTED: \"USER_FUNCTION_ASYNC_UNSUPPORTED\",\n /** A map/reduce transform body (inline expression or user-defined function) calling an async plugin. Same v1 scope restriction as `USER_FUNCTION_ASYNC_UNSUPPORTED` above, enforced both at parse time (`MAP_REDUCE_TRANSFORM_MUST_BE_SYNCHRONOUS`, packages/mapreduce/) and as a defense-in-depth runtime backstop here. */\n MAP_REDUCE_ASYNC_UNSUPPORTED: \"MAP_REDUCE_ASYNC_UNSUPPORTED\",\n /** An algebra verb's expression argument (`BIND_UNKNOWN`'s body) calling an async plugin. Same v1 scope restriction as the two above, and likewise refused at parse time first (`SYMBOLIC_ARGUMENT_MUST_BE_SYNCHRONOUS`, packages/symbolic/). */\n SYMBOLIC_ASYNC_UNSUPPORTED: \"SYMBOLIC_ASYNC_UNSUPPORTED\",\n /** `pushCallFrame()`'s recursion guard, a nested `CALL_USER_FUNCTION` re-enters `executeBytecode()`, so `maxInstructions` alone can't catch e.g. `f(x) = f(x)`; this is the dedicated backstop. `recoverable: true` (the default for `.execution()`), ordinary user-written infinite recursion, not an engine bug; the guard exists precisely so it surfaces as a clear error instead of overflowing the native call stack uncatchably. */\n FUNCTION_RECURSION_LIMIT_EXCEEDED: \"FUNCTION_RECURSION_LIMIT_EXCEEDED\",\n /** The companion to the code above, and the half it could never see: how MANY user-defined-function calls one evaluation makes, rather than how deeply they nest. A twenty-two-line doubling chain nests twenty-two deep (legal) and makes two million calls (a fatal heap abort). Counted in `vm/AllocationBudget.ts`, because the tally has to survive `executeBytecode()` re-entering itself. Recoverable. */\n FUNCTION_CALL_LIMIT_EXCEEDED: \"FUNCTION_CALL_LIMIT_EXCEEDED\",\n /** A `<date> + N workdays` offset outside `date.maxOffsetYears`/`minOffsetYears`. Workdays are the one date offset that walks the calendar a day at a time, so the one whose cost is the offset; every other one moves a Date field once. Recoverable. */\n DATE_OFFSET_LIMIT_EXCEEDED: \"DATE_OFFSET_LIMIT_EXCEEDED\",\n /** A `<<`/`>>` with a bigint operand whose exact result would pass `MAX_EXACT_SHIFT_BITS`, whichever operand is the bigint. Both spellings refuse as of 1.0.0: a bigint on the left used to fall through to `x * 2^n` in doubles and report a 19,870-digit integer as Infinity. See `vm/VM.ts`'s `bigIntShift()`. Recoverable. */\n BIGINT_SHIFT_LIMIT_EXCEEDED: \"BIGINT_SHIFT_LIMIT_EXCEEDED\",\n /** The same ceiling for `^`, the operator it was written for: `2n ^ 100000` asks for the same 100,001-bit integer `1n << 100000` does, so the two spellings answer the same way. Also new in 1.0.0, and for the same reason: this used to fall through to the double path and answer Infinity. A fractional or negative exponent (`4n ^ 0.5`, `2n ^ -1`) has no exact answer to bound and still uses the double path. See `vm/VM.ts`'s `MAX_EXACT_POW_BITS`. Recoverable. */\n BIGINT_POW_LIMIT_EXCEEDED: \"BIGINT_POW_LIMIT_EXCEEDED\",\n /** An operand with no whole-number form (a fraction, an infinity, a NaN) meeting a bigint: `1n + 0.5`, `1n & 1.5`, `5n/pi`. `BigInt()` answers those with a raw RangeError, which the VM relabelled UNEXPECTED_ERROR, so a typo in the line was reported as an engine fault. Recoverable; see `vm/VMConversion.ts`'s `toBigIntOperand()`. */\n BIGINT_INEXACT_OPERAND: \"BIGINT_INEXACT_OPERAND\",\n /** `10n / 0n` and `10n mod 0n`. Deliberately NOT what `1 / 0` does, which is Infinity: a bigint division is exact integer division (`7n / 2n` is 3n), and integer division by zero has no answer, exactly as it has none in C, Java, Python or JavaScript's own BigInt. Previously V8's own RangeError, relabelled UNEXPECTED_ERROR. Recoverable; see `vm/VMConversion.ts`'s `bigIntDivisionByZero()`. */\n BIGINT_DIVISION_BY_ZERO: \"BIGINT_DIVISION_BY_ZERO\",\n /** `DEFINE_USER_FUNCTION`'s body-index lookup failing, a compiler/VM invariant violation (the opcode stream referenced a `userFunctionBodies` slot that doesn't exist), never a user-input error. */\n INTERNAL_MISSING_FUNCTION_BODY: \"INTERNAL_MISSING_FUNCTION_BODY\",\n /** `MAP_INVOKE`/`REDUCE_INVOKE`'s anonymous-body-index lookup failing. Same class as `INTERNAL_MISSING_FUNCTION_BODY` above, for the `anonymousBodies` side-table instead of `userFunctionBodies`. */\n INTERNAL_MISSING_ANONYMOUS_BODY: \"INTERNAL_MISSING_ANONYMOUS_BODY\",\n\n // ── Malformed bytecode on the public `./vm` surface (vm/VM.ts) ──\n //\n // `executeBytecode` is exported, so a bytecode program is caller input in\n // the same sense an expression string is, and these five say so. They are\n // VALIDATION rather than INTERNAL for exactly that reason: before they\n // existed, every one of these cases reached a raw TypeError (`BigInt(undefined)`,\n // `code.toUpperCase()` on a boolean, destructuring a program that was not\n // there), which normalised to UNEXPECTED_ERROR and told the caller the\n // engine was broken when their eleven bytes were. Reachable from ordinary\n // source only through a compiler bug, which is why the messages name the\n // opcode and the operand rather than the user's line.\n /** An operand byte read past the end of the stream: the program ends in the middle of an instruction. */\n MALFORMED_BYTECODE_TRUNCATED: \"MALFORMED_BYTECODE_TRUNCATED\",\n /** A constant-pool operand indexing a `numbers`/`strings` entry that does not exist, or that is not of the pool's type. */\n MALFORMED_BYTECODE_CONSTANT_INDEX: \"MALFORMED_BYTECODE_CONSTANT_INDEX\",\n /** A unit or converter name read off the value stack that is not a string. Distinct from the pool case above: the operand is a Value another opcode pushed, not a pool entry. */\n MALFORMED_BYTECODE_OPERAND_TYPE: \"MALFORMED_BYTECODE_OPERAND_TYPE\",\n /** `MAP_INVOKE`/`REDUCE_INVOKE` carrying a body kind other than 0/1/2. Used to fall through every arm with no body and recurse into `executeBytecode(undefined)`. */\n MALFORMED_BYTECODE_BODY_KIND: \"MALFORMED_BYTECODE_BODY_KIND\",\n /** A `PUSH_BIGINT` pool entry that is not a whole number, e.g. `\"1.000\"`. `BigInt()` answers that with a raw SyntaxError. */\n MALFORMED_BYTECODE_BIGINT_LITERAL: \"MALFORMED_BYTECODE_BIGINT_LITERAL\",\n /** `executeBytecode()` called with something that is not a runnable program at all. Checked before the destructure that used to throw outside the function's own try/catch. */\n MALFORMED_BYTECODE_PROGRAM: \"MALFORMED_BYTECODE_PROGRAM\",\n\n // ── Symbolic algebra (symbolic/, vm/SymbolicOps.ts) ──\n /** A coefficient grew past `RATIONAL_MAX_BITS`, e.g. repeated exact elimination multiplying denominators together. */\n SYMBOLIC_RATIONAL_OVERFLOW: \"SYMBOLIC_RATIONAL_OVERFLOW\",\n /** `NaN` or `±Infinity` reaching a symbolic expression, neither of which has an exact rational value. */\n SYMBOLIC_NONFINITE_OPERAND: \"SYMBOLIC_NONFINITE_OPERAND\",\n /** Division by an exactly-zero rational. Exact, unlike the double comparison it replaced, which could not distinguish a true zero from `5.551e-17`. */\n SYMBOLIC_DIVISION_BY_ZERO: \"SYMBOLIC_DIVISION_BY_ZERO\",\n /** A tree exceeding `SYMBOLIC_MAX_NODES` entering the simplifier. */\n SYMBOLIC_NODE_LIMIT_EXCEEDED: \"SYMBOLIC_NODE_LIMIT_EXCEEDED\",\n /** A builtin with no symbolic reading (`min`, `random`, the finance block, ...) applied to an expression still containing an unknown. Returned rather than computing against `toNumber()`'s placeholder zero. */\n SYMBOLIC_UNSUPPORTED_FUNCTION: \"SYMBOLIC_UNSUPPORTED_FUNCTION\",\n /** The rational-root search exceeding `FACTOR_MAX_ROOT_CANDIDATES`. The candidate set is the product of two divisor sets, so a highly-composite coefficient escapes quickly. */\n SYMBOLIC_FACTOR_LIMIT_EXCEEDED: \"SYMBOLIC_FACTOR_LIMIT_EXCEEDED\",\n /** An equation outside what the solver attempts: not a polynomial, above the degree ceiling, or non-linear in the unknown while another unknown is present. */\n SYMBOLIC_SOLVE_UNSUPPORTED: \"SYMBOLIC_SOLVE_UNSUPPORTED\",\n /** Some but not all of an equation's roots were found. Reported rather than returned, because a partial list of roots looks exactly like a complete one. */\n SYMBOLIC_SOLVE_INCOMPLETE: \"SYMBOLIC_SOLVE_INCOMPLETE\",\n /** `solve`'s second argument not being a bare name. */\n SOLVE_REQUIRES_VARIABLE_NAME: \"SOLVE_REQUIRES_VARIABLE_NAME\",\n /** A derivative order outside 0..`DERIVATIVE_MAX_ORDER`. */\n SYMBOLIC_DERIVATIVE_ORDER_LIMIT: \"SYMBOLIC_DERIVATIVE_ORDER_LIMIT\",\n /** An expression with no known elementary antiderivative. Reported rather than approximated, since a wrong integral is indistinguishable from a right one at the point of use. */\n SYMBOLIC_INTEGRAL_UNSUPPORTED: \"SYMBOLIC_INTEGRAL_UNSUPPORTED\",\n /** A Taylor degree outside 0..`TAYLOR_MAX_DEGREE`. */\n SYMBOLIC_TAYLOR_DEGREE_LIMIT: \"SYMBOLIC_TAYLOR_DEGREE_LIMIT\",\n /** A Taylor coefficient that does not reduce to an exact number at the expansion point. */\n SYMBOLIC_TAYLOR_INEXACT: \"SYMBOLIC_TAYLOR_INEXACT\",\n /** An algebra verb's variable-name argument not being a bare name. */\n SYMBOLIC_REQUIRES_VARIABLE_NAME: \"SYMBOLIC_REQUIRES_VARIABLE_NAME\",\n /** `jacobian` called with expressions containing no unknown to differentiate against. */\n SYMBOLIC_JACOBIAN_NO_VARIABLES: \"SYMBOLIC_JACOBIAN_NO_VARIABLES\",\n /** A finite number whose decimal form could not be read back, which the regex covering every `Number.prototype.toString` output should make unreachable. */\n INTERNAL_RATIONAL_PARSE: \"INTERNAL_RATIONAL_PARSE\",\n\n // ── Engine (engine/ExpressionEngine.ts, engine/ExpressionEngineSafety.ts, engine/AsyncResolutionBatcher.ts) ──\n EXPRESSION_TOO_LONG: \"EXPRESSION_TOO_LONG\",\n EXPRESSION_TOO_COMPLEX: \"EXPRESSION_TOO_COMPLEX\",\n /** A document with more lines than `performance.maxDocumentLines`. The per-line limits above bound what one line may ask for and say nothing about how many lines there are; two hundred thousand of `1 + 1` exhausted the heap on the line records alone. Recoverable. */\n DOCUMENT_TOO_LARGE: \"DOCUMENT_TOO_LARGE\",\n NORMALIZED_TOKEN_LIMIT_EXCEEDED: \"NORMALIZED_TOKEN_LIMIT_EXCEEDED\",\n /** `\"=>\"` with nothing before it, needs an expression or variable name to solve/simplify. */\n THEREFORE_REQUIRES_EXPRESSION: \"THEREFORE_REQUIRES_EXPRESSION\",\n /** A `\"=>\"`-triggered expression called an async plugin (weather/stocks/currency). Same v1 scope restriction as user-function/map-reduce bodies. */\n THEREFORE_ASYNC_UNSUPPORTED: \"THEREFORE_ASYNC_UNSUPPORTED\",\n /** Colon-separated numbers that are not a time any clock can show (\"24:00\", \"9:60\", \"100:5\"). Raised by the labeled-line fallback, which used to answer them with whatever stood after the colon. */\n INVALID_TIME_LITERAL: \"INVALID_TIME_LITERAL\",\n\n // ── Config (constants/Configuration.ts) ──\n CONFIG_PATH_NOT_FOUND: \"CONFIG_PATH_NOT_FOUND\",\n INVALID_CONFIG_PATH: \"INVALID_CONFIG_PATH\",\n CONFIG_SECTION_NOT_FOUND: \"CONFIG_SECTION_NOT_FOUND\",\n CONFIG_PROPERTY_NOT_FOUND: \"CONFIG_PROPERTY_NOT_FOUND\",\n\n // ── Package/lexer registration-time collisions (lexer/ExpressionLexer.ts) ──\n PLUGIN_OPERATOR_COLLISION: \"PLUGIN_OPERATOR_COLLISION\",\n PLUGIN_KEYWORD_COLLISION: \"PLUGIN_KEYWORD_COLLISION\",\n PLUGIN_UNIT_COLLISION: \"PLUGIN_UNIT_COLLISION\",\n /** A package's declared `IEnginePackage.engineVersion` semver range doesn't satisfy the running engine's ENGINE_VERSION. See api/EngineVersionCompatibility.ts. */\n PACKAGE_ENGINE_VERSION_MISMATCH: \"PACKAGE_ENGINE_VERSION_MISMATCH\",\n /** A package's declared `IEnginePackage.engineVersion` isn't a parseable semver range at all (a typo in the package's own descriptor). */\n PACKAGE_ENGINE_VERSION_INVALID_RANGE: \"PACKAGE_ENGINE_VERSION_INVALID_RANGE\",\n /** `OpRegistry.allocateOpcode()`'s dynamic opcode pool (started at 201) exhausted, too many packages calling it. */\n OPCODE_POOL_EXHAUSTED: \"OPCODE_POOL_EXHAUSTED\",\n /** `VMBuiltins.allocatePluginFunctionIndex()`'s 0-255 index pool (a single opcode-stream byte) exhausted. */\n PLUGIN_FUNCTION_INDEX_POOL_EXHAUSTED: \"PLUGIN_FUNCTION_INDEX_POOL_EXHAUSTED\",\n\n // ── vm/Value.ts caller-contract violations (check isRateUnit()/isTimecodeUnit() first) ──\n INVALID_RATE_UNIT: \"INVALID_RATE_UNIT\",\n INVALID_TIMECODE_UNIT: \"INVALID_TIMECODE_UNIT\",\n\n // ── errors/EngineError.ts's own fallback normalization ──\n UNEXPECTED_ERROR: \"UNEXPECTED_ERROR\",\n UNKNOWN_ERROR: \"UNKNOWN_ERROR\",\n} as const;\n\n/** Every error code the engine's own layers can produce, from {@link CoreErrorCodes}. */\nexport type CoreErrorCode = (typeof CoreErrorCodes)[keyof typeof CoreErrorCodes];\n\n/**\n * The aggregated catalog type. Currently just `CoreErrorCode`, union in\n * each package's own code-object type here as Phase 5 converts it, e.g.\n * `CoreErrorCode | WeatherErrorCode | StocksErrorCode | ...`.\n */\nexport type ErrorCode = CoreErrorCode;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lexer/Token.ts"],"names":[],"mappings":";;;AA0CO,IAAM,UAAA,GAAa;AAAA,EACxB,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,KAAA,EAAO,OAAA;AAAA,EACP,IAAA,EAAM,MAAA;AAAA,EACN,KAAA,EAAO,OAAA;AAAA,EACP,IAAA,EAAM,MAAA;AAAA,EACN,KAAA,EAAO,OAAA;AAAA,EACP,KAAA,EAAO,OAAA;AAAA,EACP,OAAA,EAAS,SAAA;AAAA,EACT,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,OAAA,EAAS,SAAA;AAAA,EACT,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,QAAA,EAAU,UAAA;AAAA,EACV,QAAA,EAAU,UAAA;AAAA,EACV,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,KAAA,EAAO,OAAA;AAAA,EACP,GAAA,EAAK,KAAA;AAAA,EACL,KAAA,EAAO,OAAA;AAAA,EACP,SAAA,EAAW,WAAA;AAAA,EACX,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,KAAA,EAAO,OAAA;AAAA,EACP,IAAA,EAAM,MAAA;AAAA,EACN,GAAA,EAAK,KAAA;AAAA,EACL,KAAA,EAAO,OAAA;AAAA,EACP,GAAA,EAAK,KAAA;AAAA,EACL,QAAA,EAAU,UAAA;AAAA,EACV,IAAA,EAAM,MAAA;AAAA,EACN,OAAA,EAAS,SAAA;AAAA,EACT,MAAA,EAAQ,QAAA;A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AA,EAAM,MAAA;AAAA;AAAA;AAAA;AAAA,EAIN,QAAA,EAAU,UAAA;AAAA;AAAA;AAAA;AAAA,EAIV,cAAA,EAAgB,gBAAA;AAAA,EAChB,kBAAA,EAAoB,oBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKpB,WAAA,EAAa,aAAA;AAAA,EACb,SAAA,EAAW,WAAA;AAAA,EACX,aAAA,EAAe;AACjB;AAcA,IAAI,gBAAA,GAAmB,CAAA;AAGvB,IAAM,kBAAA,uBAAyB,GAAA,EAAoB;AAGnD,IAAM,kBAAA,uBAAyB,GAAA,EAAoB;AAO5C,SAAS,kBAAkB,IAAA,EAAsB;AACvD,EAAA,MAAM,QAAA,GAAW,kBAAA,CAAmB,GAAA,CAAI,IAAI,CAAA;AAC5C,EAAA,IAAI,QAAA,KAAa,QAAW,OAAO,QAAA;AACnC,EAAA,MAAM,EAAA,GAAK,gBAAA,EAAA;AACX,EAAA,kBAAA,CAAmB,GAAA,CAAI,MAAM,EAAE,CAAA;AAC/B,EAAA,kBAAA,CAAmB,GAAA,CAAI,IAAI,IAAI,CAAA;AAC/B,EAAA,OAAO,EAAA;AACR;AAQO,SAAS,YAAY,IAAA,EAAsB;AACjD,EAAA,OAAO,kBAAkB,IAAI,CAAA;AAC9B;AAMO,SAAS,cAAc,EAAA,EAAoB;AACjD,EAAA,OAAO,kBAAA,CAAmB,GAAA,CAAI,EAAE,CAAA,IAAK,WAAW,EAAE,CAAA,CAAA;AACnD;AAMO,SAAS,qBAAA,GAA8B;AAC7C,EAAA,KAAA,MAAW,IAAA,IAAQ,MAAA,CAAO,MAAA,CAAO,UAAU,CAAA,EAAG;AAC7C,IAAA,iBAAA,CAAkB,IAAI,CAAA;AAAA,EACvB;AACD","file":"chunk-5LI5EPGJ.cjs","sourcesContent":["/**\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 STAR: \"STAR\",\n SLASH: \"SLASH\",\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 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 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 // 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 // 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 // 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} 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"]}
|