feat: enhance compiler
- Add comments and test for it - Add semicolon as required end of some expressions - Add new arguments parser - Add multi-file compilation - Add colors in output
This commit is contained in:
+6
-6
@@ -1,7 +1,7 @@
|
||||
printline(2 + 2 * 2)
|
||||
printline(-1 + 1)
|
||||
printline(2 ^ 2)
|
||||
printline(1 + 1 * 1 / 1)
|
||||
printline(4 % 2)
|
||||
printline(10 / 2)
|
||||
printline(2 + 2 * 2);
|
||||
printline(-1 + 1);
|
||||
printline(2 ^ 2);
|
||||
printline(1 + 1 * 1 / 1);
|
||||
printline(4 % 2);
|
||||
printline(10 / 2);
|
||||
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
// I'm a comment
|
||||
printline("Comment is skipped")
|
||||
printline("Comment is skipped");;;;;
|
||||
|
||||
|
||||
+5
-5
@@ -1,16 +1,16 @@
|
||||
bool flag = true
|
||||
bool flag = true;
|
||||
|
||||
if (!flag)
|
||||
printline("buhhh, flag is not true")
|
||||
printline("buhhh, flag is not true");
|
||||
else if (2 + 2 >= 4)
|
||||
{
|
||||
printline ("two plus two is four")
|
||||
printline ("two plus two is four");
|
||||
}
|
||||
else {
|
||||
printline("gotcha")
|
||||
printline("gotcha");
|
||||
}
|
||||
|
||||
{
|
||||
printline("block after")
|
||||
printline("block after");
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -1,24 +1,24 @@
|
||||
int fib(int n)
|
||||
{
|
||||
if (n <= 1)
|
||||
return n
|
||||
return n;
|
||||
|
||||
return fib(n - 1) + fib(n - 2)
|
||||
return fib(n - 1) + fib(n - 2);
|
||||
}
|
||||
|
||||
uint sum(uint a, uint b)
|
||||
{
|
||||
return a + b
|
||||
return a + b;
|
||||
}
|
||||
|
||||
printline("Test #1: fibonacci")
|
||||
int result = fib(7)
|
||||
printline("Test #1: fibonacci");
|
||||
int result = fib(7);
|
||||
if (result == 13)
|
||||
printline("Recurse test passed")
|
||||
else printline("Recurse test failed")
|
||||
printline("Recurse test passed");
|
||||
else printline("Recurse test failed");
|
||||
|
||||
printline("Test #2: sum")
|
||||
printline("Test #2: sum");
|
||||
if (sum(2, 2) == 4)
|
||||
printline("Sum test passed")
|
||||
else printline("Sum test failed")
|
||||
printline("Sum test passed");
|
||||
else printline("Sum test failed");
|
||||
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
printline('hello, world')
|
||||
printline('hello, world');
|
||||
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
printline("")
|
||||
printline("");
|
||||
|
||||
@@ -1 +1 @@
|
||||
printline("hello)
|
||||
printline("hello);
|
||||
|
||||
+9
-9
@@ -1,13 +1,13 @@
|
||||
uint work_it = 21 * 2 ^ 2
|
||||
int make_it = 10
|
||||
uint work_it = 21 * 2 ^ 2;
|
||||
int make_it = 10;
|
||||
|
||||
u64 do_it
|
||||
do_it = 15
|
||||
u64 do_it;
|
||||
do_it = 15;
|
||||
|
||||
printline(work_it)
|
||||
printline(make_it + do_it)
|
||||
printline(work_it);
|
||||
printline(make_it + do_it);
|
||||
|
||||
char make_us
|
||||
str floyd = "hello, Pink Floyd!"
|
||||
printline(floyd)
|
||||
char make_us;
|
||||
str floyd = "hello, Pink Floyd!";
|
||||
printline(floyd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user