{"id":13424653,"url":"https://github.com/yhirose/monkey-cpp","last_synced_at":"2025-10-04T09:47:52.721Z","repository":{"id":56339928,"uuid":"244484465","full_name":"yhirose/monkey-cpp","owner":"yhirose","description":"An interpreter for the Monkey programming language written in C++","archived":false,"fork":false,"pushed_at":"2023-07-12T02:15:22.000Z","size":565,"stargazers_count":27,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-27T09:44:24.617Z","etag":null,"topics":["cpp","interpret","peg","programing-language"],"latest_commit_sha":null,"homepage":null,"language":"C++","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/yhirose.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}},"created_at":"2020-03-02T21:59:36.000Z","updated_at":"2025-05-11T00:49:21.000Z","dependencies_parsed_at":"2024-01-16T21:55:28.127Z","dependency_job_id":"c6fd6080-9ede-4b76-921c-1fe0192a0cb5","html_url":"https://github.com/yhirose/monkey-cpp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yhirose/monkey-cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhirose%2Fmonkey-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhirose%2Fmonkey-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhirose%2Fmonkey-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhirose%2Fmonkey-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yhirose","download_url":"https://codeload.github.com/yhirose/monkey-cpp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhirose%2Fmonkey-cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278295845,"owners_count":25963427,"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-10-04T02:00:05.491Z","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":["cpp","interpret","peg","programing-language"],"created_at":"2024-07-31T00:00:57.418Z","updated_at":"2025-10-04T09:47:52.703Z","avatar_url":"https://github.com/yhirose.png","language":"C++","readme":"# monkey\n\nAnother implementation of Monkey programming language described in [Writing An Interpreter In Go](https://interpreterbook.com/) and [Writing A Compiler In Go](https://compilerbook.com/).\nThis is written in C++ and uses [cpp-peglib](https://github.com/yhirose/cpp-peglib) PEG library for lexter and parser.\n\nIn addition to the original Monkey language spec, this implementation supports the line comment. Macro system in Appendix A is not implemented, yet.\n\n## Install\n\n```bash\n$ git clone --recursive https://github.com/yhirose/monkey-cpp.git\n$ cd monkey-cpp \u0026\u0026 mkdir build \u0026\u0026 cd build\n$ cmake ..\n$ make\n\n$ ./build/cli/monkey\n\u003e\u003e puts(\"hello \" + \"world!\")\nhello world!\nnull\n\u003e\u003e quit\n\n$ ./build/cli/monkey ../examples/map.monkey\n[2, 4, 6, 8]\n15\n```\n\n## PEG grammar\n\n```\nPROGRAM                \u003c-  STATEMENTS\n\nSTATEMENTS             \u003c-  (STATEMENT ';'?)*\nSTATEMENT              \u003c-  ASSIGNMENT / RETURN / EXPRESSION_STATEMENT\n\nASSIGNMENT             \u003c-  'let' IDENTIFIER '=' EXPRESSION\nRETURN                 \u003c-  'return' EXPRESSION\nEXPRESSION_STATEMENT   \u003c-  EXPRESSION\n\nEXPRESSION             \u003c-  INFIX_EXPR(PREFIX_EXPR, INFIX_OPE)\nINFIX_EXPR(ATOM, OPE)  \u003c-  ATOM (OPE ATOM)* {\n                             precedence\n                               L == !=\n                               L \u003c \u003e\n                               L + -\n                               L * /\n                           }\n\nIF                     \u003c-  'if' '(' EXPRESSION ')' BLOCK ('else' BLOCK)?\n\nFUNCTION               \u003c-  'fn' '(' PARAMETERS ')' BLOCK\nPARAMETERS             \u003c-  LIST(IDENTIFIER, ',')\n\nBLOCK                  \u003c-  '{' STATEMENTS '}'\n\nCALL                   \u003c-  PRIMARY (ARGUMENTS / INDEX)*\nARGUMENTS              \u003c-  '(' LIST(EXPRESSION, ',') ')'\nINDEX                  \u003c-   '[' EXPRESSION ']'\n\nPREFIX_EXPR            \u003c-  PREFIX_OPE* CALL\nPRIMARY                \u003c-  IF / FUNCTION / ARRAY / HASH / INTEGER / BOOLEAN / NULL / IDENTIFIER / STRING / '(' EXPRESSION ')'\n\nARRAY                  \u003c-  '[' LIST(EXPRESSION, ',') ']'\n\nHASH                   \u003c-  '{' LIST(HASH_PAIR, ',') '}'\nHASH_PAIR              \u003c-  EXPRESSION ':' EXPRESSION\n\nIDENTIFIER             \u003c-  \u003c [a-zA-Z]+ \u003e\nINTEGER                \u003c-  \u003c [0-9]+ \u003e\nSTRING                 \u003c-  \u003c [\"] \u003c (![\"] .)* \u003e [\"] \u003e\nBOOLEAN                \u003c-  'true' / 'false'\nNULL                   \u003c-  'null'\nPREFIX_OPE             \u003c-  \u003c [-!] \u003e\nINFIX_OPE              \u003c-  \u003c [-+/*\u003c\u003e] / '==' / '!=' \u003e\n\nKEYWORD                \u003c-  'null' | 'true' | 'false' | 'let' | 'return' | 'if' | 'else' | 'fn'\n\nLIST(ITEM, DELM)       \u003c-  (ITEM (~DELM ITEM)*)?\n\nLINE_COMMENT           \u003c-  '//' (!LINE_END .)* \u0026LINE_END\nLINE_END               \u003c-  '\\r\\n' / '\\r' / '\\n' / !.\n\n%whitespace            \u003c-  ([ \\t\\r\\n]+ / LINE_COMMENT)*\n%word                  \u003c-  [a-zA-Z]+\n```\n","funding_links":[],"categories":["C++","Scripts"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyhirose%2Fmonkey-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyhirose%2Fmonkey-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyhirose%2Fmonkey-cpp/lists"}