734d818f173f4bc1a1ca39ac01de405c804df77a
[calc.git] / parser.h
1 #ifndef __PARSER_H__
2 #define __PARSER_H__
3
4 /* global variables */
5
6 extern double answer;
7
8 /* function type */
9
10 typedef enum {
11 Val = 0, Sig,
12 Add, Sub,
13 Mul, Div, Mod,
14 Pow, Sqr,
15 Cos, Sin, Atan,
16 Log, Exp,
17 Store, Recall, Inc, Dec, Disp,
18 Quit, Help,
19 Ans, E, Pi,
20 Equal, Diff, Ge, Le, Gt, Lt,
21 And, Or, Not,
22 Cond, While, Prog
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;
32 float prio;
33 } keyword_t;
34
35 /* calculus element type */
36
37 typedef struct _element_t {
38 func_t func;
39 int nbops;
40 struct _element_t **ops;
41 double value;
42 int prio;
43 } element_t;
44
45 #define ERROR_OP ((element_t *)(-1))
46
47 /* parser function */
48
49 void delelement (element_t *root);
50
51 element_t *parser (char *str, char **next, int prio);
52
53 void print_element (element_t *root, int level);
54
55 double evaluate_element (element_t *root, char mask);
56
57 #endif /* __PARSER_H__ */
58
59 /* vim: set ts=4 sw=4 et: */