summaryrefslogtreecommitdiff
path: root/c-flex-bison/tree.h
blob: 78a4c80e522f363fa002870aada1fac0c947f30f (plain)
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
enum tree_type {
  parenthesized,
  escaped_run,
  delimiter_run,
};

struct forest {
  struct tree **trees;
  int tree_num;
};

struct raw {
  char *data;
  int len;
};

struct tree
{
  enum tree_type type;
  union {
    struct forest *children;
    struct raw literal;
  };
};

struct tree *tree_alloc(enum tree_type type, char *raw, size_t len);
struct forest *forest_alloc();
void plant_tree(struct forest *forest, struct tree *tree);

void print_tree (struct tree *tree, int debug);
void print_forest (struct forest *forest, int debug);