rename runtime to std and update example

This commit is contained in:
sam 2024-07-21 02:16:36 +12:00
parent f4a08bdfbd
commit 786d85463a
5 changed files with 6 additions and 5 deletions

View file

@ -1 +1,2 @@
(print_str "guh")
(print_str "hello world")
(print_num (add 5 (divide 100 5)))

View file

@ -3,7 +3,7 @@
const char* codegen(ASTNode* node) {
if(node->type == AST_PROGRAM) {
sl_string code = sl_string("#include <runtime.h>\n\nint main() {\n");
sl_string code = sl_string("#include <std.h>\n\nint main() {\n");
for(sl_vec_it(n, node->body)) {
sl_append_c_str(&code, codegen(*n));
sl_append_c_str(&code, ";\n");

View file

@ -32,8 +32,8 @@ int main(int argc, char* argv[]) {
TCCState* state = tcc_new();
assert(tcc_set_output_type(state, TCC_OUTPUT_EXE) == 0);
tcc_set_lib_path(state, "lib/tcc");
assert(tcc_add_include_path(state, "runtime") == 0);
assert(tcc_add_file(state, "runtime/runtime.c") == 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);

View file

@ -1,4 +1,4 @@
#include "runtime.h"
#include "std.h"
#include <stdio.h>
int add(int a, int b) {