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