A Rust implementation of the interpreter described in the book Crafting Interpreters by Bob Nystrom.
This project aims to follow the book's structure and philosophy, building a Lox(using the .smith extension for source files) interpreter in Rust. It is a learning project, focusing on clarity, idiomatic Rust, and testability.
- Lexical analysis (scanner) with support for single-line and block comments, string and number literals, identifiers, and keywords.
- Tokenization and error reporting.
- Modular code structure for easy extension as more chapters are implemented.
- Unit tests for core components.
- Rust (latest stable recommended). Install from rustup.rs.
Currently, the main focus is on the scanner (lexer). You can run the tests to see the scanner in action:
cd interpreter-rs
cargo testTo run the interpreter (when implemented):
cargo run -- path/to/source.smithUnit tests are included for the scanner and tokenization logic. Run all tests with:
cargo test- Scanner (lexer)
- Parser
- Interpreter
- REPL
- Error handling improvements
- Crafting Interpreters by Bob Nystrom
This project is primarily for educational purposes, but contributions and suggestions are welcome! If you see a better or more idiomatic way to implement something, suggestions are especially encouraged.
Happy interpreting!