Following `Writing an interpreter in Go` book by Thorsten Ball. https://interpreterbook.com/
Project description
monkeylang
monkeylang is a toy programming language and interpreter implemented in Python, inspired by the book
Writing an Interpreter in Go.
This project exists purely for learning and experimentation. It follows the structure, ideas, and design presented in the book, but reimplements them in Python instead of Go.
About
Monkey is a small, interpreted language designed to be simple enough to implement from scratch while still being powerful enough to demonstrate real interpreter concepts, such as:
- Lexing and parsing
- Abstract Syntax Trees (ASTs)
- Evaluation and environments
- Functions, closures, and control flow
This Python implementation closely mirrors the book’s original Go-based Monkey interpreter, with adjustments made where Python idioms differ from Go.
Installation
pip install monkeylang
This will install the monkey command-line tool.
Usage
You can invoke the Monkey interpreter directly from the command line:
monkey hello.mk
Where hello.mk is a file containing Monkey source code.
In the future, you can also start an interactive REPL:
monkey
Example
let greet = fn(name) {
return "Hello, " + name;
};
greet("world");
Project Goals
- Learn how interpreters work by implementing one end-to-end
- Translate the concepts from Go into Python
- Keep the implementation simple, readable, and close to the book
This is not intended to be a production language or a fully featured runtime.
Credits
-
Thorsten Ball — Author of Writing an Interpreter in Go
https://interpreterbook.com/ -
Original Monkey language design and Go implementation by Thorsten Ball
All core ideas, language design, and architecture are derived from the book. This repository is a Python reimplementation for educational purposes only.
License
This project is provided for educational use. Please refer to the book’s license and terms when reusing or redistributing ideas or code inspired by it.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file monkeylang-0.0.1.tar.gz.
File metadata
- Download URL: monkeylang-0.0.1.tar.gz
- Upload date:
- Size: 1.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67c9a633fcae1cc8f5f2d7196a34a12265af94aa7948c62aab8347dedd2dc904
|
|
| MD5 |
81f2af16e4f83ea02a62a3e15ca94e8e
|
|
| BLAKE2b-256 |
31daf9e374f9a9da5b349c82f3d16bbb18089ccd709d44d83838d14fa98de36f
|
File details
Details for the file monkeylang-0.0.1-py3-none-any.whl.
File metadata
- Download URL: monkeylang-0.0.1-py3-none-any.whl
- Upload date:
- Size: 2.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65153e6cd2557988e957e0aa762fd34a5c3f5a03355df7d967000cc10ff84ede
|
|
| MD5 |
c721208c46029a9f9d4fd89cd73ea770
|
|
| BLAKE2b-256 |
13f9f8f91e728f283e2cfddd2bde262f7a50063416337597eed2e9d616a8cc5b
|