A Rust implementation of an interpreter for the Lox language.
Lox is a language designed by Bob Nystrom for his entertaining book Crafting Interpreters.
This Rust-based Lox interpreter is currently a simple tree-walking interpreter. If for some strange reason you work at a Lox shop, don't use this interpreter in production!
Tree-walking interpreter
- scanning/lexing
- parsing
- evaluating
- statements
- control flow
- functions
- scope resolution
- classes
- inheritance
Future: implement the much faster bytecode version.
Clone and change to rlox
directory:
git clone https://github.com/jtfmumm/rlox
cd rlox
Build:
cargo build --release
Enter the repl:
target/release/rlox
Run a Lox file:
target/release/rlox examples/guessing_game.lox
I've included Bob Nystrom's Lox interpreter test suite.
To run, you need to have Dart v2.12. On MacOS you can install with:
brew install dart@2.12
Then install deps with:
cd lox-test-suite/tool
dart pub get
cd -
Then run the test suite (up to the point I've implemented):
make test