{"id":19099501,"url":"https://github.com/dentrax/monkey","last_synced_at":"2025-07-18T16:06:46.415Z","repository":{"id":103621545,"uuid":"270365217","full_name":"Dentrax/Monkey","owner":"Dentrax","description":"Monkey Programming Language in Rust","archived":false,"fork":false,"pushed_at":"2022-01-28T23:13:54.000Z","size":178,"stargazers_count":32,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T16:17:04.444Z","etag":null,"topics":["interpreter","monkey","programming-language","repl","rust"],"latest_commit_sha":null,"homepage":"https://interpreterbook.com/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dentrax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-07T16:29:27.000Z","updated_at":"2024-12-27T17:37:29.000Z","dependencies_parsed_at":"2023-05-24T00:15:19.843Z","dependency_job_id":null,"html_url":"https://github.com/Dentrax/Monkey","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Dentrax/Monkey","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dentrax%2FMonkey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dentrax%2FMonkey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dentrax%2FMonkey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dentrax%2FMonkey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dentrax","download_url":"https://codeload.github.com/Dentrax/Monkey/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dentrax%2FMonkey/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265791697,"owners_count":23829164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interpreter","monkey","programming-language","repl","rust"],"created_at":"2024-11-09T03:51:00.940Z","updated_at":"2025-07-18T16:06:46.397Z","avatar_url":"https://github.com/Dentrax.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monkey\n\n[![Build](https://travis-ci.org/Dentrax/Monkey.svg?branch=master)](https://travis-ci.org/Dentrax/Monkey)\n\n**Yet another Monkey interpreter \u0026 compiler implementation in Rust, based on Thorsten Ball's [Writing An Interpreter In Go](https://interpreterbook.com/) and [Writing A Compiler In Go](https://compilerbook.com/) books.**\n\n## Features\n* AST\n* Tokenizer\n* Parser\n* Lexer\n* Evaluator\n* Compiler\n* SymbolTable\n* VirtualMachine\n* Builtin Functions\n* Functions \u0026 Closures\n* Read–Eval–Print Loop\n\n## Usage\n\n### 1. Install [rustup](https://rustup.rs/)\n\n\n### 2. Test\n\n```sh\n$ cargo test --all\n```\n\n### 3. Run\n\n```sh\n$ cargo run --bin monkey\n```\n\n```bash\nMonkey Compiler v0.2.0\n\u003e\u003e\u003e \"Hello, \" + \"World!\"\nHello, World!\n\u003e\u003e\u003e\n```\n\n## Examples\n\n### Functions\n\n```rust\n[1, 2 * 2, 3 + 3]\n```\n\n\n### Function Call\n\n```rust\nlet identity = fn(x) { x; }; identity(7); //7\n```\n\n```rust\nlet add = fn(a, b) { a + b }; \nlet sub = fn(a, b) { a - b }; \nlet applyFunc = fn(a, b, func) { \n    func(a, b) \n}; \napplyFunc(10, 2, sub); //8\n```\n\n### If\n\n\n```rust\nif (x \u003c y) { z } else { w }\n```\n\n### Nested If\n\n```rust\nif (2 \u003e 1) { if (3 \u003e 1) { return 7; } return 0; }\n```\n\n### HashMap\n\n```rust\n{\"one\": 0 + 1, \"two\": 10 - 8, \"ten\": 50 / 5}\n```\n\n### Arrays\n\n```rust\nlet arr = [1, 2 * 2, 3 + 3] //arr[1 + 1] =\u003e returns 6\n```\n\n### Operator Precedence\n\n```rust\n3 + 4 * 5 == 3 * 1 + 4 * 5 //((3 + (4 * 5)) == ((3 * 1) + (4 * 5)))\n```\n\n### Error Handlers\n\n```rust\nif (10 \u003e 1) { if (10 \u003e 1) { return true + false; } return 1; } //unknown operator: BOOLEAN + BOOLEAN\n```\n\n```rust\nlet newAdder = fn(x) { fn(y) { x + y } }; let addTwo = newAdder(2); x //identifier not found: x\n```\n\n## Complete Example\n\n### Builtin\n\n```rust\nlet map = fn(arr, f) {\n\tlet iter = fn(arr, accumulated) {\n\t\tif (len(arr) == 0) {\n\t\t\taccumulated\n\t\t} else {\n\t\t\titer(rest(arr), push(accumulated, f(first(arr))));\n\t\t}\n\t};\n\titer(arr, []);\n};\nlet a = [1, 2, 3, 4];\nlet double = fn(x) { x * 2 };\nmap(a, double);\n```\n\n### HashMap\n\n```rust\nlet people = [{\"name\": \"Alice\", \"age\": 24}, {\"name\": \"Anna\", \"age\": 28}];\nlet getAge = fn(person) { person[\"name\"]; };\nreturn getAge(people[0]) + getAge(people[1]);\n```\n\n## Benchmark\n\n```sh\n$ cargo run --release --bin benchmark -- --vm\n$ cargo run --release --bin benchmark -- --eval\n```\n\n## TODO\n- [X] Impl Compiler\n- [X] Impl VM\n- [ ] Add Pipeline with Stages: `fmt`, `check`, `clippy`, `test`, `build`\n- [ ] Optimize overall performance\n- [ ] Fix `clippy` warnings\n \n## License\n\nMIT License ([LICENSE](LICENSE)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdentrax%2Fmonkey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdentrax%2Fmonkey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdentrax%2Fmonkey/lists"}