A Rust implementation of the Monkey programming language interpreter. This project is an implementation of the Monkey programming language as described in the book "Writing An Interpreter In Go" by Thorsten Ball, but written in Rust.
The project is organized into a few key components:
lexer/: Tokenizes the input source codeparser/: Parses tokens into an Abstract Syntax Tree (AST)evaluator/: Evaluates the AST to produce resultsrepl/: Provides an interactive Read-Eval-Print Loop
- Interactive REPL (Read-Eval-Print Loop)
- Lexical analysis
- Parsing
- Evaluation
- Support for Monkey programming language features
- Rust (2021 edition or later)
- Cargo (comes with Rust)
To build the project:
cargo buildThis project includes comprehensive unit tests for all major components. To run the tests:
cargo testEach component (lexer, parser, evaluator) has its own test suite to ensure correct functionality.
To run the REPL:
cargo runOnce the REPL is running, you can enter Monkey code expressions. To exit the REPL, enter an empty string.
Example Monkey code you can try:
let x = 5;
let y = 10;
x + yindoc: For indented documentation strings
This project is open source and available under the MIT License.