40 lines
1.2 KiB
C
40 lines
1.2 KiB
C
#include <stdio.h>
|
|
|
|
#include "parse.h"
|
|
#include "ast.h"
|
|
#include "compile.h"
|
|
|
|
int main(int argc, const char **argv) {
|
|
ast_init_parser();
|
|
FILE *file = fopen("bootstrap/test.sl", "r");
|
|
if (!file) {
|
|
perror("fopen");
|
|
}
|
|
TokenStream *stream = make_token_stream(file);
|
|
COMPILE_FORMAT = COMPILE_FORMAT_ASM;
|
|
CompileEnvironment *env = make_compile_environment();
|
|
AstErrorList *ast_errs;
|
|
CompileError *comp_errs;
|
|
while (!token_stream_is_eof(stream)) {
|
|
AstNode *node = ast_next_toplevel(stream, &ast_errs);
|
|
while (ast_errs) {
|
|
AstErrorList *err = ast_error_list_pop(&ast_errs);
|
|
ast_format_error(err, "test.sl", stderr);
|
|
ast_error_list_free_one(err);
|
|
}
|
|
if (node) {
|
|
ssize_t ninst = byte_compile_form(env, node, stdout, &comp_errs);
|
|
while (comp_errs) {
|
|
CompileError *err = compile_error_pop(&comp_errs);
|
|
compile_format_error(err, "test.sl", stderr);
|
|
compile_error_free_one(err);
|
|
}
|
|
}
|
|
destroy_ast_node(node);
|
|
}
|
|
destroy_compile_environment(env);
|
|
destroy_token_stream(stream);
|
|
ast_deinit_parser();
|
|
return 0;
|
|
}
|