Commit | Line | Data |
---|---|---|
bc97a989 LM |
1 | #ifndef __PARSER_H__ |
2 | #define __PARSER_H__ | |
3 | ||
5075f6ea LM |
4 | /* global variables */ |
5 | ||
6 | extern double answer; | |
7 | ||
bc97a989 LM |
8 | /* function type */ |
9 | ||
10 | typedef enum { | |
89cf0955 | 11 | Val = 0, Sig, |
bc97a989 | 12 | Add, Sub, |
c47a9298 LM |
13 | Mul, Div, Mod, |
14 | Pow, Sqr, | |
471da7c9 | 15 | Cos, Sin, Atan, |
3b4b0bbe | 16 | Log, Exp, |
a8cf32ba | 17 | Store, Recall, Inc, Dec, Disp, |
471da7c9 | 18 | Quit, Help, |
7fe742c9 | 19 | Ans, E, Pi, |
ca3e2a2f | 20 | Equal, Diff, Ge, Le, Gt, Lt, |
94b4e517 | 21 | And, Or, Not, |
124da7fd | 22 | Cond, While, Prog |
bc97a989 LM |
23 | } func_t; |
24 | ||
25 | /* keyword type */ | |
26 | ||
27 | typedef struct _keyword_t { | |
28 | char *keyword; | |
29 | func_t func; | |
30 | int nbops; | |
31 | int offset; | |
ca3e2a2f | 32 | float prio; |
bc97a989 LM |
33 | } keyword_t; |
34 | ||
35 | /* calculus element type */ | |
36 | ||
bc97a989 LM |
37 | typedef struct _element_t { |
38 | func_t func; | |
39 | int nbops; | |
0c95a3d3 | 40 | struct _element_t **ops; |
fd88e359 | 41 | double value; |
11cda8d7 | 42 | int prio; |
bc97a989 LM |
43 | } element_t; |
44 | ||
0b489a77 LM |
45 | #define ERROR_OP ((element_t *)(-1)) |
46 | ||
bc97a989 LM |
47 | /* parser function */ |
48 | ||
031d7bba LM |
49 | void delelement (element_t *root); |
50 | ||
ef37d966 | 51 | element_t *parser (char *str, char **next, int prio); |
bc97a989 LM |
52 | |
53 | void print_element (element_t *root, int level); | |
54 | ||
3b4b0bbe | 55 | double evaluate_element (element_t *root, char mask); |
f2927108 | 56 | |
bc97a989 LM |
57 | #endif /* __PARSER_H__ */ |
58 | ||
59 | /* vim: set ts=4 sw=4 et: */ |