| 1 | #ifndef __ELEMENT_H__ |
| 2 | #define __ELEMENT_H__ |
| 3 | |
| 4 | /* function type */ |
| 5 | |
| 6 | typedef enum { |
| 7 | Val = 0, Id, Sig, |
| 8 | Add, Sub, |
| 9 | Mul, Div, Mod, |
| 10 | Pow, Sqr, |
| 11 | Cos, Sin, Tan, Acos, Asin, Atan, |
| 12 | Ln, Log, Exp, |
| 13 | Erfc, Erf, |
| 14 | Abs, Ceil, Floor, |
| 15 | Store, Recall, Inc, Dec, Disp, Memory, Clear, |
| 16 | Quit, Help, History, |
| 17 | Ans, E, Pi, |
| 18 | Equal, Diff, Ge, Le, Gt, Lt, |
| 19 | And, Or, Not, |
| 20 | Cond, While, Code, Print, |
| 21 | Prog, Arg, Call, List, Edit, Del, |
| 22 | Get, Length, Pop, Push, Put, Set, Show, |
| 23 | Max, Mean, Median, Min, Order, Prod, Sum, Variance, |
| 24 | Precision, Base, Deg, Grad, Rad, |
| 25 | } func_t; |
| 26 | |
| 27 | /* keyword type */ |
| 28 | |
| 29 | typedef struct _keyword_t { |
| 30 | char *keyword; |
| 31 | func_t func; |
| 32 | int nbops; |
| 33 | int offset; |
| 34 | float prio; |
| 35 | } keyword_t; |
| 36 | |
| 37 | /* global variables */ |
| 38 | |
| 39 | #define NB_OPERATORS 14 |
| 40 | extern keyword_t operators[]; |
| 41 | |
| 42 | #define NB_FUNCTIONS 56 |
| 43 | extern keyword_t functions[]; |
| 44 | |
| 45 | #define NB_CONSTANTS 3 |
| 46 | extern keyword_t constants[]; |
| 47 | |
| 48 | #define NB_SYMBOLS 4 |
| 49 | extern char *symbols[]; |
| 50 | |
| 51 | /* calculus element type */ |
| 52 | |
| 53 | typedef struct _element_t { |
| 54 | func_t func; |
| 55 | int nbops; |
| 56 | struct _element_t **ops; |
| 57 | double value; |
| 58 | int prio; |
| 59 | int hidden; |
| 60 | char *string; |
| 61 | } element_t; |
| 62 | |
| 63 | #define ERROR_OP ((element_t *)(-1)) |
| 64 | |
| 65 | /* functions */ |
| 66 | |
| 67 | element_t *newelement (func_t function, int nbops, int prio); |
| 68 | void delelement (element_t *root); |
| 69 | element_t *dupelement (element_t *root); |
| 70 | |
| 71 | #endif /* __ELEMENT_H__ */ |
| 72 | |
| 73 | /* vim: set ts=4 sw=4 et: */ |