diff --git a/ccodegen.cpp b/ccodegen.cpp index 642a332..26ddacb 100644 --- a/ccodegen.cpp +++ b/ccodegen.cpp @@ -273,7 +273,7 @@ gen_ast(Ast *ast){ CASE(VAR, Decl){ gen_var(node->name, node->type, node->expr, is_inside_struct ? DONT_EMIT_VALUE : ALWAYS_EMIT_VALUE); - gen(";"); + if(!is_flag_set(ast->flags, AST_EXPR)) gen(";"); BREAK(); } @@ -477,7 +477,7 @@ compile_files(Array filename){ resolve_package(it); } -#if 0 +#if 1 gen(R"==( #include #include diff --git a/main.cpp b/main.cpp index 1253861..fab4267 100644 --- a/main.cpp +++ b/main.cpp @@ -181,7 +181,7 @@ int main(int argument_count, char **arguments){ test_intern_table(); -#if 0 +#if 1 emit_line_directives = true; if(argument_count > 1){ Scratch scratch; @@ -190,7 +190,9 @@ int main(int argument_count, char **arguments){ String compiler_call = string_fmt(scratch, "clang.exe %s.c -g -o %s.exe", arguments[1], arguments[1]); String run_program = string_fmt(scratch, "%s.exe", arguments[1]); - String result = compile_file(name); + Array files = {scratch}; + files.add(name); + String result = compile_files(files); FILE *f = fopen((const char *)c_filename.str, "w"); assert(f); fprintf(f, "%.*s", (int)result.len, result.str); @@ -201,7 +203,7 @@ int main(int argument_count, char **arguments){ system((const char *)run_program.str); } -#endif + #else Scratch scratch; Array files = {scratch}; // files.add("lambdas.kl"_s); @@ -213,5 +215,6 @@ int main(int argument_count, char **arguments){ // files.add("euler.kl"_s); String result = compile_files(files); printf("%s", result.str); +#endif __debugbreak(); }