#define SL_IMPLEMENTATION #include #include #include #include #include int main(int argc, char* argv[]) { assert(argc > 2); sl_string buffer = { 0 }; sl_read_file(argv[1], &buffer); Token* root = tokenize(sl_c_str(buffer)); printf("Tokens:\n"); Token* curr = root; while(curr != NULL) { printf("%s: %s\n", TokenTypeText[curr->type], curr->value); curr = curr->next; } printf("\n"); printf("AST:\n"); ASTNode* program = ast_parse(&root); ast_print(program, 0); printf("\n"); printf("Codegen:\n"); const char* code = codegen(program); printf("%s\n\n", code); TCCState* state = tcc_new(); tcc_set_lib_path(state, "tcc"); assert(tcc_set_output_type(state, TCC_OUTPUT_EXE) == 0); assert(tcc_add_include_path(state, "std") == 0); assert(tcc_add_file(state, "std/std.c") == 0); assert(tcc_compile_string(state, code) == 0); assert(tcc_output_file(state, argv[2]) == 0); printf("Binary produced: %s\n", argv[2]); }