{"id":21359912,"url":"https://github.com/ujstor/interpreter-in-go","last_synced_at":"2025-07-09T04:39:05.170Z","repository":{"id":213374957,"uuid":"724615980","full_name":"Ujstor/interpreter-in-go","owner":"Ujstor","description":"Interpreter in Go","archived":false,"fork":false,"pushed_at":"2023-12-20T16:06:48.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-22T18:51:53.450Z","etag":null,"topics":["go","interpreter","lexer","parser"],"latest_commit_sha":null,"homepage":"","language":"Go","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/Ujstor.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-28T12:54:10.000Z","updated_at":"2023-12-20T16:06:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"bee865f0-ea85-4349-bf0a-eb39ed757439","html_url":"https://github.com/Ujstor/interpreter-in-go","commit_stats":null,"previous_names":["ujstor/interpreter-in-go"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ujstor%2Finterpreter-in-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ujstor%2Finterpreter-in-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ujstor%2Finterpreter-in-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ujstor%2Finterpreter-in-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ujstor","download_url":"https://codeload.github.com/Ujstor/interpreter-in-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243835953,"owners_count":20355611,"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":["go","interpreter","lexer","parser"],"created_at":"2024-11-22T05:30:42.232Z","updated_at":"2025-03-16T06:27:15.718Z","avatar_url":"https://github.com/Ujstor.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Interpreter\n\nThis repository contains the source code for a custom interpreter written in Go. The interpreter is designed to parse and evaluate the Monkey programming language. C-like language with features such as variable bindings, arithmetic expressions, built-in functions, first-class and higher-order functions, closures and complex data structures like strings, arrays, and hash.\n\nThis project is an implementation of a programming language interpreter, as presented in Thorsten Ball's book: [\"Writing An Interpreter In Go\"](https://interpreterbook.com/).\n\n## Features\n\n- **Lexer and Parser**: Custom-built lexer and parser to handle the syntax of Monkey.\n- **Abstract Syntax Tree (AST)**: Building and evaluating AST for interpreting the Monkey language.\n- **Evaluator**: A core component that interprets the AST.\n- **Data Structures**: Support for integers, booleans, strings, arrays, and hashes.\n- **Functions**: First-class and higher-order functions with closures.\n- **REPL**: A Read-Eval-Print Loop for interactive execution.\n\n## Getting Started\n\n### Prerequisites\n\n- Go programming language (version 1.14 or higher recommended)\n- Basic understanding of compilers and interpreters\n\n### Installation\n\n1. Clone the repository:\n   ```sh\n   git clone https://github.com/Ujstor/interpreter-in-go.git\n   ```\n\n2. Navigate to the project directory:\n   ```sh\n   cd go-interpreter\n   ```\n\n### Running the Interpreter\n\nTo launch the REPL:\n\n```sh\ngo run main.go\n```\n\n## Usage Examples\n\n### Variable Bindings\n\n```monkey\nlet age = 30;\nlet name = \"Monkey\";\nlet result = 10 * (20 / 2);\n```\n\n### Working with Arrays and Hashes\n\n```monkey\nlet myArray = [1, 2, 3, 4, 5];\nlet userInfo = {\"name\": \"Jane\", \"age\": 25};\n```\n\n### Functions\n\n```monkey\nlet add = fn(a, b) { return a + b; };\nadd(10, 20);\n\nlet fibonacci = fn(x) {\n    if (x == 0) {\n        0\n    } else {\n        if (x == 1) {\n            1\n        } else {\n            fibonacci(x - 1) + fibonacci(x - 2);\n        }\n    }\n};\nfibonacci(10);\n```\n\n### Higher-Order Functions\n\n```monkey\nlet twice = fn(f, x) { return f(f(x)); };\nlet addTwo = fn(x) { return x + 2; };\ntwice(addTwo, 2); // =\u003e 6\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fujstor%2Finterpreter-in-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fujstor%2Finterpreter-in-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fujstor%2Finterpreter-in-go/lists"}