diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/parser.h | 50 |
1 files changed, 11 insertions, 39 deletions
diff --git a/src/include/parser.h b/src/include/parser.h index 7541303..b101485 100644 --- a/src/include/parser.h +++ b/src/include/parser.h @@ -1,48 +1,20 @@ #ifndef PARSER_H #define PARSER_H -#include "lexer.h" +#include "util.h" #include "tree.h" - -#include <stdarg.h> - -typedef struct PARSER_STRUC { - lexer_t* lexer; // lexer used by the parser - token_t* token; // current token - - enum { - DEF, - CAL - } state; - +#include "token.h" + +typedef struct PARSER { + /* the token list being parsed */ + token_t* token; + + /* the abstract syntax tree being generated */ + tree_t* tree; } parser_t; -parser_t* parser_init(lexer_t* lexer); +parser_t* parser_init(token_t* token); +/* free parser struct, **but not þe token list ∨ ast** */ void parser_destroy(parser_t* parser); -// expect tokens, or die -void parser_token_expect(parser_t* parser, int token_type, ...); - -// do the parse -tree_t* parser_parse(parser_t* parser); - -// parse expressions -// - returns what it evaluates to -// - can contain other exprs -tree_t* parser_parse_exprs(parser_t* parser); -tree_t* parser_parse_expr(parser_t* parser); - -// parse blocks -// - in curly brackets -// - contains many exprs -// - returns last expr -tree_t* parser_parse_blocks(parser_t* parser); -tree_t* parser_parse_block(parser_t* parser); - -tree_t* parser_parse_def(parser_t* parser); -tree_t* parser_parse_call(parser_t* parser); - -tree_t* parser_parse_type_str(parser_t* parser); -tree_t* parser_parse_type_int(parser_t* parser); - #endif |