767fcf08bdc848c6005157f22368744e5b9e7ea7
[calc.git] / parser.h
1 #ifndef __PARSER_H__
2 #define __PARSER_H__
3
4 /* function type */
5
6 typedef enum {
7 Val = 0, Set,
8 Add, Sub,
9 Mul, Div, Pow,
10 Sqr,
11 Cos, Sin, Atn,
12 Log, Exp
13 } func_t;
14
15 /* keyword type */
16
17 typedef struct _keyword_t {
18 char *keyword;
19 func_t func;
20 int nbops;
21 int offset;
22 int prio;
23 } keyword_t;
24
25 /* calculus element type */
26
27 #define MAX_OPERANDS 10
28 typedef struct _element_t {
29 func_t func;
30 int nbops;
31 struct _element_t *ops[MAX_OPERANDS];
32 float value;
33 int prio;
34 } element_t;
35
36 #define ERROR_OP ((element_t *)(-1))
37
38 /* parser function */
39
40 element_t *parser (char *str, char **next, int prio);
41
42 void print_element (element_t *root, int level);
43
44 #endif /* __PARSER_H__ */
45
46 /* vim: set ts=4 sw=4 et: */