- Clone the project
cd Boomslang/app/
make
./interpreter
program (examples see below)
- Types
- int
- bool
- string
- void
- fun(type_1, type_2, ..., type_n -> returnType)
- Variables, final variables, functional variables
- Overshadow variables
- Basic arithmetics (Add/Sub, Mul/Div, Mod, Comparisons)
- Assignment
- if, else conditional blocks
- while loop (break, continue, return early form function)
- For loop (iterator is const, return early from function)
- Functions
- Recursion supported
- Nested functions
- Lambdas with recursion
- Closure
- Runtime error handling
int factorial(int a) {
int r = 1;
while (a > 0) {
r = r * a;
a = a - 1;
}
return r;
}
void main() {
// 5 factorial is 120
print("Factorial of 5 is " + factorial(5));
}
void testReturnInFor() {
for (int i = 0 to 50) {
if (i == 5) {
return;
}
print(i);
}
}
void main() {
testReturnInFor();
}