diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/tree.h | 76 |
1 files changed, 51 insertions, 25 deletions
diff --git a/src/include/tree.h b/src/include/tree.h index 108f646..d19f1f7 100644 --- a/src/include/tree.h +++ b/src/include/tree.h @@ -3,39 +3,65 @@ #include <stdlib.h> -typedef enum { - LEAF_TYPE_INT, - LEAF_TYPE_STR, -} leaf_t; - -typedef struct ARG_T_STRUCT { - leaf_t type; - char* id; - struct ARG_T_STRUCT* nxt; -} arg_t; - -typedef struct TREE_T_STRUCT { +typedef struct TREE { enum TREE_TYPE { + TREE_TYPE_LINT, + TREE_TYPE_LSTR, + TREE_TYPE_TAG, + TREE_TYPE_DARG, + TREE_TYPE_CARG, TREE_TYPE_DEF, TREE_TYPE_CAL, } type; - union { - struct { - leaf_t type; - char* id; - arg_t* arg; - struct TREE_T_STRUCT* val; - } tree_def; - - struct { - char* id; - arg_t* arg; - } tree_cal; + union TREE_DATA{ + + /* literal integer */ + struct TREE_DATA_LINT { + int val; + } lint; + + /* literal string */ + struct TREE_DATA_LSTR { + size_t len; + char* val; + } lstr; + + /* tags */ + struct TREE_DATA_TAG { + char* val; + struct TREE_DATA_TAG* nxt; + } tag; + + /* definition arguments */ + struct TREE_DATA_DARG { + struct TREE_DATA_TAG* tag; + struct TREE_DATA_DARG* nxt; + } darg; + + /* call arguments */ + struct TREE_DATA_CARG { + struct TREE* val; + struct TREE_DATA_CARG* nxt; + } carg; + + /* definitions */ + struct TREE_DATA_DEF { + struct TREE_DATA_TAG* tag; + struct TREE_DATA_DARG* arg; + struct TREE* val; + } def; + + /* calls */ + struct TREE_DATA_CAL { + char* target; + struct TREE_DATA_CARG* arg; + } cal; + } data; } tree_t; tree_t* tree_init(int type); -void tree_destroy(tree_t*); +void tree_destroy(tree_t* tree); #endif |