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, |
1e292005 | 25 | Prog, Arg, Call, List, Edit, Del, |
226557a3 LM |
26 | Get, Length, Pop, Push, Put, Set, Show, |
27 | Max, Mean, Median, Min, Order, Prod, Sum, Variance | |
bc97a989 LM |
28 | } func_t; |
29 | ||
30 | /* keyword type */ | |
31 | ||
32 | typedef struct _keyword_t { | |
33 | char *keyword; | |
34 | func_t func; | |
35 | int nbops; | |
36 | int offset; | |
ca3e2a2f | 37 | float prio; |
bc97a989 LM |
38 | } keyword_t; |
39 | ||
40 | /* calculus element type */ | |
41 | ||
bc97a989 LM |
42 | typedef struct _element_t { |
43 | func_t func; | |
44 | int nbops; | |
0c95a3d3 | 45 | struct _element_t **ops; |
fd88e359 | 46 | double value; |
11cda8d7 | 47 | int prio; |
2d0cd54c | 48 | int hidden; |
779282bb | 49 | char *string; |
bc97a989 LM |
50 | } element_t; |
51 | ||
0b489a77 LM |
52 | #define ERROR_OP ((element_t *)(-1)) |
53 | ||
c7cbb833 LM |
54 | /* workspace type */ |
55 | ||
56 | typedef struct _workspace_t { | |
57 | int id; | |
58 | double answer; | |
59 | double *storage; | |
05aabb97 | 60 | int storage_size; |
1e292005 LM |
61 | double *argument; |
62 | int argument_size; | |
c7cbb833 | 63 | element_t *root; |
a9a3da22 LM |
64 | double *stack; |
65 | int stack_size; | |
2e34899a | 66 | char *string; |
c7cbb833 LM |
67 | } workspace_t; |
68 | ||
bc97a989 LM |
69 | /* parser function */ |
70 | ||
031d7bba LM |
71 | void delelement (element_t *root); |
72 | ||
ef37d966 | 73 | element_t *parser (char *str, char **next, int prio); |
bc97a989 LM |
74 | |
75 | void print_element (element_t *root, int level); | |
76 | ||
3b4b0bbe | 77 | double evaluate_element (element_t *root, char mask); |
f2927108 | 78 | |
b9c1c40d LM |
79 | /* completion functions */ |
80 | ||
81 | char **generate_completion_list (); | |
82 | ||
83 | void free_completion_list (char **list); | |
84 | ||
2a5ec9d1 LM |
85 | /* print function */ |
86 | ||
87 | void set_format (char *prompt, int precision); | |
88 | ||
89 | void free_format (); | |
90 | ||
91 | double print (double value); | |
92 | ||
bc97a989 LM |
93 | #endif /* __PARSER_H__ */ |
94 | ||
95 | /* vim: set ts=4 sw=4 et: */ |