smcc/ccompiler/frontend/frontend.c
2025-04-01 00:13:21 +08:00

24 lines
526 B
C

#include <lib/core.h>
#include "frontend.h"
ast_node_t* cc_frontend(const char* file, void* stream, sread_fn sread) {
init_lib_core();
strpool_t strpool;
init_strpool(&strpool);
cc_lexer_t lexer;
init_lexer(&lexer, file, stream, sread, &strpool);
symtab_t symtab;
init_symtab(&symtab);
// TODO global scope
symtab_enter_scope(&symtab);
parser_t parser;
init_parser(&parser, &lexer, &symtab);
parse_prog(&parser);
// TODO Free the resourse
return parser.root;
}