Commit | Line | Data |
---|---|---|
bc97a989 LM |
1 | #ifndef __PARSER_H__ |
2 | #define __PARSER_H__ | |
3 | ||
4 | /* function type */ | |
5 | ||
6 | typedef enum { | |
7 | Val = 0, | |
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 | ||
26 | #define MAX_OPERANDS 2 | |
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 | ||
34 | /* parser function */ | |
35 | ||
36 | element_t *parser (char *str); | |
37 | ||
38 | void print_element (element_t *root, int level); | |
39 | ||
40 | #endif /* __PARSER_H__ */ | |
41 | ||
42 | /* vim: set ts=4 sw=4 et: */ |