{"id":21438238,"url":"https://github.com/bpetermann/node-interpreter","last_synced_at":"2026-05-07T10:36:21.111Z","repository":{"id":207467480,"uuid":"717415435","full_name":"bpetermann/node-interpreter","owner":"bpetermann","description":" Typescript interpreter for monkey","archived":false,"fork":false,"pushed_at":"2024-06-22T21:16:43.000Z","size":165,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-05T12:40:04.913Z","etag":null,"topics":["interpreter","jest","lexer","nodejs","parser","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bpetermann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-11-11T12:33:52.000Z","updated_at":"2024-11-14T13:43:53.000Z","dependencies_parsed_at":"2024-01-31T09:39:51.739Z","dependency_job_id":"2511f76b-7f4f-423b-b664-dc899cd47cba","html_url":"https://github.com/bpetermann/node-interpreter","commit_stats":null,"previous_names":["bpetermann/node-interpreter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bpetermann/node-interpreter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpetermann%2Fnode-interpreter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpetermann%2Fnode-interpreter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpetermann%2Fnode-interpreter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpetermann%2Fnode-interpreter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bpetermann","download_url":"https://codeload.github.com/bpetermann/node-interpreter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpetermann%2Fnode-interpreter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271215037,"owners_count":24720098,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","jest","lexer","nodejs","parser","typescript"],"created_at":"2024-11-23T00:34:16.089Z","updated_at":"2026-05-07T10:36:21.080Z","avatar_url":"https://github.com/bpetermann.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node Interpreter\n\nA Node/Typescript interpreter for the [monkey](https://monkeylang.org/) programming language, based on the excellent book [\"Writing An Interpreter In Go\"](https://interpreterbook.com/).\n\n## ⚙️ Installation\n\nTo get started, clone the repository:\n\n```bash\ngit clone https://github.com/bpetermann/node-interpreter.git\ncd node-interpreter\n```\n\nThen, install dependencies and build the project:\n\n```js\nnpm run build:fresh // Installs dependencies and builds the project\n```\n\n## 🚀 Start\n\nFinally, start the REPL (Read-Eval-Print Loop):\n\n```js\nnpm run start // Starts the REPL\n```\n\n## 📋 Usage Examples\n\n```js\n\u003e\u003e let a = 2; // Declare a variable\n\u003e\u003e let baz = [\"foo\", \"bar\"]; // Declare an array\n\u003e\u003e baz[0]; // Acesss array\n\u003e\u003e let person = {\"name\": \"Alice\"}; // Declare a hash map\n\u003e\u003e person[\"name\"]; // Access map\n```\n\nHere's a basic example illustrating the declaration and invocation of a function:\n\n```js\n\u003e\u003e let a = 2; // Declare a variable\n\u003e\u003e let multiply = fn(x, y) { x * y }; // Declare a function\n\u003e\u003e multiply(50 / 2, a); // Call the function\n50\n```\n\nExample of closures:\n\n```js\n\u003e\u003e let newAdd = fn(x) {\n  fn(y) { x + y };\n};\n\u003e\u003e let addTwo = newAdd(2);\n\u003e\u003e addTwo(2);\n4\n```\n\nClose the REPL:\n\n```js\neof;\n```\n\n## Interpreter Workflow\n\n1. Lexical Analysis (Lexer):\n\n- The input code undergoes tokenization by the Lexer, breaking it into smaller units known as tokens (keywords, identifiers, operators).\n\n2. Parsing:\n\n- Tokens are organized into an abstract syntax tree (AST) by the Parser, following the grammar rules specific to the language.\n- The AST represents the hierarchical structure of the code, arranging statements and expressions.\n\n3. Evaluation:\n\n- The interpreter traverses the AST, evaluating nodes and executing code based on the languages syntax rules.\n\nThis interpreter employs a process of lexical analysis, parsing, and evaluation to systematically analyze and execute code, creating an AST to interpret programs according to the specific syntax and rules of the language.\n\n## Syntax Overview\n\nThe syntax embodies a rich spectrum of functionalities, managing mathematical expressions, variable assignments, function definitions, calls, conditionals, and returns. It adeptly handles concepts like higher-order functions and closures.\n\nAdditionally, the interpreter accommodates diverse data types — integers, booleans, strings, arrays, and hashes.\n\nIt also features a set of built-in functions tailored to expedite string/array operations and console output logging.\n\n## 🧪 Tests\n\nThe following command will run all jest test suites:\n\n```js\nnpm run test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbpetermann%2Fnode-interpreter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbpetermann%2Fnode-interpreter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbpetermann%2Fnode-interpreter/lists"}