Fix syntax errors in compiler and clean up debug output

This commit is contained in:
10x Developer 2026-05-03 17:13:25 +02:00
parent 35a4fb7fef
commit 80caf6412c
19 changed files with 243 additions and 0 deletions

8
tests/test-arithmetic.c Normal file
View file

@ -0,0 +1,8 @@
// test-arithmetic.c
int main(int argc, int argv)
{
int a = 5;
int b = 3;
int c = a + b;
return c;
}

5
tests/test-basic.c Normal file
View file

@ -0,0 +1,5 @@
// test-basic.c
int main(int argc, int argv)
{
return 0;
}

View file

@ -0,0 +1,9 @@
// test-complex-expressions.c
int main(int argc, int argv)
{
int a = 2;
int b = 3;
int c = 4;
int result = a + b * c - 1;
return result;
}

9
tests/test-compound.c Normal file
View file

@ -0,0 +1,9 @@
// test-compound.c
int main(int argc, int argv)
{
int a = 5;
int b = 3;
int c = 2;
int result = a + b * c;
return result;
}

View file

@ -0,0 +1,8 @@
// test-expression-variables.c
int main(int argc, int argv)
{
int x = 10;
int y = 20;
int z = x + y;
return z;
}

View file

@ -0,0 +1,11 @@
// test-function-call.c
int add(int a, int b)
{
return a + b;
}
int main(int argc, int argv)
{
int result = add(5, 3);
return result;
}

View file

@ -0,0 +1,10 @@
// test-function-decl.c
int add(int a, int b)
{
return a + b;
}
int main(int argc, int argv)
{
return add(1, 2);
}

8
tests/test-local-vars.c Normal file
View file

@ -0,0 +1,8 @@
// test-local-vars.c
int main(int argc, int argv)
{
int a = 1;
int b = 2;
int c = a + b;
return c;
}

View file

@ -0,0 +1,8 @@
// test-multistatement.c
int main(int argc, int argv)
{
int a = 1;
int b = 2;
int c = a + b;
return c;
}

10
tests/test-return.c Normal file
View file

@ -0,0 +1,10 @@
// test-return.c
int return_test(int x)
{
return x;
}
int main(int argc, int argv)
{
return return_test(42);
}

View file

@ -0,0 +1,8 @@
// test-simple-arithmetic.c
int main(int argc, int argv)
{
int a = 10;
int b = 20;
int c = a + b;
return c;
}

View file

@ -0,0 +1,10 @@
// test-simple-function.c
int add(int a, int b)
{
return a + b;
}
int main(int argc, int argv)
{
return add(1, 2);
}

View file

@ -0,0 +1,5 @@
// test-simple-return.c
int main(int argc, int argv)
{
return 42;
}

5
tests/test-simple.c Normal file
View file

@ -0,0 +1,5 @@
// Simple test for basic compiler functionality
int main(int argc, int argv)
{
return 0;
}

View file

@ -0,0 +1,7 @@
// test-variable-assign.c
int main(int argc, int argv)
{
int x = 5;
x = 10;
return x;
}

View file

@ -0,0 +1,6 @@
// test-variable-decl.c
int main(int argc, int argv)
{
int x = 10;
return x;
}