Can call the compiler from command line with argument
This commit is contained in:
26
main.cpp
26
main.cpp
@@ -77,10 +77,9 @@ Expr:
|
||||
|
||||
|
||||
@todo
|
||||
[ ] - Passing down program to compile through command line
|
||||
[ ] - Arrays with size passed
|
||||
[ ] - Switch
|
||||
[ ] - Fix printf somehow.
|
||||
[ ] - Values inited to 0 by default
|
||||
|
||||
[ ] - Comma notation when declaring variables thing1, thing2: S32
|
||||
[ ] - Array of inferred size
|
||||
@@ -115,6 +114,7 @@ Expr:
|
||||
[x] - We are parsing wrong here: (t.str=(&string_to_lex.str)[i]);
|
||||
[x] - Test new operators, add constant eval for them
|
||||
[x] - lvalue, rvalue concept so we cant assign value to some arbitrary weird expression
|
||||
[x] - Passing down program to compile through command line
|
||||
[x] - More basic types
|
||||
[x] - Implementing required operations int128
|
||||
[x] - Fix casting
|
||||
@@ -161,7 +161,7 @@ Expr:
|
||||
#include "typecheck.cpp"
|
||||
#include "ccodegen.cpp"
|
||||
|
||||
int main(){
|
||||
int main(int argument_count, char **arguments){
|
||||
// test_big_int();
|
||||
|
||||
test_os_memory();
|
||||
@@ -191,15 +191,19 @@ int main(){
|
||||
printf("%s", result.str);
|
||||
#endif
|
||||
|
||||
if(argument_count > 1){
|
||||
Scratch scratch;
|
||||
String name = string_fmt(scratch, "%s.kl", arguments[1]);
|
||||
String c_filename = string_fmt(scratch, "%s.c", arguments[1]);
|
||||
String call = string_fmt(scratch, "clang.exe %s.c -g -o %s.exe && %s.exe", arguments[1], arguments[1], arguments[1]);
|
||||
|
||||
#if 1
|
||||
result = compile_file("program.kl"_s);
|
||||
FILE *f = fopen("program.c", "w");
|
||||
assert(f);
|
||||
fprintf(f, "%.*s", (int)result.len, result.str);
|
||||
fclose(f);
|
||||
system("clang.exe program.c -g -o program.exe");
|
||||
#endif
|
||||
result = compile_file(name);
|
||||
FILE *f = fopen((const char *)c_filename.str, "w");
|
||||
assert(f);
|
||||
fprintf(f, "%.*s", (int)result.len, result.str);
|
||||
fclose(f);
|
||||
system((const char *)call.str);
|
||||
}
|
||||
|
||||
__debugbreak();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user