An interpreter and compiler for the Monkey programming language written in Rust
https://monkey-lang-playground-jw.vercel.app/
Monkey has a C-like syntax, supports variable bindings, prefix and infix operators, has first-class and higher-order functions, can handle closures with ease and has integers, booleans, arrays and hashes built-in.
- Split packages to make everything minimum
- REPL: A Read-Eval-Print-Loop (REPL) for Monkey tokenizer, parser, evaluator, compiler, and GC runtime
- location info for ast
- test for every module
- Wasm: A WebAssembly target, thus run monkey on browser is directly supported.
- Prettier Plugin: Format Monkey source code with Prettier via
prettier-plugin-monkey. - Minifier (
@gengjiawen/monkey-minifier): A semantics-preserving source-to-source minifier powered by the Rust/Wasm parser, with compact printing, identifier mangling, constant folding and propagation, deadletelimination, and Node/browser/CLI APIs. - VS Code Extension: First-class editor support with syntax highlighting, snippets, WASM-powered diagnostics, AST preview, and bytecode compilation commands.
- bytecode viewer from source
- GC (
monkey-gc): alternate bytecode VM with QuickJS-style refcounting and three-phase cycle collection (gc_decref→gc_scan→gc_free_cycles) on aGcHeap, so cyclic object graphs can be reclaimed without changingobjector the defaultRcVM. - Bytecode snapshots (
.mbc): QuickJS-style ahead-of-time compilation, mirroringqjsc—monkey-gc compile foo.monkeyserializes the compiled bytecode to a.mbcfile andmonkey-gc run foo.mbcexecutes it without the parser/compiler, treating the file as untrusted input behind a three-layer validation model (design doc). - ASM (
monkey-asm): AOT arm64 (AArch64) assembly backend — single-pass lowering from the AST to AArch64 assembly text, assembled and linked against a cross-built Rust runtime into a native executable, in Linux/ELF and macOS/Mach-O flavors (the Linux flavor runs on any host viaqemu-aarch64); the playground's ARM64 tab shows the same assembly godbolt-style (design doc).
Official site is: https://monkeylang.org/. It's has various implementation languages :).
There is a book about learning how to make an interpreter: Writing An Interpreter In Go. This is where the Monkey programming language come from.
