This repository implements a Monkey programming language interpreter in Go. It includes components for lexical analysis, parsing, evaluation, and a REPL for interactive use.
- Lexer: Tokenizes the input source code.
- Parser: Builds an Abstract Syntax Tree (AST).
- Evaluator: Executes the AST.
- REPL: Interactive shell for testing Monkey code.
The project leverages WebAssembly (Wasm) to enable high-performance execution of the Monkey language in web environments. This integration allows the interpreter to run directly in browsers, providing a seamless experience for users without requiring native installations.
WebAssembly enhances the portability and performance of the Monkey language interpreter, making it accessible to a broader audience.
- Compilation: The Go-based interpreter is compiled to WebAssembly using
wasm_exec.js. - Frontend Integration: The
editor/src/lib/wasm/index.tsfile handles communication between the WebAssembly module and the frontend editor. - Execution: Monkey code can be executed in the browser with near-native performance.
let x = 10;
let y = x + 5;if (x > 5) {
let result = 40;
} else {
let result = 50;
}- lexer/: Handles tokenization.
- parser/: Builds AST.
- evaluator/: Evaluates AST.
- object/: Defines runtime objects.
- repl/: Interactive shell.
- editor/: Frontend editor for Monkey code.
This project is based on the book Writing An Interpreter In Go. Special thanks to Thorsten Ball for providing an excellent resource for learning and implementing interpreters.
This project is licensed under the MIT License.