aboutsummaryrefslogtreecommitdiff
path: root/src/tree.c
blob: b7677d3e62d1661aba0edd5da8e350a28b586e24 (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
#include "include/tree.h"

tree_t* tree_init(int type) {
   tree_t* tree = calloc(1, sizeof(struct TREE_STRUC));

   tree->type = type;

   switch (type) {
      case TREE_VAR_DEF:
         tree->data.var_def.name       = NULL;
         tree->data.var_def.val        = NULL;
         tree->data.var_def.is_const   = 0;
         break;
      case TREE_VAR:
         tree->data.var.name           = NULL;
         break;
      case TREE_FN_DEF:
         tree->data.fn_def.name        = NULL;
         tree->data.fn_def.val         = NULL;
         tree->data.fn_def.argv        = NULL;
         tree->data.fn_def.argsize     = 0;
         break;
      case TREE_FN_CALL:
         tree->data.fn_call.name       = NULL;
         tree->data.fn_call.argv       = NULL;
         tree->data.fn_call.argsize    = 0;
         break;
      case TREE_STR:
         tree->data.str.val            = NULL;
         tree->data.subtree.val        = NULL;
         tree->data.subtree.size       = 0;
         break;
   }

   return tree;
}