{"id":50887494,"url":"https://github.com/liautraver/codecrafters-interpreter-cpp","last_synced_at":"2026-06-15T18:01:10.500Z","repository":{"id":265886166,"uuid":"896578657","full_name":"LiAuTraver/codecrafters-interpreter-cpp","owner":"LiAuTraver","description":"an exercise for building an interpreter on codecrafter","archived":false,"fork":false,"pushed_at":"2025-04-12T19:14:02.000Z","size":1523,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T19:38:47.913Z","etag":null,"topics":["cpp","cpp23","crafting-interpreters"],"latest_commit_sha":null,"homepage":"","language":"C++","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/LiAuTraver.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,"zenodo":null}},"created_at":"2024-11-30T18:30:40.000Z","updated_at":"2025-04-12T19:14:06.000Z","dependencies_parsed_at":"2025-03-30T05:31:30.790Z","dependency_job_id":null,"html_url":"https://github.com/LiAuTraver/codecrafters-interpreter-cpp","commit_stats":null,"previous_names":["liautraver/codecrafters-interpreter-cpp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LiAuTraver/codecrafters-interpreter-cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiAuTraver%2Fcodecrafters-interpreter-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiAuTraver%2Fcodecrafters-interpreter-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiAuTraver%2Fcodecrafters-interpreter-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiAuTraver%2Fcodecrafters-interpreter-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiAuTraver","download_url":"https://codeload.github.com/LiAuTraver/codecrafters-interpreter-cpp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiAuTraver%2Fcodecrafters-interpreter-cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34374146,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","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","cpp23","crafting-interpreters"],"created_at":"2026-06-15T18:01:09.416Z","updated_at":"2026-06-15T18:01:10.493Z","avatar_url":"https://github.com/LiAuTraver.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![progress-banner](https://backend.codecrafters.io/progress/interpreter/6542333f-225f-4480-80ca-e0d68ba3f0e6)](https://app.codecrafters.io/users/codecrafters-bot?r=2qF)\n\nThis is a C++ interpreter for Lox, made while taking on the\n[\"Build your own Interpreter\" Challenge](https://app.codecrafters.io/courses/interpreter/overview) by [CodeCrafters](https://codecrafters.io).\n\n\u003e from [Crafting Interpreters](http://www.craftinginterpreters.com/appendix-i.html) -- Lox is a language created solely for the purpose of the book and learning.\n\nThis is the repo for codecrafters' online judge exercise, a more detailed version see [here](https://github.com/LiAuTraver/loxcpp).\n\n## Build\n\nA C++23 compiler is required to build the project; tested with gcc, clang, and MSVC. Bazel or CMake is required to build the project.\n\n### Debug mode\n\n```powershell\n$env:AC_CPP_DEBUG=1 # set the environment variable to enable debug mode\n```\n\n#### with Bazel(currently only configured for Windows)\n\n```powershell\nbazel build //tools:interpreter # build the interpreter\nbazel test //tests:... # run the tests\n```\n\n#### with CMake\n\nvcpkg is required to install the dependencies.\nMake sure the option `AC_CPP_DEBUG` is set to `ON` in the CMakeLists.txt file.\n\n```powershell\ncmake --preset= # see available presets via `cmake --list-presets` make sure to alter the toolchain file\n```\n\n### Release mode\n\nNo external dependencies are required for release mode.\nYou can run Bazel or CMake as mentioned above(only for target `interpreter`),\nor run the `run.sh` script in the root directory(Linux).\n\n## Run\n\n### Run the interpreter\n\n```powershell\ninterpreter tokenize \u003csource\u003e\ninterpreter parse \u003csource\u003e\ninterpreter evaluate \u003csource\u003e\ninterpreter run \u003csource\u003e\n# repl was on the way, but not in a forseeable future...\n```\n\n## Grammar\n\n### Syntax\n\n```cpp\nprogram        → declaration* EOF ;\n```\n\n### Declaration\n\n```cpp\ndeclaration    -\u003e varDecl\n                | statement\n                | funcDecl \n                | classDecl ;\n\nvarDecl        -\u003e \"var\" IDENTIFIER ( \"=\" expression )? \";\" ;\nfuncDecl   -\u003e \"fun\" function ;\nclassDecl  -\u003e \"class\" IDENTIFIER (\"\u003c\" IDENTIFIER )? ( \"{\" function* \"}\" )? ;  \n```\n\n### Statement\n\n```cpp\nstatement      -\u003e exprStmt\n                | printStmt\n                | block\n                | ifStmt\n                | whileStmt\n                | forStmt\n                | returnStmt ;\n\nexprStmt        -\u003e expression \";\" ;\nprintStmt       -\u003e \"print\" expression \";\" ;\nblock           -\u003e \"{\" declaration* \"}\" ;\nifStmt          -\u003e \"if\" \"(\" expression \")\" statement ( \"else\" statement )? ;\nwhileStmt       -\u003e \"while\" \"(\" expression \")\" statement ;\nforStmt         -\u003e \"for\" \"(\" ( varDecl | exprStmt | \";\" )\n                           expression? \";\"\n                           expression? \")\" statement ;\nreturnStmt      -\u003e \"return\" expression? \";\" ;\n```\n\n### Expression\n\n```cpp\nexpression     -\u003e assignment ;\n\nassignment     -\u003e ( call \".\" )? IDENTIFIER \"=\" assignment\n                | logic_or ;\n\nlogic_or       -\u003e logic_and ( \"or\" logic_and )* ;\nlogic_and      -\u003e equality ( \"and\" equality )* ; \nequality       -\u003e comparison ( ( \"!=\" | \"==\" ) comparison )* ;\ncomparison     -\u003e term ( ( \"\u003e\" | \"\u003e=\" | \"\u003c\" | \"\u003c=\" ) term )* ;\nterm           -\u003e factor ( ( \"-\" | \"+\" ) factor )* ;\nfactor         -\u003e unary ( ( \"/\" | \"*\" ) unary )* ;\nunary          -\u003e ( \"!\" | \"-\" ) unary\n                | call ;\ncall           -\u003e primary ( \"(\" arguments? \")\" | \".\" IDENTIFIER )* ;\n\nprimary        -\u003e NUMBER | STRING \n                | \"true\" | \"false\" | \"nil\" | \"this\"\n                | \"(\" expression \")\" | IDENTIFIER | \"super\" \".\" IDENTIFIER;\n```\n\n### Miscellaneous\n\n```cpp\narguments     -\u003e expression ( \",\" expression )* ;\nfunction      -\u003e IDENTIFIER \"(\" parameters? \")\" block ;\nparameters    -\u003e IDENTIFIER ( \",\" IDENTIFIER )* ;\nalnums        -\u003e [a-zA-Z0-9] \n               | [.!@#$%^\u0026*()] \n               | [...] ;\n```\n\n### Lexical\n\n```cpp\nnumber        -\u003e digit + ( \".\" digit + )? ;\nstring        -\u003e \"\\\"\" + ([[alnums]])* + \"\\\"\" ;\nidentifier    -\u003e [a-zA-Z_] + [a-zA-Z0-9_]* ;\n```\n\n\u003e note: the `cpp` was just for syntax highlighting in vscode to make it look prettier than plain text.\n\n## Project Structure\n\n[dependencies for interpreter](image/interpreter.png), generated by Bazel\n\n## Notes\n\nThis exercise is still in active development, and I will be updating it as I progress through the book.\n\nTODO(pirority from high to low)\n\n- [ ] Desugar `for` statement(currently handles it saparately)\n- [x] Binding and resolving\n- [x] Add `class` support\n- [x] Add class inheritance support\n- [ ] JVM bytecode generation\n- [ ] LLVM IR generation\n- [ ] Machine code generation(x86_64, risc-v)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliautraver%2Fcodecrafters-interpreter-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliautraver%2Fcodecrafters-interpreter-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliautraver%2Fcodecrafters-interpreter-cpp/lists"}