diff options
Diffstat (limited to 'include/parser.h')
-rw-r--r-- | include/parser.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/include/parser.h b/include/parser.h new file mode 100644 index 0000000..b344a7b --- /dev/null +++ b/include/parser.h @@ -0,0 +1,33 @@ +#ifndef CMONKEY_PARSER_H +#define CMONKEY_PARSER_H + +#include "ast.h" +#include "hmap.h" +#include "lexer.h" +#include "token.h" +#include "vector.h" + +struct parser { + struct lexer *lexer; + struct token cur_token; + struct token peek_token; + struct vector *errors; + struct hmap *prefix_fns; + struct hmap *infix_fns; + struct hmap *precedences; +}; + +typedef struct expression *(*prefix_parse_f)(struct parser *); +typedef struct expression *(*infix_parse_f)(struct parser *, struct expression *); + +struct parser *parser_new(); + +void parser_reset(struct parser *, const char *input); + +void parser_next_token(struct parser *); + +struct program *parser_parse_program(struct parser *); + +void parser_destroy(struct parser *); + +#endif |