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, | |
9e52bbc5 | 15 | Cos, Sin, Tan, Acos, Asin, Atan, |
3b4b0bbe | 16 | Log, Exp, |
9e52bbc5 | 17 | Abs, Ceil, Floor, |
143f91ae | 18 | Store, Recall, Inc, Dec, Disp, Mem, Clear, |
471da7c9 | 19 | Quit, Help, |
7fe742c9 | 20 | Ans, E, Pi, |
ca3e2a2f | 21 | Equal, Diff, Ge, Le, Gt, Lt, |
94b4e517 | 22 | And, Or, Not, |
05aabb97 | 23 | Cond, While, Code, Print, |
c7cbb833 | 24 | Prog, Call, List, Edit, Del |
bc97a989 LM |
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; | |
ca3e2a2f | 34 | float prio; |
bc97a989 LM |
35 | } keyword_t; |
36 | ||
37 | /* calculus element type */ | |
38 | ||
bc97a989 LM |
39 | typedef struct _element_t { |
40 | func_t func; | |
41 | int nbops; | |
0c95a3d3 | 42 | struct _element_t **ops; |
fd88e359 | 43 | double value; |
11cda8d7 | 44 | int prio; |
2d0cd54c | 45 | int hidden; |
779282bb | 46 | char *string; |
bc97a989 LM |
47 | } element_t; |
48 | ||
0b489a77 LM |
49 | #define ERROR_OP ((element_t *)(-1)) |
50 | ||
c7cbb833 LM |
51 | /* workspace type */ |
52 | ||
53 | typedef struct _workspace_t { | |
54 | int id; | |
55 | double answer; | |
56 | double *storage; | |
05aabb97 | 57 | int storage_size; |
c7cbb833 | 58 | element_t *root; |
2e34899a | 59 | char *string; |
c7cbb833 LM |
60 | } workspace_t; |
61 | ||
bc97a989 LM |
62 | /* parser function */ |
63 | ||
031d7bba LM |
64 | void delelement (element_t *root); |
65 | ||
ef37d966 | 66 | element_t *parser (char *str, char **next, int prio); |
bc97a989 LM |
67 | |
68 | void print_element (element_t *root, int level); | |
69 | ||
3b4b0bbe | 70 | double evaluate_element (element_t *root, char mask); |
f2927108 | 71 | |
b9c1c40d LM |
72 | /* completion functions */ |
73 | ||
74 | char **generate_completion_list (); | |
75 | ||
76 | void free_completion_list (char **list); | |
77 | ||
2a5ec9d1 LM |
78 | /* print function */ |
79 | ||
80 | void set_format (char *prompt, int precision); | |
81 | ||
82 | void free_format (); | |
83 | ||
84 | double print (double value); | |
85 | ||
bc97a989 LM |
86 | #endif /* __PARSER_H__ */ |
87 | ||
88 | /* vim: set ts=4 sw=4 et: */ |