blob: b344a7b39b63db767092738f151b30ada7c7a237 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
|