simple-lisp/bootstrap/main.c

30 lines
777 B
C

#include <stdio.h>
#include "parse.h"
#include "ast.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);
AstErrorList *errs;
while (!token_stream_is_eof(stream)) {
AstNode *node = ast_next_toplevel(stream, &errs);
if (node) {
ast_prin1_node(node, stdout);
}
while (errs) {
AstErrorList *err = ast_error_list_pop(&errs);
ast_format_error(err, "bootstrap/test.sl", stderr);
ast_error_list_free_one(err);
}
destroy_ast_node(node);
}
destroy_token_stream(stream);
ast_deinit_parser();
return 0;
}