aboutsummaryrefslogtreecommitdiff
path: root/src/include/tree.h
blob: 20c67145d3dcd099a6ed001761deddbf4128868a (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef TREE_H
#define TREE_H


#include <stdlib.h>


typedef struct PRIM_STRUC {
   int is_mutable;
   enum {
      STR,
      INT,
      UNKWN,
   } type; 

   union prim_union {
      struct str_struc {
         unsigned int* len;
         char* val;
      } prim_str;

      struct int_struc {
         int* val;
      } prim_int;

      struct unkwn_struc {
         void* val;
      } prim_unkwn;
   } val;
} prim_t;

typedef struct TREE_STRUC {
   enum {
      TREE_PRIM,
      TREE_SUBTREE,
      TREE_DEF,
      TREE_CALL,
   } type;

   union tree_union {

      struct prim_struc {
         prim_t* val;
      } prim;

      struct subtree_struc {
         struct TREE_STRUC** val;
         size_t size;
      } subtree;

      struct def_struc {
         char* name;
         prim_t** args;
         struct subtree_struc** val;
      } def;

      struct call_struc {
         char* name;
         prim_t** args;
      } call;

   } oftype;
} tree_t;

prim_t* prim_init(int type);
tree_t* tree_init(int type);


#endif