Fix syntax errors in compiler and clean up debug output
This commit is contained in:
parent
35a4fb7fef
commit
80caf6412c
19 changed files with 243 additions and 0 deletions
8
tests/test-arithmetic.c
Normal file
8
tests/test-arithmetic.c
Normal 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
5
tests/test-basic.c
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// test-basic.c
|
||||
int main(int argc, int argv)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
9
tests/test-complex-expressions.c
Normal file
9
tests/test-complex-expressions.c
Normal 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
9
tests/test-compound.c
Normal 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;
|
||||
}
|
||||
8
tests/test-expression-variables.c
Normal file
8
tests/test-expression-variables.c
Normal 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;
|
||||
}
|
||||
11
tests/test-function-call.c
Normal file
11
tests/test-function-call.c
Normal 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;
|
||||
}
|
||||
10
tests/test-function-decl.c
Normal file
10
tests/test-function-decl.c
Normal 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
8
tests/test-local-vars.c
Normal 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;
|
||||
}
|
||||
8
tests/test-multistatement.c
Normal file
8
tests/test-multistatement.c
Normal 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
10
tests/test-return.c
Normal 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);
|
||||
}
|
||||
8
tests/test-simple-arithmetic.c
Normal file
8
tests/test-simple-arithmetic.c
Normal 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;
|
||||
}
|
||||
10
tests/test-simple-function.c
Normal file
10
tests/test-simple-function.c
Normal 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);
|
||||
}
|
||||
5
tests/test-simple-return.c
Normal file
5
tests/test-simple-return.c
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// test-simple-return.c
|
||||
int main(int argc, int argv)
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
5
tests/test-simple.c
Normal file
5
tests/test-simple.c
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Simple test for basic compiler functionality
|
||||
int main(int argc, int argv)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
7
tests/test-variable-assign.c
Normal file
7
tests/test-variable-assign.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
// test-variable-assign.c
|
||||
int main(int argc, int argv)
|
||||
{
|
||||
int x = 5;
|
||||
x = 10;
|
||||
return x;
|
||||
}
|
||||
6
tests/test-variable-decl.c
Normal file
6
tests/test-variable-decl.c
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// test-variable-decl.c
|
||||
int main(int argc, int argv)
|
||||
{
|
||||
int x = 10;
|
||||
return x;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue