Tree walk interpreter for the Lox language in Rust, following the book Crafting Interpreters. Work in progress.
- Evaluate expressions (upon numbers, strings and booleans)
- Variable declaration and assignment
- Scopes
- Control Flow (if statements, while and foor loops)
- Functions
- Closures
- Classes
- Inheritance
fun fib(n) {
if (n < 2) {
return n;
}
return fib(n - 1) + fib(n - 2);
}
var result = fib(10);
print(result);
fun makeCounter() {
var i = 0;
fun count() {
i = i + 1;
print i;
}
return count;
}
var counter = makeCounter();
counter(); // 1
counter(); // 2
class Doughnut {
cook() {
print "Fry until golden brown.";
}
}
class BostonCream < Doughnut {}
BostonCream().cook();