-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.h
52 lines (46 loc) · 1.24 KB
/
node.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef NODE_H
#define NODE_H
enum node_type_e
{
NODE_COMMAND,
NODE_VAR,
};
enum val_type_e
{
VAL_SINT = 1,
VAL_UINT,
VAL_SLLONG,
VAL_ULLONG,
VAL_FLOAT,
VAL_LDOUBLE,
VAL_CHR,
VAL_STR,
};
union symval_u
{
long sint;
unsigned long uint;
long long sllong;
unsigned long long ullong;
double sfloat;
long double ldouble;
char chr;
char *str;
};
struct node_s
{
enum node_type_e type;
enum val_type_e val_type;
union symval_u val;
int children;
struct node_s *first_child;
struct node_s *next_sibling, *prev_sibling; /*
* if this is a child node, keep
* pointers to prev/next siblings
*/
};
struct node_s *new_node(enum node_type_e type);
void add_child_node(struct node_s *parent, struct node_s *child);
void free_node_tree(struct node_s *node);
void set_node_val_str(struct node_s *node, char *val);
#endif