diff options
-rw-r--r-- | src/include/tree.h | 79 |
1 files changed, 42 insertions, 37 deletions
diff --git a/src/include/tree.h b/src/include/tree.h index e42f761..cf02ee9 100644 --- a/src/include/tree.h +++ b/src/include/tree.h @@ -5,58 +5,63 @@ #include <stdlib.h> -typedef struct TREE_STRUC { - +typedef struct PRIM_STRUC { + int is_mutable; enum { - TREE_VAR_DEF, - TREE_VAR, + STR, + INT, + //ARR, + //FLOAT, + //STRUCT, + //NAMESPACE, + } type; + + union prim_union { + struct str_struc { + unsigned int len; + char* val; + }; - TREE_FN_DEF, - TREE_FN_CALL, - - TREE_STR, + struct int_struc { + int val; + }; + } with_value; +} prim_t; +typedef struct TREE_STRUC { + enum { + TREE_PRIM, TREE_SUBTREE, + TREE_DEF, + TREE_CALL, } type; union tree_union { - struct var_def_struc { - char* name; - struct TREE_STRUC* val; - int* is_const; - } var_def; - - struct var_struc { - char* name; - } var; - - struct fn_def_struc { - char* name; - struct TREE_STRUC** val; - struct TREE_STRUC** argv; - size_t argsize; - } fn_def; - - struct fn_call_struc { - char* name; - struct TREE_STRUC** argv; - size_t argsize; - } fn_call; - - struct str_struc { - char* val; - } str; + struct prim_struc { + prim_t* val; + } prim; struct subtree_struc { - struct TREE_STRUC** val; - size_t size; + struct TREE_STRUC** val; + size_t size; } subtree; - } data; + struct def_struc { + char* name; + prim_t** args; + struct subtree_struc** val; + } def; + + struct call_struc { + char* name; + prim_t** args; + } call; + } of_type; } tree_t; +prim_t* prim_init(int type); tree_t* tree_init(int type); |