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

#include <stdlib.h>

typedef struct TREE_STRUC {
   enum {
      TREE_COMP,
      TREE_DEF,
      TREE_CALL,
      TREE_TYPE_STR,
      TREE_TYPE_INT,
   } type;

   union {
      struct {                               // === "COMPOUND" ===
         struct TREE_STRUC**  value;
         size_t               size;
      } comp;

      struct {                               // === DEFINITIONS ===
         char*                type;          // the definition type
         char**               tags;          // the definition tags
         char*                name;          // the definition name
         struct TREE_STRUC*   value;         // value of definition
                                             // :D lines line up :D
      } def;

      struct {                               // === CALLS ===
         char*                target;        // name of definition being called
         struct TREE_STRUC**  args;          // arguments passed to definition
         size_t               args_size;     // size of arguments
      } call;

                                             // === TYPES ===
      struct {                               // strings
         char*                value;
      } type_str; 

      struct {                               // integers
         int                  value;
      } type_int;
   } data;
} tree_t;

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

#endif