Initial import from http://www.droids-corp.org/hg/libcmdline/rev/db316e4289a1
[libcmdline.git] / src / genconf / expression.h
1 #ifndef _EXPRESSION_H_
2 #define _EXPRESSION_H_
3
4 enum op_type {
5         OP_VAR,
6         OP_OBRACKET,
7         OP_CBRACKET,
8         OP_OR,
9         OP_AND,
10         OP_NOT,
11         OP_EQUAL,
12         OP_EOF,
13 };
14
15 struct expr_op {
16         enum op_type optype;
17         char *name; /* only valid if op==VAR */
18 };
19
20 struct expr_node {
21         TAILQ_ENTRY(expr_node) next;
22         struct expr_op op;
23         struct expr_node *left;
24         struct expr_node *right;
25 };
26
27 struct expr_node *parse_expression(char *buf);
28
29 void expression_free(struct expr_node *expression);
30 int expression_to_str(struct expr_node *n, char *buf, int len);
31 int expression_eval(struct expr_node *node);
32
33 #endif /* _EXPRESSION_H_ */