https://github.com/marioariasc/monyet
An implementation of the monkey language on Crystal
https://github.com/marioariasc/monyet
crystal monkey monkey-language
Last synced: 5 months ago
JSON representation
An implementation of the monkey language on Crystal
- Host: GitHub
- URL: https://github.com/marioariasc/monyet
- Owner: MarioAriasC
- License: apache-2.0
- Created: 2021-11-12T10:34:47.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-03T15:26:55.000Z (about 1 year ago)
- Last Synced: 2024-12-01T10:42:54.874Z (5 months ago)
- Topics: crystal, monkey, monkey-language
- Language: Crystal
- Homepage:
- Size: 122 KB
- Stars: 15
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Monyet
[Crystal](https://crystal-lang.org/reference/1.2/index.html) implementation of
the [Monkey Language](https://monkeylang.org/)Monyet has a sibling implementation for Kotlin: [monkey.kt](https://github.com/MarioAriasC/monkey.kt)
## Status
The two books ([Writing An Interpreter In Go](https://interpreterbook.com/)
and [Writing A Compiler in Go](https://compilerbook.com/)) are implemented.## Commands
Before running the command you must have crystal and shards installed on your machine
| Script | Description |
|----------------------------------|----------------------------------------------------------------------------------------------------------------------|
| [`tests.sh`](tests.sh) | Run all the tests |
| [`checks.sh`](checks.sh) | Run format tool and ameba checks |
| [`build.sh`](build.sh) | Release build |
| [`benchmarks.sh`](benchmarks.sh) | Run the classic monkey benchmark (`fibonacci(35)`), requires one command (`--eval`,`--eval-fast`,`--vm`,`--vm-fast`) |
| [`repl.sh`](repl.sh) | Run the Monyet REPL |## Compiling variants
There are two different implementations for the compiler/VM.
* The default variant, based on `Array(UInt8)` as Bytecode and `OffsetArray` arrays for read operations
* The slices variant, based purely on `Slice(UInt8)`The slices variant is more idiomatic but the default variant has better performance (around 10%).
To compile with a different variant you can the flag `--define=slice` to your compile or test. Additionally,
both [`build.sh`](build.sh) and [`test.sh`](tests.sh) have lines that you can comment/uncomment to enable different
variants