30 lines
744 B
C
30 lines
744 B
C
|
#include "mrk/parser_internal.h"
|
||
|
|
||
|
void mrk_parser_open(mrk_parser *parser, mrk_lexer *lexer) {
|
||
|
parser->lexer = lexer;
|
||
|
|
||
|
// Prefill lookahead buffer
|
||
|
for (size_t i = 0;
|
||
|
i < MRK_PARSER_LOOKAHEAD_BUF_SIZE && !mrk_lexer_done(lexer); i++) {
|
||
|
mrk_lexer_next(&parser->lookahead.buf[i], lexer);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
mrk_err mrk_parser_parse(mrk_ast_node **out, mrk_parser *parser) {
|
||
|
mrk_ast_node *root;
|
||
|
MRK_RES(mrk_ast_node_init(&root));
|
||
|
|
||
|
while (!mrk_lexer_done(parser->lexer)) {
|
||
|
mrk_ast_node *block_root;
|
||
|
|
||
|
MRK_RES(mrk_parser_parse_block(&block_root, parser));
|
||
|
MRK_RES(mrk_ast_node_child_append(root, block_root));
|
||
|
}
|
||
|
|
||
|
*out = root;
|
||
|
|
||
|
return mrk_err_ok;
|
||
|
}
|
||
|
|
||
|
mrk_err mrk_parser_parse_block(mrk_ast_node **out, mrk_parser *parser) {}
|