https://github.com/spydr06/monkey
The Monkey Programming language written in Go following Thorsten Ball's Book "Writing an Interpreter in Go"
https://github.com/spydr06/monkey
go golang interpreter monkey-programming-language programming-language writing-an-interpreter-in-go
Last synced: 11 months ago
JSON representation
The Monkey Programming language written in Go following Thorsten Ball's Book "Writing an Interpreter in Go"
- Host: GitHub
- URL: https://github.com/spydr06/monkey
- Owner: Spydr06
- Created: 2021-04-13T12:19:41.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-04-18T22:19:11.000Z (almost 4 years ago)
- Last Synced: 2025-01-16T00:34:45.074Z (about 1 year ago)
- Topics: go, golang, interpreter, monkey-programming-language, programming-language, writing-an-interpreter-in-go
- Language: Go
- Homepage:
- Size: 5.88 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Monkey
The Monkey Programming language, written in Go, following Thorsten Ball's Books "Writing an Interpreter in Go" and "Writing a Compiler in Go"
Monkey is a small, interpreted or compiled toy programming language with high-level simplicity and easy to write C-like syntax.
*The language features:*
* Two backends: an evaluator or a stack-based virtual-machine with bytecode compiler
* Turing-completeness
* expressions like `+` `-` `*` `/` `-`(prefix) `!`(prefix) `==` `!=` `>` `<`
* local and global variables
* macros and quotes (only with the evaluator backend)
* functions/closures as first-class objects
* everything is an expression
* arrays `[1, 2, 3]`
* hash tables `{a: 1, b: 2, c: 3}`
* strings `"Hello"`
* full unit test coverage
* written in 100% pure Go without external dependencies
* Examples in the `examples` directory
## Installation
- Clone this repository or download a precompiled package
```bash
git clone github.com/spydr06/monkey.git
cd monkey
```
Build the executable:
```bash
go build .
```
## Usage
By default, monkey starts it's interactive REPL, just by typing
```bash
./monkey
```
To run a specific file, use the `-file` flag
```bash
./monkey -file examples/helloworld.monkey
```
To use the evaluator backend, use `-engine eval`
```bash
./monkey -engine eval
```
To get help, use `-help`
```bash
./monkey -help
```