compiler/src/main.c

34 lines
696 B
C
Raw Normal View History

2024-07-21 02:04:32 +12:00
#define SL_IMPLEMENTATION
#include <slibs/slibs.h>
2024-07-22 13:02:37 +12:00
2024-07-21 02:04:32 +12:00
#include <tokenizer.h>
#include <ast.h>
#include <codegen.h>
2024-07-22 13:02:37 +12:00
#include <binary.h>
#include <helpers.h>
2024-07-21 02:04:32 +12:00
int main(int argc, char* argv[]) {
2024-07-22 13:02:37 +12:00
Args args = parse_args(argc, argv);
2024-07-21 02:04:32 +12:00
sl_string buffer = { 0 };
2024-07-22 13:02:37 +12:00
sl_read_file(args.input, &buffer);
2024-07-21 02:04:32 +12:00
printf("Tokens:\n");
2024-07-22 15:46:25 +12:00
TokenVec tokens = { 0 };
tokenize(sl_c_str(buffer), &tokens);
2024-07-22 13:02:37 +12:00
tokens_print(tokens);
2024-07-21 02:04:32 +12:00
printf("\n");
printf("AST:\n");
2024-07-22 13:02:37 +12:00
ASTNode* program = ast_parse(&tokens);
2024-07-21 02:04:32 +12:00
ast_print(program, 0);
printf("\n");
printf("Codegen:\n");
const char* code = codegen(program);
printf("%s\n\n", code);
2024-07-22 13:02:37 +12:00
binary_produce(code, args);
2024-07-21 02:04:32 +12:00
2024-07-22 13:02:37 +12:00
return 0;
2024-07-21 02:04:32 +12:00
}