Rlox is simple language designed purely to learn how build interpreters.
Rlox is a clone of lox langauge from https://craftinginterpreters.com/ book. Lox was written in Java and C and Rlox is a clone written in Rust just for fun.
NOTE - This is work in progress. Branch tree-walk
contains tree walking interpreter.
Currently REPL it is very basic but you can execute all of the commands from it. To run REPL just cargo run
cargo run -- -i path/filename.rl
cargo t
fun fib(n) {
if (n <= 1) return n;
return fib(n - 2) + fib(n - 1);
}
for (var i = 0; i < 20; i = i + 1) {
print fib(i);
}
var a = "global";
{
fun showA() {
print a;
}
showA();
var a = "block";
showA();
}
fun test() {
print a;
a=a+"!";
return a;
}
print test();
class Doughnut {
cook() {
return "Fry until golden brown.";
}
cookAnother() {
return "Fry until golden.";
}
}
class BostonCream < Doughnut {
cookAnother() {
var orig = super.cookAnother();
return orig + " Then pipe full of custard and coat with chocolate.";
}
}
var first = BostonCream().cook();
print first;
var second = BostonCream().cookAnother();
print second;