diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/parser.h | 10 | ||||
-rw-r--r-- | src/include/tree.h | 29 |
2 files changed, 24 insertions, 15 deletions
diff --git a/src/include/parser.h b/src/include/parser.h index deb6c7c..7541303 100644 --- a/src/include/parser.h +++ b/src/include/parser.h @@ -9,13 +9,19 @@ typedef struct PARSER_STRUC { lexer_t* lexer; // lexer used by the parser token_t* token; // current token + + enum { + DEF, + CAL + } state; + } parser_t; parser_t* parser_init(lexer_t* lexer); void parser_destroy(parser_t* parser); -// expect token(s), or die -void parser_token_expect(parser_t* parser, int token, ...); +// expect tokens, or die +void parser_token_expect(parser_t* parser, int token_type, ...); // do the parse tree_t* parser_parse(parser_t* parser); diff --git a/src/include/tree.h b/src/include/tree.h index 88287a4..a240a18 100644 --- a/src/include/tree.h +++ b/src/include/tree.h @@ -3,27 +3,30 @@ #include <stdlib.h> -typedef struct TREE_STRUC { +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 { enum TREE_TYPE { - TREE_TYPE_INT, - TREE_TYPE_STR, TREE_TYPE_DEF, TREE_TYPE_CAL, - TREE_TYPE_COND, } type; union { struct { - int val; - } tree_int_t; - - struct { - char* val; - } tree_str_t; - - struct { + leaf_t type; char* id; - } tree_def_t; + arg_t* arg; + struct TREE_T_STRUCT* val; + } tree_def; } data; } tree_t; |