main
rust-interpreter
This repository follows the book Writing an Interpreter in Go and implements the code in Rust.
Run
cargo run
Architecture
The interpreter is built in three main stages:
- Lexer — tokenizes the input source code.
- Pratt parser — builds an AST from the tokens.
- Evaluator — walks the AST and executes the program.
Additional tests are in evaluator/tests.rs.
Features
- Integers, strings, booleans
- Arrays and hashes with index access
letbindings,returnstatements, andif/elseexpressions- First-class functions and closures
Project structure
| Module | Purpose |
|---|---|
lexer |
Tokenizes source input |
parser |
Pratt parser that produces an AST |
ast |
AST node definitions |
object |
Runtime values and environment |
evaluator |
Tree-walking evaluator |
repl |
Interactive REPL |
Tests
cargo test
Description
This repository follows the book Writing an Interpreter in Go and implements the code in Rust.
Languages
Rust
100%
