summaryrefslogtreecommitdiff
path: root/include/formula/compiler.hrc
blob: 9bda945bae516311e0f4253b98a729b18f535793 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef FORMULA_COMPILER_HRC
#define FORMULA_COMPILER_HRC

/* Central definition of OpCodes for spreadsheet functions */

/*** Special commands ***/
#define SC_OPCODE_PUSH                0     /* internal commands */
#define SC_OPCODE_CALL                1
#define SC_OPCODE_STOP                2
#define SC_OPCODE_EXTERNAL            3
#define SC_OPCODE_NAME                4
#define SC_OPCODE_EXTERNAL_REF        5
#define SC_OPCODE_IF                  6     /* jump commands */
#define SC_OPCODE_IF_ERROR            7
#define SC_OPCODE_IF_NA               8
#define SC_OPCODE_CHOSE               9
#define SC_OPCODE_OPEN               10     /* parentheses and separators */
#define SC_OPCODE_CLOSE              11
#define SC_OPCODE_SEP                12
#define SC_OPCODE_MISSING            13     /* special OpCodes */
#define SC_OPCODE_BAD                14
#define SC_OPCODE_STRINGXML          15
#define SC_OPCODE_SPACES             16
#define SC_OPCODE_MAT_REF            17
#define SC_OPCODE_DB_AREA            18     /* additional access operators */
#define SC_OPCODE_MACRO              19
#define SC_OPCODE_COL_ROW_NAME       20
#define SC_OPCODE_COL_ROW_NAME_AUTO  21
#define SC_OPCODE_PERCENT_SIGN       22     /* operator _follows_ value */
#define SC_OPCODE_ARRAY_OPEN         23
#define SC_OPCODE_ARRAY_CLOSE        24
#define SC_OPCODE_ARRAY_ROW_SEP      25
#define SC_OPCODE_ARRAY_COL_SEP      26     /* some convs use sep != col_sep */
#define SC_OPCODE_STOP_DIV           27
#define SC_OPCODE_SKIP               28     /* used to skip raw tokens during string compilation */

/*** error constants #... ***/
#define SC_OPCODE_START_ERRORS       30
#define SC_OPCODE_ERROR_NULL         30
#define SC_OPCODE_ERROR_DIVZERO      31
#define SC_OPCODE_ERROR_VALUE        32
#define SC_OPCODE_ERROR_REF          33
#define SC_OPCODE_ERROR_NAME         34
#define SC_OPCODE_ERROR_NUM          35
#define SC_OPCODE_ERROR_NA           36
#define SC_OPCODE_STOP_ERRORS        37

/*** Binary operators ***/
#define SC_OPCODE_START_BIN_OP       40
#define SC_OPCODE_ADD                40
#define SC_OPCODE_SUB                41
#define SC_OPCODE_MUL                42
#define SC_OPCODE_DIV                43
#define SC_OPCODE_AMPERSAND          44
#define SC_OPCODE_POW                45
#define SC_OPCODE_EQUAL              46
#define SC_OPCODE_NOT_EQUAL          47
#define SC_OPCODE_LESS               48
#define SC_OPCODE_GREATER            49
#define SC_OPCODE_LESS_EQUAL         50
#define SC_OPCODE_GREATER_EQUAL      51
#define SC_OPCODE_AND                52
#define SC_OPCODE_OR                 53
#define SC_OPCODE_INTERSECT          54
#define SC_OPCODE_UNION              55
#define SC_OPCODE_RANGE              56
#define SC_OPCODE_STOP_BIN_OP        57

/* NOTE: binary and unary operators must be in sequence for compiler! */

/*** Unary operators ***/
#define SC_OPCODE_START_UN_OP        60
#define SC_OPCODE_NOT                60
#define SC_OPCODE_NEG                61
#define SC_OPCODE_NEG_SUB            62
#define SC_OPCODE_STOP_UN_OP         63

#define SC_OPCODE_START_FUNCTION     65

/*** Functions without parameters ***/
#define SC_OPCODE_START_NO_PAR       65
#define SC_OPCODE_PI                 65
#define SC_OPCODE_RANDOM             66
#define SC_OPCODE_TRUE               67
#define SC_OPCODE_FALSE              68
#define SC_OPCODE_GET_ACT_DATE       69
#define SC_OPCODE_GET_ACT_TIME       70
#define SC_OPCODE_NO_VALUE           71
#define SC_OPCODE_CURRENT            72
#define SC_OPCODE_STOP_NO_PAR        73

/*** Functions with one parameter ***/
#define SC_OPCODE_START_1_PAR        80
#define SC_OPCODE_DEG                80     /* trigonometric */
#define SC_OPCODE_RAD                81
#define SC_OPCODE_SIN                82
#define SC_OPCODE_COS                83
#define SC_OPCODE_TAN                84
#define SC_OPCODE_COT                85
#define SC_OPCODE_ARC_SIN            86
#define SC_OPCODE_ARC_COS            87
#define SC_OPCODE_ARC_TAN            88
#define SC_OPCODE_ARC_COT            89
#define SC_OPCODE_SIN_HYP            90
#define SC_OPCODE_COS_HYP            91
#define SC_OPCODE_TAN_HYP            92
#define SC_OPCODE_COT_HYP            93
#define SC_OPCODE_ARC_SIN_HYP        94     /* transcendent */
#define SC_OPCODE_ARC_COS_HYP        95
#define SC_OPCODE_ARC_TAN_HYP        96
#define SC_OPCODE_ARC_COT_HYP        97
#define SC_OPCODE_COSECANT           98
#define SC_OPCODE_SECANT             99
#define SC_OPCODE_COSECANT_HYP      100
#define SC_OPCODE_SECANT_HYP        101
#define SC_OPCODE_EXP               102
#define SC_OPCODE_LN                103
#define SC_OPCODE_SQRT              104
#define SC_OPCODE_FACT              105
#define SC_OPCODE_GET_YEAR          106     /* date and time */
#define SC_OPCODE_GET_MONTH         107
#define SC_OPCODE_GET_DAY           108
#define SC_OPCODE_GET_HOUR          109
#define SC_OPCODE_GET_MIN           110
#define SC_OPCODE_GET_SEC           111
#define SC_OPCODE_PLUS_MINUS        112     /* miscellaneous */
#define SC_OPCODE_ABS               113
#define SC_OPCODE_INT               114
#define SC_OPCODE_PHI               115
#define SC_OPCODE_GAUSS             116
#define SC_OPCODE_IS_EMPTY          117     /* obtain type */
#define SC_OPCODE_IS_STRING         118
#define SC_OPCODE_IS_NON_STRING     119
#define SC_OPCODE_IS_LOGICAL        120
#define SC_OPCODE_TYPE              121
#define SC_OPCODE_IS_REF            122
#define SC_OPCODE_IS_VALUE          123
#define SC_OPCODE_IS_FORMULA        124
#define SC_OPCODE_IS_NV             125
#define SC_OPCODE_IS_ERR            126
#define SC_OPCODE_IS_ERROR          127
#define SC_OPCODE_IS_EVEN           128
#define SC_OPCODE_IS_ODD            129
#define SC_OPCODE_N                 130
#define SC_OPCODE_GET_DATE_VALUE    131     /* string functions */
#define SC_OPCODE_GET_TIME_VALUE    132
#define SC_OPCODE_CODE              133
#define SC_OPCODE_TRIM              134
#define SC_OPCODE_UPPER             135
#define SC_OPCODE_PROPPER           136
#define SC_OPCODE_LOWER             137
#define SC_OPCODE_LEN               138
#define SC_OPCODE_T                 139     /* miscellaneous, part 21 */
#define SC_OPCODE_VALUE             140
#define SC_OPCODE_CLEAN             141
#define SC_OPCODE_CHAR              142
#define SC_OPCODE_LOG10             143
#define SC_OPCODE_EVEN              144
#define SC_OPCODE_ODD               145
#define SC_OPCODE_STD_NORM_DIST     146
#define SC_OPCODE_FISHER            147
#define SC_OPCODE_FISHER_INV        148
#define SC_OPCODE_S_NORM_INV        149
#define SC_OPCODE_GAMMA_LN          150
#define SC_OPCODE_ERROR_TYPE        151
#define SC_OPCODE_ERR_CELL          152
#define SC_OPCODE_FORMULA           153
#define SC_OPCODE_ARABIC            154
#define SC_OPCODE_INFO              155
#define SC_OPCODE_BAHTTEXT          156
#define SC_OPCODE_JIS               157
#define SC_OPCODE_ASC               158
#define SC_OPCODE_UNICODE           159
#define SC_OPCODE_UNICHAR           160
#define SC_OPCODE_GAMMA             161
#define SC_OPCODE_STOP_1_PAR        162

/*** Functions with more than one parameters ***/
#define SC_OPCODE_START_2_PAR       201
#define SC_OPCODE_ARC_TAN_2         201
#define SC_OPCODE_CEIL              202
#define SC_OPCODE_FLOOR             203
#define SC_OPCODE_ROUND             204
#define SC_OPCODE_ROUND_UP          205
#define SC_OPCODE_ROUND_DOWN        206
#define SC_OPCODE_TRUNC             207
#define SC_OPCODE_LOG               208
#define SC_OPCODE_POWER             209
#define SC_OPCODE_GGT               210
#define SC_OPCODE_KGV               211
#define SC_OPCODE_MOD               212
#define SC_OPCODE_SUM_PRODUCT       213
#define SC_OPCODE_SUM_SQ            214
#define SC_OPCODE_SUM_X2MY2         215
#define SC_OPCODE_SUM_X2DY2         216
#define SC_OPCODE_SUM_XMY2          217
#define SC_OPCODE_GET_DATE          218
#define SC_OPCODE_GET_TIME          219
#define SC_OPCODE_GET_DIFF_DATE     220
#define SC_OPCODE_GET_DIFF_DATE_360 221
#define SC_OPCODE_MIN               222
#define SC_OPCODE_MAX               223
#define SC_OPCODE_SUM               224
#define SC_OPCODE_PRODUCT           225
#define SC_OPCODE_AVERAGE           226
#define SC_OPCODE_COUNT             227
#define SC_OPCODE_COUNT_2           228
#define SC_OPCODE_NBW               229
#define SC_OPCODE_IKV               230
#define SC_OPCODE_VAR               231
#define SC_OPCODE_VAR_P             232
#define SC_OPCODE_ST_DEV            233
#define SC_OPCODE_ST_DEV_P          234
#define SC_OPCODE_B                 235
#define SC_OPCODE_NORM_DIST         236
#define SC_OPCODE_EXP_DIST          237
#define SC_OPCODE_BINOM_DIST        238
#define SC_OPCODE_POISSON_DIST      239
#define SC_OPCODE_KOMBIN            240
#define SC_OPCODE_KOMBIN_2          241
#define SC_OPCODE_VARIATIONEN       242
#define SC_OPCODE_VARIATIONEN_2     243
#define SC_OPCODE_BW                244
#define SC_OPCODE_DIA               245
#define SC_OPCODE_GDA               246
#define SC_OPCODE_GDA_2             247
#define SC_OPCODE_VBD               248
#define SC_OPCODE_LAUFZ             249
#define SC_OPCODE_LIA               250
#define SC_OPCODE_RMZ               251
#define SC_OPCODE_COLUMNS           252
#define SC_OPCODE_ROWS              253
#define SC_OPCODE_COLUMN            254
#define SC_OPCODE_ROW               255
#define SC_OPCODE_ZGZ               256
#define SC_OPCODE_ZW                257
#define SC_OPCODE_ZZR               258
#define SC_OPCODE_ZINS              259
#define SC_OPCODE_ZINS_Z            260
#define SC_OPCODE_KAPZ              261
#define SC_OPCODE_KUM_ZINS_Z        262
#define SC_OPCODE_KUM_KAP_Z         263
#define SC_OPCODE_EFFEKTIV          264
#define SC_OPCODE_NOMINAL           265
#define SC_OPCODE_SUB_TOTAL         266
#define SC_OPCODE_DB_SUM            267     /* database functions */
#define SC_OPCODE_DB_COUNT          268
#define SC_OPCODE_DB_COUNT_2        269
#define SC_OPCODE_DB_AVERAGE        270
#define SC_OPCODE_DB_GET            271
#define SC_OPCODE_DB_MAX            272
#define SC_OPCODE_DB_MIN            273
#define SC_OPCODE_DB_PRODUCT        274
#define SC_OPCODE_DB_STD_DEV        275
#define SC_OPCODE_DB_STD_DEV_P      276
#define SC_OPCODE_DB_VAR            277
#define SC_OPCODE_DB_VAR_P          278
#define SC_OPCODE_INDIRECT          279     /* management functions */
#define SC_OPCODE_ADDRESS           280
#define SC_OPCODE_MATCH             281
#define SC_OPCODE_COUNT_EMPTY_CELLS 282
#define SC_OPCODE_COUNT_IF          283
#define SC_OPCODE_SUM_IF            284
#define SC_OPCODE_LOOKUP            285
#define SC_OPCODE_V_LOOKUP          286
#define SC_OPCODE_H_LOOKUP          287
#define SC_OPCODE_MULTI_AREA        288
#define SC_OPCODE_OFFSET            289
#define SC_OPCODE_INDEX             290
#define SC_OPCODE_AREAS             291
#define SC_OPCODE_CURRENCY          292     /* string functions */
#define SC_OPCODE_REPLACE           293
#define SC_OPCODE_FIXED             294
#define SC_OPCODE_FIND              295
#define SC_OPCODE_EXACT             296
#define SC_OPCODE_LEFT              297
#define SC_OPCODE_RIGHT             298
#define SC_OPCODE_SEARCH            299
#define SC_OPCODE_MID               300
#define SC_OPCODE_TEXT              301
#define SC_OPCODE_SUBSTITUTE        302
#define SC_OPCODE_REPT              303
#define SC_OPCODE_CONCAT            304
#define SC_OPCODE_MAT_VALUE         305     /* matrix functions */
#define SC_OPCODE_MAT_DET           306
#define SC_OPCODE_MAT_INV           307
#define SC_OPCODE_MAT_MULT          308
#define SC_OPCODE_MAT_TRANS         309
#define SC_OPCODE_MATRIX_UNIT       310
#define SC_OPCODE_BACK_SOLVER       311     /* BackSolver */
#define SC_OPCODE_HYP_GEOM_DIST     312     /* statistical functions */
#define SC_OPCODE_LOG_NORM_DIST     313
#define SC_OPCODE_T_DIST            314
#define SC_OPCODE_F_DIST            315
#define SC_OPCODE_CHI_DIST          316
#define SC_OPCODE_WEIBULL           317
#define SC_OPCODE_NEG_BINOM_VERT    318
#define SC_OPCODE_KRIT_BINOM        319
#define SC_OPCODE_KURT              320
#define SC_OPCODE_HAR_MEAN          321
#define SC_OPCODE_GEO_MEAN          322
#define SC_OPCODE_STANDARD          323
#define SC_OPCODE_AVE_DEV           324
#define SC_OPCODE_SCHIEFE           325
#define SC_OPCODE_DEV_SQ            326
#define SC_OPCODE_MEDIAN            327
#define SC_OPCODE_MODAL_VALUE       328
#define SC_OPCODE_Z_TEST            329
#define SC_OPCODE_T_TEST            330
#define SC_OPCODE_RANK              331
#define SC_OPCODE_PERCENTILE        332
#define SC_OPCODE_PERCENT_RANK      333
#define SC_OPCODE_LARGE             334
#define SC_OPCODE_SMALL             335
#define SC_OPCODE_FREQUENCY         336
#define SC_OPCODE_QUARTILE          337
#define SC_OPCODE_NORM_INV          338
#define SC_OPCODE_CONFIDENCE        339
#define SC_OPCODE_F_TEST            340
#define SC_OPCODE_TRIM_MEAN         341
#define SC_OPCODE_PROB              342
#define SC_OPCODE_CORREL            343
#define SC_OPCODE_COVAR             344
#define SC_OPCODE_PEARSON           345
#define SC_OPCODE_RSQ               346
#define SC_OPCODE_STEYX             347
#define SC_OPCODE_SLOPE             348
#define SC_OPCODE_INTERCEPT         349
#define SC_OPCODE_TREND             350
#define SC_OPCODE_GROWTH            351
#define SC_OPCODE_RGP               352
#define SC_OPCODE_RKP               353
#define SC_OPCODE_FORECAST          354
#define SC_OPCODE_CHI_INV           355
#define SC_OPCODE_GAMMA_DIST        356
#define SC_OPCODE_GAMMA_INV         357
#define SC_OPCODE_T_INV             358
#define SC_OPCODE_F_INV             359
#define SC_OPCODE_CHI_TEST          360
#define SC_OPCODE_LOG_INV           361
#define SC_OPCODE_TABLE_OP          362
#define SC_OPCODE_BETA_DIST         363
#define SC_OPCODE_BETA_INV          364
#define SC_OPCODE_WEEK              365     /* miscellaneous */
#define SC_OPCODE_GET_DAY_OF_WEEK   366
#define SC_OPCODE_NO_NAME           367
#define SC_OPCODE_STYLE             368
#define SC_OPCODE_DDE               369
#define SC_OPCODE_BASE              370
#define SC_OPCODE_TABLE             371
#define SC_OPCODE_TABLES            372
#define SC_OPCODE_MIN_A             373
#define SC_OPCODE_MAX_A             374
#define SC_OPCODE_AVERAGE_A         375
#define SC_OPCODE_ST_DEV_A          376
#define SC_OPCODE_ST_DEV_P_A        377
#define SC_OPCODE_VAR_A             378
#define SC_OPCODE_VAR_P_A           379
#define SC_OPCODE_EASTERSUNDAY      380
#define SC_OPCODE_DECIMAL           381
#define SC_OPCODE_CONVERT           382
#define SC_OPCODE_ROMAN             383
#define SC_OPCODE_MIRR              384
#define SC_OPCODE_CELL              385
#define SC_OPCODE_ISPMT             386
#define SC_OPCODE_HYPERLINK         387
#define SC_OPCODE_INDIRECT_XL       388     /* See also INDIRECT for OOO variant */
#define SC_OPCODE_ADDRESS_XL        389     /* See also ADRESS for OOO variant */
#define SC_OPCODE_GET_PIVOT_DATA    390
#define SC_OPCODE_EUROCONVERT       391
#define SC_OPCODE_NUMBERVALUE       392
#define SC_OPCODE_CHISQ_DIST        393
#define SC_OPCODE_CHISQ_INV         394
#define SC_OPCODE_BITAND            395
#define SC_OPCODE_BITOR             396
#define SC_OPCODE_BITXOR            397
#define SC_OPCODE_BITRSHIFT         398
#define SC_OPCODE_BITLSHIFT         399
#define SC_OPCODE_GET_DATEDIF       400
#define SC_OPCODE_XOR               401
#define SC_OPCODE_AVERAGE_IF        402
#define SC_OPCODE_SUM_IFS           403
#define SC_OPCODE_AVERAGE_IFS       404
#define SC_OPCODE_COUNT_IFS         405
#define SC_OPCODE_SKEWP             406
#define SC_OPCODE_LENB              407
#define SC_OPCODE_RIGHTB            408
#define SC_OPCODE_LEFTB             409
#define SC_OPCODE_MIDB              410
#define SC_OPCODE_FILTERXML         411
#define SC_OPCODE_WEBSERVICE        412
#define SC_OPCODE_COVARIANCE_S      413
#define SC_OPCODE_COVARIANCE_P      414
#define SC_OPCODE_ST_DEV_P_MS       415
#define SC_OPCODE_ST_DEV_S          416
#define SC_OPCODE_VAR_P_MS          417
#define SC_OPCODE_VAR_S             418
#define SC_OPCODE_BETA_DIST_MS      419
#define SC_OPCODE_BETA_INV_MS       420
#define SC_OPCODE_BINOM_DIST_MS     421
#define SC_OPCODE_BINOM_INV         422
#define SC_OPCODE_CHI_DIST_MS       423
#define SC_OPCODE_CHI_INV_MS        424
#define SC_OPCODE_CHI_TEST_MS       425
#define SC_OPCODE_CHISQ_DIST_MS     426
#define SC_OPCODE_CHISQ_INV_MS      427
#define SC_OPCODE_CONFIDENCE_N      428
#define SC_OPCODE_CONFIDENCE_T      429
#define SC_OPCODE_F_DIST_LT         430
#define SC_OPCODE_F_DIST_RT         431
#define SC_OPCODE_F_INV_LT          432
#define SC_OPCODE_F_INV_RT          433
#define SC_OPCODE_F_TEST_MS         434
#define SC_OPCODE_EXP_DIST_MS       435
#define SC_OPCODE_HYP_GEOM_DIST_MS  436
#define SC_OPCODE_POISSON_DIST_MS   437
#define SC_OPCODE_WEIBULL_MS        438

#define SC_OPCODE_STOP_2_PAR        439     /* last function with two or more parameters' OpCode + 1 */
#define SC_OPCODE_STOP_FUNCTION     SC_OPCODE_STOP_2_PAR            /* last function's OpCode + 1 */
#define SC_OPCODE_LAST_OPCODE_ID    (SC_OPCODE_STOP_FUNCTION - 1)   /* last OpCode */

/*** Internal ***/
#define SC_OPCODE_INTERNAL_BEGIN   9999
#define SC_OPCODE_TTT              9999
#define SC_OPCODE_INTERNAL_END     9999

/*** from here on ExtraData contained ***/
#define SC_OPCODE_DATA_TOKEN_1    10000

#define SC_OPCODE_NONE           0xFFFF


#endif /* FORMULA_COMPILER_HRC */

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */