Every programmer must write at least one compiler/interpreter, I follow this idea :D
Currently interpreter can execute this program
fun main(){
print("LOG: Main function loaded");
var a = 1;
var b = -1;
var c = -20;
print("LOG: Variables created");
var d = (b * b) - (4 * a * c);
print("LOG: Discriminant computed, value is", d.toString(d));
print("LOG: Checking for D < 0");
if(d < 0){
print("No roots.");
return;
}
print("LOG: Checking for D equals to 0");
if(d == 0){
print("One root.");
print("Root", -b / (2 * a));
return;
}
var x1 = (-b + sqr(d)) / (2 * a);
var x2 = (-b - sqr(d)) / (2 * a);
print("LOG: Roots computed.");
print("Two roots.");
print("First root:", x1.toString(x1));
print("Second root:", x2.toString(x2));
}
main();
Rita is dynamically typed language, you don't need to provide a typename for creating a variable, just only use var-keyword provide name and value!
var varName = "Hello, Rita!";
Rita support functions (fully), you can create, call, return values and provide arguments to your functions
// Create function with fun - keyword.
fun functionName(arg){
anotherFunc(); // call another function.
print(arg);
return;
}
If statement in Rita is similiar to Rust, if keyword, expression and body.
if a > 0{
print("Really, a is bigger than 0!");
}
Rita support while statements, use while-keyword, provide expression and code-block.
var a = 100;
while a > 0 {
print("working");
a -= 1;
}
Yes, you can use operators, priorities in Rita are fully correct.
var a = 2 + 2 * 3; // a equals to 8
sqr(); // Returns a square root of Int-object.
print(); // Prints string to terminal
input(); // EXPERIMENTAL! Returns a string given from user.
git clone https://github.com/ilyas-kalandar/Rita
cd Rita && mkdir build && cd build
cmake .. && cmake --build .
./rita
Usage: rita --file filename.rt
--ast - Show ast.
--tokens - Show tokens from tokenizer.
--help - Show this menu.
--version - Output version of language.
- - While-loops
- - Classes
- - Floats
Created with โฅ by Ilyas Qalandarzoda (Awaitable)
I always check my telegram