Commit | Line | Data |
---|---|---|
bc97a989 LM |
1 | #ifndef __PARSER_H__ |
2 | #define __PARSER_H__ | |
3 | ||
4 | /* function type */ | |
5 | ||
6 | typedef enum { | |
0b489a77 | 7 | Val = 0, Set, |
bc97a989 LM |
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 | } keyword_t; | |
23 | ||
24 | /* calculus element type */ | |
25 | ||
0b489a77 | 26 | #define MAX_OPERANDS 10 |
bc97a989 LM |
27 | typedef struct _element_t { |
28 | func_t func; | |
29 | int nbops; | |
30 | struct _element_t *ops[MAX_OPERANDS]; | |
31 | float value; | |
32 | } element_t; | |
33 | ||
0b489a77 LM |
34 | #define ERROR_OP ((element_t *)(-1)) |
35 | ||
bc97a989 LM |
36 | /* parser function */ |
37 | ||
0b489a77 | 38 | element_t *parser (char *str, char **next); |
bc97a989 LM |
39 | |
40 | void print_element (element_t *root, int level); | |
41 | ||
42 | #endif /* __PARSER_H__ */ | |
43 | ||
44 | /* vim: set ts=4 sw=4 et: */ |