solve-engine 1.0.0-beta.2 → 1.0.0-beta.4
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/{Lexer-D9l4Yrk2.d.ts → Lexer-Cfm79Dak.d.cts} +18 -2
- package/dist/{Lexer-BJdhlnej.d.cts → Lexer-W9MBOP0V.d.ts} +18 -2
- package/dist/{PackageRegistry-DaH4aIKP.d.ts → PackageRegistry-CjDt-Jy_.d.ts} +60 -4
- package/dist/{PackageRegistry-D-Tv_7ca.d.cts → PackageRegistry-pHtKythi.d.cts} +60 -4
- package/dist/{Parselet-CK8cQu2a.d.cts → Parselet-Cu0bLSis.d.cts} +1 -1
- package/dist/{Parselet-ConOIdRO.d.ts → Parselet-DEdF9I7n.d.ts} +1 -1
- package/dist/{Token-0jpvUdPY.d.cts → Token-BzG5G4ja.d.cts} +44 -0
- package/dist/{Token-0jpvUdPY.d.ts → Token-BzG5G4ja.d.ts} +44 -0
- package/dist/TokenNormalizer-DGVa24Q-.d.cts +377 -0
- package/dist/TokenNormalizer-t_GotBxr.d.ts +377 -0
- package/dist/{chunk-HWSZJQCI.js → chunk-2CS6OMZK.js} +37 -15
- package/dist/chunk-2CS6OMZK.js.map +1 -0
- package/dist/{chunk-XJCMXB2E.cjs → chunk-2MV4HBKC.cjs} +187 -61
- package/dist/chunk-2MV4HBKC.cjs.map +1 -0
- package/dist/{chunk-J73SJHR3.cjs → chunk-2NPS5DQ3.cjs} +558 -341
- package/dist/chunk-2NPS5DQ3.cjs.map +1 -0
- package/dist/{chunk-QWY3VEZN.js → chunk-3MNKQZ77.js} +65 -12
- package/dist/chunk-3MNKQZ77.js.map +1 -0
- package/dist/{chunk-RZCWSXTA.cjs → chunk-43G3JT2E.cjs} +1491 -218
- package/dist/chunk-43G3JT2E.cjs.map +1 -0
- package/dist/{chunk-WQTTOGXC.cjs → chunk-4AVD7NZW.cjs} +4 -4
- package/dist/{chunk-WQTTOGXC.cjs.map → chunk-4AVD7NZW.cjs.map} +1 -1
- package/dist/{chunk-HTXVVJRA.cjs → chunk-4CVLFLOB.cjs} +112 -2
- package/dist/chunk-4CVLFLOB.cjs.map +1 -0
- package/dist/{chunk-5YEMOYSE.js → chunk-6GCKCWLB.js} +9 -3
- package/dist/chunk-6GCKCWLB.js.map +1 -0
- package/dist/{chunk-EBSPLUW4.cjs → chunk-AHCLWAM5.cjs} +28 -10
- package/dist/chunk-AHCLWAM5.cjs.map +1 -0
- package/dist/{chunk-KVILKGMS.js → chunk-AJA6LUI7.js} +36 -2
- package/dist/chunk-AJA6LUI7.js.map +1 -0
- package/dist/{chunk-EHAHVROS.cjs → chunk-CLVQBF5C.cjs} +5 -5
- package/dist/{chunk-EHAHVROS.cjs.map → chunk-CLVQBF5C.cjs.map} +1 -1
- package/dist/{chunk-34RRD7PC.js → chunk-CYFK5SY2.js} +111 -3
- package/dist/chunk-CYFK5SY2.js.map +1 -0
- package/dist/{chunk-M5LX5AOO.js → chunk-DDQVZGLO.js} +25 -12
- package/dist/chunk-DDQVZGLO.js.map +1 -0
- package/dist/{chunk-LR7YASZF.cjs → chunk-EAAHVJ4P.cjs} +3 -3
- package/dist/chunk-EAAHVJ4P.cjs.map +1 -0
- package/dist/{chunk-3PPFLFH4.js → chunk-FIFQPKBA.js} +1417 -144
- package/dist/chunk-FIFQPKBA.js.map +1 -0
- package/dist/{chunk-RIN643A3.js → chunk-GPPLSM2Z.js} +61 -2
- package/dist/chunk-GPPLSM2Z.js.map +1 -0
- package/dist/{chunk-4QADQTWS.js → chunk-KHJUSHFU.js} +231 -14
- package/dist/chunk-KHJUSHFU.js.map +1 -0
- package/dist/{chunk-NMD5VRN4.cjs → chunk-M4F66R4O.cjs} +74 -73
- package/dist/chunk-M4F66R4O.cjs.map +1 -0
- package/dist/{chunk-6NTVRDQV.cjs → chunk-M4Q47KHF.cjs} +126 -73
- package/dist/chunk-M4Q47KHF.cjs.map +1 -0
- package/dist/{chunk-LIPPNDBE.js → chunk-M5E34VG5.js} +3 -3
- package/dist/{chunk-LIPPNDBE.js.map → chunk-M5E34VG5.js.map} +1 -1
- package/dist/{chunk-53B6KDDJ.cjs → chunk-MBNQVDVC.cjs} +38 -3
- package/dist/{chunk-53B6KDDJ.cjs.map → chunk-MBNQVDVC.cjs.map} +1 -1
- package/dist/{chunk-SDGRK7EP.js → chunk-MEOHSQEH.js} +6 -5
- package/dist/chunk-MEOHSQEH.js.map +1 -0
- package/dist/{chunk-NMCRQP3Z.cjs → chunk-MTX2KVU7.cjs} +71 -70
- package/dist/chunk-MTX2KVU7.cjs.map +1 -0
- package/dist/{chunk-QNJ4ACRT.cjs → chunk-NJTXJ5AG.cjs} +37 -15
- package/dist/chunk-NJTXJ5AG.cjs.map +1 -0
- package/dist/{chunk-C4XZV6E7.cjs → chunk-NZFKROS7.cjs} +26 -20
- package/dist/chunk-NZFKROS7.cjs.map +1 -0
- package/dist/{chunk-64W6GLLZ.js → chunk-OFXOTECC.js} +24 -6
- package/dist/chunk-OFXOTECC.js.map +1 -0
- package/dist/{chunk-3YNVWKR2.cjs → chunk-OUHT5Z36.cjs} +28 -5
- package/dist/chunk-OUHT5Z36.cjs.map +1 -0
- package/dist/{chunk-EIGTWK5N.js → chunk-OWRHDUJD.js} +3 -3
- package/dist/chunk-OWRHDUJD.js.map +1 -0
- package/dist/{chunk-4MG4XKO2.js → chunk-PCPX42KL.js} +38 -3
- package/dist/{chunk-4MG4XKO2.js.map → chunk-PCPX42KL.js.map} +1 -1
- package/dist/{chunk-GW32KPCU.cjs → chunk-R24DI24X.cjs} +61 -2
- package/dist/chunk-R24DI24X.cjs.map +1 -0
- package/dist/{chunk-XVWCOTR6.js → chunk-SFQWJMKT.js} +7 -6
- package/dist/chunk-SFQWJMKT.js.map +1 -0
- package/dist/{chunk-6BKTCEUP.cjs → chunk-TY3TLZAW.cjs} +36 -2
- package/dist/chunk-TY3TLZAW.cjs.map +1 -0
- package/dist/{chunk-DM3LMRBC.js → chunk-UKPGSAZW.js} +187 -61
- package/dist/chunk-UKPGSAZW.js.map +1 -0
- package/dist/{chunk-NH2O2AUR.js → chunk-WC5FFSHB.js} +26 -4
- package/dist/chunk-WC5FFSHB.js.map +1 -0
- package/dist/{chunk-CLL7RUQV.cjs → chunk-WWOLFXTX.cjs} +40 -18
- package/dist/chunk-WWOLFXTX.cjs.map +1 -0
- package/dist/{chunk-JBSYC7BB.cjs → chunk-X2BWAZAU.cjs} +66 -53
- package/dist/chunk-X2BWAZAU.cjs.map +1 -0
- package/dist/{chunk-GOLDJNMZ.js → chunk-XBTEO4OB.js} +28 -5
- package/dist/chunk-XBTEO4OB.js.map +1 -0
- package/dist/{chunk-EPOXXJBK.js → chunk-YU2CUNFO.js} +3 -3
- package/dist/{chunk-EPOXXJBK.js.map → chunk-YU2CUNFO.js.map} +1 -1
- package/dist/constants.cjs +4 -4
- package/dist/constants.js +1 -1
- package/dist/engine.cjs +29 -30
- package/dist/engine.d.cts +6 -6
- package/dist/engine.d.ts +6 -6
- package/dist/engine.js +19 -20
- package/dist/format.cjs +7 -8
- package/dist/format.cjs.map +1 -1
- package/dist/format.js +2 -3
- package/dist/format.js.map +1 -1
- package/dist/index.cjs +28 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +20 -21
- package/dist/index.js.map +1 -1
- package/dist/language.cjs +74 -12
- package/dist/language.cjs.map +1 -1
- package/dist/language.d.cts +6 -6
- package/dist/language.d.ts +6 -6
- package/dist/language.js +68 -6
- package/dist/language.js.map +1 -1
- package/dist/lexer.cjs +19 -19
- package/dist/lexer.d.cts +3 -3
- package/dist/lexer.d.ts +3 -3
- package/dist/lexer.js +7 -7
- package/dist/normalizer.cjs +12 -12
- package/dist/normalizer.d.cts +4 -210
- package/dist/normalizer.d.ts +4 -210
- package/dist/normalizer.js +6 -6
- package/dist/packages.cjs +36 -37
- package/dist/packages.d.cts +5 -47
- package/dist/packages.d.ts +5 -47
- package/dist/packages.js +13 -14
- package/dist/parser.cjs +12 -12
- package/dist/parser.d.cts +3 -2
- package/dist/parser.d.ts +3 -2
- package/dist/parser.js +4 -4
- package/dist/resolvers.d.cts +1 -1
- package/dist/resolvers.d.ts +1 -1
- package/dist/uom.cjs +14 -14
- package/dist/uom.d.cts +12 -4
- package/dist/uom.d.ts +12 -4
- package/dist/uom.js +4 -4
- package/dist/vm.cjs +17 -17
- package/dist/vm.js +6 -6
- package/package.json +2 -1
- package/dist/NormalizerRule-BrVoVjmP.d.cts +0 -163
- package/dist/NormalizerRule-CEjf1FyD.d.ts +0 -163
- package/dist/chunk-34RRD7PC.js.map +0 -1
- package/dist/chunk-3PPFLFH4.js.map +0 -1
- package/dist/chunk-3YNVWKR2.cjs.map +0 -1
- package/dist/chunk-4QADQTWS.js.map +0 -1
- package/dist/chunk-5YEMOYSE.js.map +0 -1
- package/dist/chunk-64W6GLLZ.js.map +0 -1
- package/dist/chunk-6BKTCEUP.cjs.map +0 -1
- package/dist/chunk-6NTVRDQV.cjs.map +0 -1
- package/dist/chunk-C4XZV6E7.cjs.map +0 -1
- package/dist/chunk-CLL7RUQV.cjs.map +0 -1
- package/dist/chunk-DM3LMRBC.js.map +0 -1
- package/dist/chunk-EBSPLUW4.cjs.map +0 -1
- package/dist/chunk-EIGTWK5N.js.map +0 -1
- package/dist/chunk-GOLDJNMZ.js.map +0 -1
- package/dist/chunk-GW32KPCU.cjs.map +0 -1
- package/dist/chunk-HTXVVJRA.cjs.map +0 -1
- package/dist/chunk-HWSZJQCI.js.map +0 -1
- package/dist/chunk-J73SJHR3.cjs.map +0 -1
- package/dist/chunk-JBSYC7BB.cjs.map +0 -1
- package/dist/chunk-KVILKGMS.js.map +0 -1
- package/dist/chunk-LR7YASZF.cjs.map +0 -1
- package/dist/chunk-M5LX5AOO.js.map +0 -1
- package/dist/chunk-NH2O2AUR.js.map +0 -1
- package/dist/chunk-NMCRQP3Z.cjs.map +0 -1
- package/dist/chunk-NMD5VRN4.cjs.map +0 -1
- package/dist/chunk-OT6OJY7C.cjs +0 -114
- package/dist/chunk-OT6OJY7C.cjs.map +0 -1
- package/dist/chunk-QNJ4ACRT.cjs.map +0 -1
- package/dist/chunk-QWY3VEZN.js.map +0 -1
- package/dist/chunk-RFYD5TJE.js +0 -111
- package/dist/chunk-RFYD5TJE.js.map +0 -1
- package/dist/chunk-RIN643A3.js.map +0 -1
- package/dist/chunk-RZCWSXTA.cjs.map +0 -1
- package/dist/chunk-SDGRK7EP.js.map +0 -1
- package/dist/chunk-XJCMXB2E.cjs.map +0 -1
- package/dist/chunk-XVWCOTR6.js.map +0 -1
|
@@ -47,6 +47,18 @@ var TokenTypes = {
|
|
|
47
47
|
PI: "PI",
|
|
48
48
|
E: "E",
|
|
49
49
|
MOD: "MOD",
|
|
50
|
+
// The English word "and", which is NOT the same thing as "+" even though it
|
|
51
|
+
// adds. It used to map straight onto PLUS in the locale keyword map, which
|
|
52
|
+
// made "3 and 4" evaluate to 7 correctly and then quietly broke every phrase
|
|
53
|
+
// that uses "and" as a list separator: "average of 36, 42, 19 and 81" parsed
|
|
54
|
+
// its last argument as "19 + 81" and returned 178/3 rather than 178/4.
|
|
55
|
+
//
|
|
56
|
+
// Giving it its own type lets a parselet tell the two apart. It is still an
|
|
57
|
+
// infix addition (see ArithmeticPackage.ts) so "3 and 4" is unchanged, but it
|
|
58
|
+
// binds at BindingPower.Conjunction, one step looser than Sum, so a phrase
|
|
59
|
+
// parselet can parse an argument at Conjunction and get "1 + 2" whole while
|
|
60
|
+
// still stopping at "and".
|
|
61
|
+
AND_CONJ: "AND_CONJ",
|
|
50
62
|
OF: "OF",
|
|
51
63
|
INCREASE_BY: "INCREASE_BY",
|
|
52
64
|
DECREASE_BY: "DECREASE_BY",
|
|
@@ -106,6 +118,13 @@ var TokenTypes = {
|
|
|
106
118
|
ELSE: "ELSE",
|
|
107
119
|
AS: "AS",
|
|
108
120
|
CONVERTER_NAME: "CONVERTER_NAME",
|
|
121
|
+
// Rounding (packages/converters/). "rounded" is a bare keyword: it is a
|
|
122
|
+
// past participle with no plausible use as a :variableName, the same
|
|
123
|
+
// accepted-risk category as "between"/"from". TO_NEAREST and
|
|
124
|
+
// DECIMAL_PLACES are fused, since "to" already means percentage change.
|
|
125
|
+
ROUNDED: "ROUNDED",
|
|
126
|
+
TO_NEAREST: "TO_NEAREST",
|
|
127
|
+
DECIMAL_PLACES: "DECIMAL_PLACES",
|
|
109
128
|
// Fused two-word phrase tokens (see MathPhrasesPackage.ts's `phrases`
|
|
110
129
|
// field), deliberately NOT bare single-word keywords: "average"
|
|
111
130
|
// "total", "count", etc. are common variable names, and this codebase
|
|
@@ -122,8 +141,26 @@ var TokenTypes = {
|
|
|
122
141
|
SMALLER_OF: "SMALLER_OF",
|
|
123
142
|
HALF_OF: "HALF_OF",
|
|
124
143
|
MIDPOINT_BETWEEN: "MIDPOINT_BETWEEN",
|
|
144
|
+
REMAINDER_OF: "REMAINDER_OF",
|
|
145
|
+
NTH_ROOT: "NTH_ROOT",
|
|
146
|
+
LOG_PHRASE: "LOG_PHRASE",
|
|
147
|
+
LOG_BASE: "LOG_BASE",
|
|
148
|
+
GCD_OF: "GCD_OF",
|
|
149
|
+
LCM_OF: "LCM_OF",
|
|
150
|
+
SQUARE_ROOT_OF: "SQUARE_ROOT_OF",
|
|
151
|
+
CUBE_ROOT_OF: "CUBE_ROOT_OF",
|
|
125
152
|
RANDOM_NUMBER: "RANDOM_NUMBER",
|
|
126
153
|
IS_TO: "IS_TO",
|
|
154
|
+
// Bare "is", the trigger for the solve-for-the-unknown percentage family
|
|
155
|
+
// (packages/percentage/IsWhatParselet.ts). Safe as a bare keyword: it is a
|
|
156
|
+
// verb, not a plausible :variableName, and the "is to" proportion phrase is
|
|
157
|
+
// fused earlier so it still wins.
|
|
158
|
+
IS: "IS",
|
|
159
|
+
PCT_ON: "PCT_ON",
|
|
160
|
+
PCT_OFF: "PCT_OFF",
|
|
161
|
+
OF_WHAT: "OF_WHAT",
|
|
162
|
+
OFF_WHAT: "OFF_WHAT",
|
|
163
|
+
ON_WHAT: "ON_WHAT",
|
|
127
164
|
// CLAMP stays a bare single-word keyword: "clamp X between Y and Z" has
|
|
128
165
|
// the value X between the trigger and "between", so it can't be
|
|
129
166
|
// phrase-fused like the others above (same structural reason
|
|
@@ -206,6 +243,23 @@ var TokenTypes = {
|
|
|
206
243
|
// create an unintended coupling if "@" is ever wired up.
|
|
207
244
|
OVER: "OVER",
|
|
208
245
|
RATE_AT: "RATE_AT",
|
|
246
|
+
// The investment grammar's connectives (packages/finance/), same
|
|
247
|
+
// accepted-risk category as OVER/RATE_AT above. "after"/"for" are
|
|
248
|
+
// prepositions; "compounding", "invested" and "returned" are participles,
|
|
249
|
+
// and none is a plausible `:variableName`.
|
|
250
|
+
//
|
|
251
|
+
// "after" and "for" are the pivots Soulver's own documented syntax uses,
|
|
252
|
+
// `$1,000 after 3 years at 7%` and `$1,000 for 3 years at 7% compounding
|
|
253
|
+
// monthly`. This package originally substituted "over" for both and said so
|
|
254
|
+
// in CompoundInterestParselet.ts's doc comment; the documented spellings now
|
|
255
|
+
// work as well, and "over" is kept so nothing that already parsed stops.
|
|
256
|
+
AFTER: "AFTER",
|
|
257
|
+
PRESENT_VALUE_OF: "PRESENT_VALUE_OF",
|
|
258
|
+
ANNUAL_RETURN_ON: "ANNUAL_RETURN_ON",
|
|
259
|
+
FOR_DURATION: "FOR_DURATION",
|
|
260
|
+
COMPOUNDING: "COMPOUNDING",
|
|
261
|
+
INVESTED: "INVESTED",
|
|
262
|
+
RETURNED: "RETURNED",
|
|
209
263
|
// Fused phrase tokens (see FinancePackage.ts's `phrases` field)
|
|
210
264
|
// deliberately NOT bare single-word keywords: "interest", "tax", "vat",
|
|
211
265
|
// "repayment", "principal" etc. are all common, plausible variable names
|
|
@@ -226,6 +280,7 @@ var TokenTypes = {
|
|
|
226
280
|
TOTAL_LOAN_INTEREST_ON: "TOTAL_LOAN_INTEREST_ON",
|
|
227
281
|
TAX_ON: "TAX_ON",
|
|
228
282
|
TAX_OFF: "TAX_OFF",
|
|
283
|
+
TAX_IN_PHRASE: "TAX_IN_PHRASE",
|
|
229
284
|
// Inflation-adjusted value (packages/finance/) -- fused phrase
|
|
230
285
|
// tokens (see FinancePackage.ts's `phrases` field), same reasoning
|
|
231
286
|
// as the tax/interest phrases above: "what"/"was"/"value"/"worth"
|
|
@@ -278,6 +333,10 @@ var TokenTypes = {
|
|
|
278
333
|
MONTH_ON: "MONTH_ON",
|
|
279
334
|
MONTH_IN: "MONTH_IN",
|
|
280
335
|
WEEK_ON: "WEEK_ON",
|
|
336
|
+
DAYS_IN_PERIOD: "DAYS_IN_PERIOD",
|
|
337
|
+
IN_TWO_UNITS: "IN_TWO_UNITS",
|
|
338
|
+
PER_UNIT: "PER_UNIT",
|
|
339
|
+
AT_RATE: "AT_RATE",
|
|
281
340
|
WEEK_IN: "WEEK_IN",
|
|
282
341
|
// `<unit> between <date> and <date>`, fused UNIT+BETWEEN, exactly like
|
|
283
342
|
// UNTIL_UNIT/SINCE_UNIT above.
|
|
@@ -350,5 +409,5 @@ function registerAllTokenTypes() {
|
|
|
350
409
|
}
|
|
351
410
|
|
|
352
411
|
export { TokenTypes, registerAllTokenTypes, registerTokenType, tokenTypeId, tokenTypeName };
|
|
353
|
-
//# sourceMappingURL=chunk-
|
|
354
|
-
//# sourceMappingURL=chunk-
|
|
412
|
+
//# sourceMappingURL=chunk-GPPLSM2Z.js.map
|
|
413
|
+
//# sourceMappingURL=chunk-GPPLSM2Z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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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AM,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-GPPLSM2Z.js","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, one step looser than Sum, so a phrase\n // parselet can parse an argument at Conjunction and get \"1 + 2\" whole while\n // still stopping at \"and\".\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"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { VariableResolver } from './chunk-GCM5JHMX.js';
|
|
2
|
-
import { sharedCurrencyExchange } from './chunk-
|
|
3
|
-
import { powNode, callNode, simplifySymbolic, sameShape, cancelSymbolic, complexNode, complex, RATIONAL_ZERO, rationalFromNumber, freeVariables, symbolicToEntry, rowMajorToColumnMajor, expandSymbolic, matrixMultiply, inverse, determinant, transpose, constNode, rationalToNumber, toPolynomial, polyDegree, polyCoefficients, rationalNeg, substitute, rationalDiv, isRationalZero, varNode, isRationalOne, RATIONAL_ONE, polyUnivariateVar, rationalMul, fromPolynomial, rationalCompare, coefficientGcd, polynomialDivide, isZeroPolynomial, rationalAdd, rationalSub, exactIntegerSqrt, surdNode, compareMonomials, COMPLEX_I, exactRationalSqrt, symbolicKey, monomialFromKey, monomialToKey, signedSurdNode, exactIntegerCbrt } from './chunk-
|
|
4
|
-
import { errorValue, symbolicValue, numberValue, bigIntValue, uomValue, matrixValue,
|
|
5
|
-
import { getMeasure, convertUnit } from './chunk-
|
|
2
|
+
import { sharedCurrencyExchange } from './chunk-UKPGSAZW.js';
|
|
3
|
+
import { powNode, callNode, simplifySymbolic, sameShape, cancelSymbolic, complexNode, complex, RATIONAL_ZERO, rationalFromNumber, freeVariables, symbolicToEntry, rowMajorToColumnMajor, expandSymbolic, matrixMultiply, inverse, determinant, transpose, constNode, rationalToNumber, toPolynomial, polyDegree, polyCoefficients, rationalNeg, substitute, rationalDiv, isRationalZero, varNode, isRationalOne, RATIONAL_ONE, polyUnivariateVar, rationalMul, fromPolynomial, rationalCompare, coefficientGcd, polynomialDivide, isZeroPolynomial, rationalAdd, rationalSub, exactIntegerSqrt, surdNode, compareMonomials, COMPLEX_I, exactRationalSqrt, symbolicKey, monomialFromKey, monomialToKey, signedSurdNode, exactIntegerCbrt } from './chunk-CYFK5SY2.js';
|
|
4
|
+
import { errorValue, symbolicValue, numberValue, bigIntValue, uomValue, matrixValue, percentageValue, stringValue, hexValue } from './chunk-BVAR5J2F.js';
|
|
5
|
+
import { getMeasure, convertUnit } from './chunk-WC5FFSHB.js';
|
|
6
|
+
import { UNIT_TABLE } from './chunk-PCPX42KL.js';
|
|
6
7
|
import { ErrorFactory } from './chunk-6RDSQURE.js';
|
|
7
8
|
|
|
8
9
|
// src/symbolic/MultivariateFactor.ts
|
|
@@ -1687,6 +1688,19 @@ function adjustForInflation(amount, fromYear, toYear) {
|
|
|
1687
1688
|
}
|
|
1688
1689
|
|
|
1689
1690
|
// src/vm/VMBuiltins.ts
|
|
1691
|
+
var ANGLE_KIND = 0;
|
|
1692
|
+
function angleInRadians(value) {
|
|
1693
|
+
if (value.type === 6 /* Uom */ && value.unit !== void 0) {
|
|
1694
|
+
const entry = UNIT_TABLE[value.unit.toLowerCase()];
|
|
1695
|
+
if (entry !== void 0 && entry[0] === ANGLE_KIND) return value.toNumber() * entry[1];
|
|
1696
|
+
}
|
|
1697
|
+
return value.toNumber();
|
|
1698
|
+
}
|
|
1699
|
+
function pluraliseUnit(unit, count) {
|
|
1700
|
+
if (count === 1) return unit;
|
|
1701
|
+
const plural = `${unit}s`;
|
|
1702
|
+
return UNIT_TABLE[plural.toLowerCase()] === void 0 ? unit : plural;
|
|
1703
|
+
}
|
|
1690
1704
|
var builtinFunctions = {
|
|
1691
1705
|
// ── Populated below ──
|
|
1692
1706
|
// sqrt: a negative argument has a complex answer now that there is a complex
|
|
@@ -1701,9 +1715,10 @@ var builtinFunctions = {
|
|
|
1701
1715
|
// valid alias for det(a) (index 64), reusing the SAME implementation
|
|
1702
1716
|
// not a separate one. Plain-number abs is unaffected.
|
|
1703
1717
|
1: (args) => args[0].type === 7 /* Matrix */ ? determinant(args[0].value) : numberValue(Math.abs(args[0].toNumber())),
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1718
|
+
// sin/cos/tan accept an angle with a unit; see angleInRadians().
|
|
1719
|
+
2: (args) => numberValue(Math.sin(angleInRadians(args[0]))),
|
|
1720
|
+
3: (args) => numberValue(Math.cos(angleInRadians(args[0]))),
|
|
1721
|
+
4: (args) => numberValue(Math.tan(angleInRadians(args[0]))),
|
|
1707
1722
|
5: (args) => numberValue(Math.log(args[0].toNumber())),
|
|
1708
1723
|
6: (args) => numberValue(Math.ceil(args[0].toNumber())),
|
|
1709
1724
|
7: (args) => numberValue(Math.floor(args[0].toNumber())),
|
|
@@ -2017,11 +2032,13 @@ var builtinFunctions = {
|
|
|
2017
2032
|
const { monthlyPayment } = amortizeLoan(principal, rate, years);
|
|
2018
2033
|
return args[0].type === 6 /* Uom */ ? uomValue(monthlyPayment, args[0].unit) : numberValue(monthlyPayment);
|
|
2019
2034
|
},
|
|
2020
|
-
// taxAdd(amount, rate) -> amount * (1 + rate)
|
|
2021
|
-
//
|
|
2022
|
-
//
|
|
2023
|
-
//
|
|
2024
|
-
//
|
|
2035
|
+
// taxAdd(amount, rate) -> amount * (1 + rate), the tax-inclusive total.
|
|
2036
|
+
// Backs the taxAdd() function-call form, whose name promises exactly this.
|
|
2037
|
+
// The "tax on $X at R%" PHRASE does NOT use it, see index 86.
|
|
2038
|
+
//
|
|
2039
|
+
// No default rate is baked in anywhere, the caller always supplies one
|
|
2040
|
+
// explicitly, since tax rates vary by region and change over time; this
|
|
2041
|
+
// package makes no assumption about which rate applies.
|
|
2025
2042
|
58: (args) => {
|
|
2026
2043
|
const amount = args[0].toNumber();
|
|
2027
2044
|
const rate = args[1].toNumber();
|
|
@@ -2237,6 +2254,206 @@ var builtinFunctions = {
|
|
|
2237
2254
|
const value = args[0];
|
|
2238
2255
|
if (value.type !== 9 /* Symbolic */) return value;
|
|
2239
2256
|
return symbolicToValue(apartSymbolic(value.value));
|
|
2257
|
+
},
|
|
2258
|
+
// taxIn(amount, rate) -> amount - amount/(1 + rate), the tax already
|
|
2259
|
+
// contained in a tax-INCLUSIVE total. Backs "tax in/of/from $X at R%".
|
|
2260
|
+
// The complement of taxRemove (index 59): the two sum to the gross amount.
|
|
2261
|
+
85: (args) => {
|
|
2262
|
+
const amount = args[0].toNumber();
|
|
2263
|
+
const rate = args[1].toNumber();
|
|
2264
|
+
if (1 + rate <= 0) {
|
|
2265
|
+
return errorValue("INVALID_RATE", `taxIn: rate ${rate} makes (1 + rate) non-positive`);
|
|
2266
|
+
}
|
|
2267
|
+
const tax = amount - amount / (1 + rate);
|
|
2268
|
+
return args[0].type === 6 /* Uom */ ? uomValue(tax, args[0].unit) : numberValue(tax);
|
|
2269
|
+
},
|
|
2270
|
+
// taxOn(amount, rate) -> amount * rate, the tax itself.
|
|
2271
|
+
//
|
|
2272
|
+
// The "tax on $X at R%" phrase used to compile to taxAdd (index 58) and
|
|
2273
|
+
// answer $345.00 for "tax on $300 at 15%". Soulver answers $45.00, and
|
|
2274
|
+
// "the tax on $300" is the tax, not the bill. The total is "$300 + 15%",
|
|
2275
|
+
// which reads as a relative increase (see PercentParselet.ts), or
|
|
2276
|
+
// taxAdd(300, 0.15) for the function form.
|
|
2277
|
+
86: (args) => {
|
|
2278
|
+
const amount = args[0].toNumber();
|
|
2279
|
+
const rate = args[1].toNumber();
|
|
2280
|
+
const tax = amount * rate;
|
|
2281
|
+
return args[0].type === 6 /* Uom */ ? uomValue(tax, args[0].unit) : numberValue(tax);
|
|
2282
|
+
},
|
|
2283
|
+
// ── Degree-taking trig (sind/cosd/tand and the inverses) ──────────────
|
|
2284
|
+
// The "d" spellings take and return degrees rather than radians, which is
|
|
2285
|
+
// the convention every scientific calculator uses. sin(90 degrees) is the
|
|
2286
|
+
// other way to say the same thing; both exist because both get typed.
|
|
2287
|
+
87: (args) => numberValue(Math.sin(args[0].toNumber() * Math.PI / 180)),
|
|
2288
|
+
88: (args) => numberValue(Math.cos(args[0].toNumber() * Math.PI / 180)),
|
|
2289
|
+
89: (args) => numberValue(Math.tan(args[0].toNumber() * Math.PI / 180)),
|
|
2290
|
+
90: (args) => numberValue(Math.asin(args[0].toNumber()) * 180 / Math.PI),
|
|
2291
|
+
91: (args) => numberValue(Math.acos(args[0].toNumber()) * 180 / Math.PI),
|
|
2292
|
+
92: (args) => numberValue(Math.atan(args[0].toNumber()) * 180 / Math.PI),
|
|
2293
|
+
// daysCount(n) -> n labelled as days. "days in Q3" is a count of days
|
|
2294
|
+
// and should say so; a bare 92 loses what was being counted.
|
|
2295
|
+
93: (args) => uomValue(args[0].toNumber(), "days"),
|
|
2296
|
+
// asTwoUnits(value, majorUnit, minorUnit) -> "12 min 30 s".
|
|
2297
|
+
//
|
|
2298
|
+
// "12.5 minutes in minutes and seconds" asks for one quantity split
|
|
2299
|
+
// across two units, which every other conversion path cannot express:
|
|
2300
|
+
// they each produce a single number in a single unit.
|
|
2301
|
+
//
|
|
2302
|
+
// The whole part goes to the major unit and the remainder to the minor,
|
|
2303
|
+
// so nothing is lost. A pair that is not ordered major-then-minor, or
|
|
2304
|
+
// that spans two different measures, reports rather than guessing.
|
|
2305
|
+
94: (args) => {
|
|
2306
|
+
const major = args[1].value;
|
|
2307
|
+
const minor = args[2].value;
|
|
2308
|
+
const majorEntry = UNIT_TABLE[major.toLowerCase()];
|
|
2309
|
+
const minorEntry = UNIT_TABLE[minor.toLowerCase()];
|
|
2310
|
+
if (majorEntry === void 0 || minorEntry === void 0) {
|
|
2311
|
+
return errorValue("UNKNOWN_UNIT", `${major} and ${minor}: one of these is not a unit`);
|
|
2312
|
+
}
|
|
2313
|
+
if (majorEntry[0] !== minorEntry[0]) {
|
|
2314
|
+
return errorValue("INCOMPATIBLE_UNITS", `${major} and ${minor} measure different things`);
|
|
2315
|
+
}
|
|
2316
|
+
if (minorEntry[1] >= majorEntry[1]) {
|
|
2317
|
+
return errorValue("INCOMPATIBLE_UNITS", `${major} and ${minor}: name the larger unit first`);
|
|
2318
|
+
}
|
|
2319
|
+
const source = args[0];
|
|
2320
|
+
const sourceEntry = source.type === 6 /* Uom */ && source.unit !== void 0 ? UNIT_TABLE[source.unit.toLowerCase()] : void 0;
|
|
2321
|
+
const inBase = source.toNumber() * (sourceEntry?.[1] ?? majorEntry[1]);
|
|
2322
|
+
const majorCount = Math.floor(inBase / majorEntry[1]);
|
|
2323
|
+
const minorCount = Math.round((inBase - majorCount * majorEntry[1]) / minorEntry[1] * 1e3) / 1e3;
|
|
2324
|
+
return stringValue(`${majorCount} ${major} ${minorCount} ${minor}`);
|
|
2325
|
+
},
|
|
2326
|
+
// makeRate(value, denominatorUnit) -> value per that unit.
|
|
2327
|
+
//
|
|
2328
|
+
// `3 hours / day` is a rate, `3 hours / 3 days` is a division. The
|
|
2329
|
+
// difference is whether a number was written in the denominator, which
|
|
2330
|
+
// is decided at parse time, so this only ever receives the rate case.
|
|
2331
|
+
//
|
|
2332
|
+
// Building the rate directly rather than dividing by an implied 1 is the
|
|
2333
|
+
// whole point: a division makes same-measure units cancel, which turned
|
|
2334
|
+
// `3 hours / day` into 0.125 when that shortcut was tried.
|
|
2335
|
+
95: (args) => {
|
|
2336
|
+
const source = args[0];
|
|
2337
|
+
const denominator = String(args[1].value);
|
|
2338
|
+
const numerator = source.type === 6 /* Uom */ && source.unit !== void 0 ? source.unit : "";
|
|
2339
|
+
if (numerator.includes("/")) {
|
|
2340
|
+
return errorValue("INVALID_RATE_UNIT", `${numerator}/${denominator}: that is already a rate`);
|
|
2341
|
+
}
|
|
2342
|
+
return uomValue(source.toNumber(), `${numerator}/${denominator}`);
|
|
2343
|
+
},
|
|
2344
|
+
// atRate(quantity, rate) -> whichever of the two the question implies.
|
|
2345
|
+
//
|
|
2346
|
+
// 30 hours at $30/hour $900 a duration at a price per duration
|
|
2347
|
+
// $500 at $20/hour 25 hours money at a price per duration
|
|
2348
|
+
//
|
|
2349
|
+
// Both are written with the same word and mean opposite operations. Which
|
|
2350
|
+
// one applies is decided by which half of the rate the left side matches:
|
|
2351
|
+
// match the denominator and you are buying that many, match the numerator
|
|
2352
|
+
// and you are asking how many it buys.
|
|
2353
|
+
96: (args) => {
|
|
2354
|
+
const left = args[0];
|
|
2355
|
+
const rate = args[1];
|
|
2356
|
+
if (rate.type !== 6 /* Uom */ || rate.unit === void 0 || !rate.unit.includes("/")) {
|
|
2357
|
+
return errorValue("INVALID_RATE", 'at: the right-hand side has to be a rate, as in "$30/hour"');
|
|
2358
|
+
}
|
|
2359
|
+
const slash = rate.unit.indexOf("/");
|
|
2360
|
+
const numerator = rate.unit.slice(0, slash);
|
|
2361
|
+
const denominator = rate.unit.slice(slash + 1);
|
|
2362
|
+
const leftUnit = left.type === 6 /* Uom */ ? left.unit : void 0;
|
|
2363
|
+
const denominatorEntry = UNIT_TABLE[denominator.toLowerCase()];
|
|
2364
|
+
const leftEntry = leftUnit === void 0 ? void 0 : UNIT_TABLE[leftUnit.toLowerCase()];
|
|
2365
|
+
if (leftEntry !== void 0 && denominatorEntry !== void 0 && leftEntry[0] === denominatorEntry[0]) {
|
|
2366
|
+
const inDenominator = left.toNumber() * leftEntry[1] / denominatorEntry[1];
|
|
2367
|
+
const total = inDenominator * rate.toNumber();
|
|
2368
|
+
return numerator === "" ? numberValue(total) : uomValue(total, numerator);
|
|
2369
|
+
}
|
|
2370
|
+
if (leftUnit !== void 0 && leftUnit === numerator) {
|
|
2371
|
+
const count = left.toNumber() / rate.toNumber();
|
|
2372
|
+
return uomValue(count, pluraliseUnit(denominator, count));
|
|
2373
|
+
}
|
|
2374
|
+
if (leftUnit === void 0) {
|
|
2375
|
+
const total = left.toNumber() * rate.toNumber();
|
|
2376
|
+
return numerator === "" ? numberValue(total) : uomValue(total, numerator);
|
|
2377
|
+
}
|
|
2378
|
+
return errorValue("INCOMPATIBLE_UNITS", `at: ${leftUnit} matches neither side of ${rate.unit}`);
|
|
2379
|
+
},
|
|
2380
|
+
// ── Investments (packages/finance/) ────────────────────────────────────
|
|
2381
|
+
// compoundFutureValueEvery(principal, rate, years, periodsPerYear)
|
|
2382
|
+
// FV = P(1 + r/n)^(n·y). Index 51 is the same formula with n fixed at 1;
|
|
2383
|
+
// this one backs "compounding monthly"/"quarterly"/"daily"/"weekly".
|
|
2384
|
+
// Kept separate rather than widening 51, because 51 is also the public
|
|
2385
|
+
// compoundInterest(principal, rate, years) call and its arity is part of
|
|
2386
|
+
// that contract.
|
|
2387
|
+
80: (args) => {
|
|
2388
|
+
const principal = args[0].toNumber();
|
|
2389
|
+
const rate = args[1].toNumber();
|
|
2390
|
+
const years = args[2].toNumber();
|
|
2391
|
+
const perYear = args[3].toNumber();
|
|
2392
|
+
if (perYear <= 0) {
|
|
2393
|
+
return errorValue("INVALID_RATE", `compounding: ${perYear} periods per year is not a period`);
|
|
2394
|
+
}
|
|
2395
|
+
if (1 + rate / perYear <= 0) {
|
|
2396
|
+
return errorValue("INVALID_RATE", `compounding: rate ${rate} makes each period non-positive`);
|
|
2397
|
+
}
|
|
2398
|
+
const fv = principal * Math.pow(1 + rate / perYear, perYear * years);
|
|
2399
|
+
return args[0].type === 6 /* Uom */ ? uomValue(fv, args[0].unit) : numberValue(fv);
|
|
2400
|
+
},
|
|
2401
|
+
// compoundInterestEarnedEvery(principal, rate, years, periodsPerYear)
|
|
2402
|
+
// The interest-only portion of index 80, i.e. FV - P.
|
|
2403
|
+
81: (args) => {
|
|
2404
|
+
const principal = args[0].toNumber();
|
|
2405
|
+
const rate = args[1].toNumber();
|
|
2406
|
+
const years = args[2].toNumber();
|
|
2407
|
+
const perYear = args[3].toNumber();
|
|
2408
|
+
if (perYear <= 0 || 1 + rate / perYear <= 0) {
|
|
2409
|
+
return errorValue("INVALID_RATE", `compounding: rate ${rate} over ${perYear} periods per year is not usable`);
|
|
2410
|
+
}
|
|
2411
|
+
const interest = principal * (Math.pow(1 + rate / perYear, perYear * years) - 1);
|
|
2412
|
+
return args[0].type === 6 /* Uom */ ? uomValue(interest, args[0].unit) : numberValue(interest);
|
|
2413
|
+
},
|
|
2414
|
+
// presentValue(futureValue, rate, years) -> FV / (1 + r)^y, what a sum
|
|
2415
|
+
// promised in the future is worth today. The inverse of index 51.
|
|
2416
|
+
82: (args) => {
|
|
2417
|
+
const future = args[0].toNumber();
|
|
2418
|
+
const rate = args[1].toNumber();
|
|
2419
|
+
const years = args[2].toNumber();
|
|
2420
|
+
if (1 + rate <= 0) {
|
|
2421
|
+
return errorValue("INVALID_RATE", `presentValue: rate ${rate} makes (1 + rate) non-positive`);
|
|
2422
|
+
}
|
|
2423
|
+
const pv = future / Math.pow(1 + rate, years);
|
|
2424
|
+
return args[0].type === 6 /* Uom */ ? uomValue(pv, args[0].unit) : numberValue(pv);
|
|
2425
|
+
},
|
|
2426
|
+
// returnOnInvestment(invested, returned) -> (returned - invested) /
|
|
2427
|
+
// invested, the gain as a multiple of what was put in. $500 in and $1,500
|
|
2428
|
+
// out is 2x, not 3x: ROI conventionally measures the profit against the
|
|
2429
|
+
// cost, so doubling your money is 1x return and tripling it is 2x. The
|
|
2430
|
+
// money multiple (3x here) is a different figure; `$1,500 / $500` gives it.
|
|
2431
|
+
83: (args) => {
|
|
2432
|
+
const invested = args[0].toNumber();
|
|
2433
|
+
const returned = args[1].toNumber();
|
|
2434
|
+
if (invested === 0) {
|
|
2435
|
+
return errorValue("INVALID_RATE", "roi: nothing was invested, so there is no return on it");
|
|
2436
|
+
}
|
|
2437
|
+
return numberValue((returned - invested) / invested);
|
|
2438
|
+
},
|
|
2439
|
+
// annualisedReturn(invested, returned, years) -> CAGR, the constant
|
|
2440
|
+
// yearly rate that turns `invested` into `returned` over `years`:
|
|
2441
|
+
// (returned/invested)^(1/years) - 1. Returned as a Percentage so it
|
|
2442
|
+
// renders "13.99%" rather than 0.1399.
|
|
2443
|
+
84: (args) => {
|
|
2444
|
+
const invested = args[0].toNumber();
|
|
2445
|
+
const returned = args[1].toNumber();
|
|
2446
|
+
const years = args[2].toNumber();
|
|
2447
|
+
if (invested <= 0) {
|
|
2448
|
+
return errorValue("INVALID_RATE", "annual return: the amount invested must be positive");
|
|
2449
|
+
}
|
|
2450
|
+
if (years <= 0) {
|
|
2451
|
+
return errorValue("INVALID_RATE", "annual return: the period must be longer than zero");
|
|
2452
|
+
}
|
|
2453
|
+
if (returned <= 0) {
|
|
2454
|
+
return errorValue("INVALID_RATE", "annual return: nothing was returned, so there is no annual rate");
|
|
2455
|
+
}
|
|
2456
|
+
return percentageValue(Math.pow(returned / invested, 1 / years) - 1);
|
|
2240
2457
|
}
|
|
2241
2458
|
};
|
|
2242
2459
|
function applyComplexAccessor(name, value) {
|
|
@@ -2388,5 +2605,5 @@ function globalDagKey(name) {
|
|
|
2388
2605
|
}
|
|
2389
2606
|
|
|
2390
2607
|
export { CPI_MAX_YEAR, CPI_MIN_YEAR, OpRegistry, SYMBOLIC_NATIVE_BUILTINS, adjustForInflation, allocatePluginFunctionIndex, asConverterRegistry, binaryOp, builtinFunctions, createEngineContext, defaultEngineContext, globalDagKey, pluginFunctionRegistry, registerAsConverter, sharedGlobalVariableStore, sharedOpRegistry, solveEquationValues, symbolicBuiltin, symbolicNeg, symbolicPow, unifyUom, unregisterAsConverter };
|
|
2391
|
-
//# sourceMappingURL=chunk-
|
|
2392
|
-
//# sourceMappingURL=chunk-
|
|
2608
|
+
//# sourceMappingURL=chunk-KHJUSHFU.js.map
|
|
2609
|
+
//# sourceMappingURL=chunk-KHJUSHFU.js.map
|