Fix lexer end of file not unwinding scopes, Trying to run a program

This commit is contained in:
Krzosa Karol
2022-06-01 14:00:42 +02:00
parent 02b6a1c85b
commit 82bb3ae493
4 changed files with 58 additions and 23 deletions

View File

@@ -32,7 +32,8 @@ For now I don't thing it should be overloadable.
-------------------------------------------------------------------------------
@todo
[ ] - lvalue, rvalue concept so we cant assign value to some arbitrary weird expression
[ ] - Compiling and running a program
[ ] - Passing down program to compile through command line
[ ] - More operators
[ ] - More for loop variations
[ ] - Fixing access to constants, in C we cant have constants inside of structs / functions so we need to rewrite the tree
@@ -50,6 +51,7 @@ For now I don't thing it should be overloadable.
[ ] - Constant arrays that evaluate fully at compile time
@donzo
[x] - lvalue, rvalue concept so we cant assign value to some arbitrary weird expression
[x] - Access through struct names to constants Arena.CONSTANT
[x] - Enums
[x] - Initial for loop
@@ -76,6 +78,10 @@ For now I don't thing it should be overloadable.
#include "typecheck.h"
#include "typecheck.cpp"
#include "ccodegen.cpp"
int main(){
test_os_memory();
@@ -89,6 +95,7 @@ int main(){
test_intern_table();
String result = {};
#if 0
result = compile_file("globals.kl"_s);
printf("%s", result.str);
result = compile_file("enums.kl"_s);
@@ -99,6 +106,14 @@ int main(){
printf("%s", result.str);
result = compile_file("lambdas.kl"_s);
printf("%s", result.str);
#endif
result = compile_file("lexer.kl"_s);
FILE *f = fopen("program.c", "w");
assert(f);
fprintf(f, "%.*s", (int)result.len, result.str);
fclose(f);
__debugbreak();
}