aboutsummaryrefslogtreecommitdiff
path: root/src/include/tree.h
blob: 108f646b2590357becf1853107cc09c2d0fe72ea (plain) (blame)
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
#ifndef TREE_H
#define TREE_H

#include <stdlib.h>

typedef enum {
      LEAF_TYPE_INT,
      LEAF_TYPE_STR,
} leaf_t;

typedef struct ARG_T_STRUCT {
   leaf_t type;
   char* id;
   struct ARG_T_STRUCT* nxt;
} arg_t;

typedef struct TREE_T_STRUCT {
   enum TREE_TYPE {
      TREE_TYPE_DEF,
      TREE_TYPE_CAL,
   } type;

   union {
      struct {
         leaf_t type;
         char* id;
         arg_t* arg;
         struct TREE_T_STRUCT* val;
      } tree_def;

      struct {
         char* id;
         arg_t* arg;
      } tree_cal;
   } data;
} tree_t;

tree_t* tree_init(int type);
void tree_destroy(tree_t*);

#endif