This project is an implementation of an interpreter for the Monkey programming language. The goal is to learn about the inner workings of interpreters and gain hands-on experience by building one from scratch using Go.
To run the interpreter, ensure that you have Go installed on your system. Clone this repository and navigate to the project directory. Then, run the following command:
go run main.go
This will start the REPL, and you can begin entering Monkey code. The interpreter will parse and evaluate the code, providing the results in the REPL.
- Closely maps to C (or other lower level languages)
- Readable and easy to understand
- Built-in tooling
- Fast
The entry point of the interpreter.
Implementation of the REPL.
Defines the Lexer
struct and its methods for tokenizing input.
Unit tests for the lexer.
Defines the Token
struct and token-related constants.
Defines the Abstract Syntax Tree (AST) nodes and their associated interfaces.
Implementation of the parser for constructing an AST from tokens.
- Clean up and extend Parser test suite
- Parse grouped expressions
- Parse if statements
- Parse function literals
This project follows the concepts taught in the book “Writing an Interpreter in Go” by Thorsten Ball. Thorsten's book serves as an excellent resource for learning about interpreters, and the subsequent project has been incredibly enlightening while also helping me become more familiar with Golang and programming languages as a whole!