diff options
author | c+1 | 2023-05-23 16:50:12 -0400 |
---|---|---|
committer | c+1 | 2023-05-23 16:50:12 -0400 |
commit | 5e273897bde728e84a7f34d552258ece7e4a4b33 (patch) | |
tree | a8d6a94c6dff6ae12832b4c1c1580c2da3d8cca2 /src | |
parent | 168417d4102de373ad0696ed3ab846f54226e570 (diff) |
AST finalized
Diffstat (limited to 'src')
-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); |