fun fib(n) {
if (n < 2) {
return n;
}
return fib(n - 2) + fib(n - 1);
}
print fib(15);
An Abstract Syntax Tree (AST) generated for the program above:
Rust implementations of Lox language as it is described in a gorgeous book Crafting Interpreters. I really recommend everyone to read it! Both fun and educational content.
This is my first Rust project, my first project connected with interpreters/languages and also my first project where I need to read Java code (I don't know the language) and port something from it. So for me this project serves 2 main purposes:
- Learn Rust and get more comfortable with it
- Get some knowledge of how computer languages actually work internally
Also I learnt some Java. At least reading it.
benchmark
— very simple benchmark for Lox implementations and comparison with some other languagestwi
— code for Tree-Walk Interpreter, as it is described in Part II of the book, and also code for custom AST visualizer that outputs nice pictures such as the one abovebvm
— Bytecode Virtual Machine, as it is described in Part III of the book
twi
and bvm
are implemented as self-consistent and completely independent Rust crates.
benchmark
is a set of independent scripts on various languages.
Unfinished. I plan to do more things. For example:
- Fix the way
twi
deals with environments, so the execution speed and some bugs will be fixed - Finish
bvm
implementation, as it does not support OOP yet
I also have some ideas like adding new datatypes (arrays, hash maps) and other features.