{"id":27373552,"url":"https://github.com/magalhaesm/rinha-compiler","last_synced_at":"2025-04-13T11:15:22.448Z","repository":{"id":195558576,"uuid":"693154170","full_name":"magalhaesm/rinha-compiler","owner":"magalhaesm","description":"💻 A simple tree-walking interpreter ","archived":false,"fork":false,"pushed_at":"2023-09-28T21:02:17.000Z","size":41,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T11:15:19.703Z","etag":null,"topics":["algorithms","compiler","cpp","cpp17","data-structures","interpreter","programming-challenges","tree-walk-interpreter"],"latest_commit_sha":null,"homepage":"","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/magalhaesm.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}},"created_at":"2023-09-18T13:08:44.000Z","updated_at":"2023-09-29T08:27:50.000Z","dependencies_parsed_at":"2023-09-29T00:06:21.330Z","dependency_job_id":null,"html_url":"https://github.com/magalhaesm/rinha-compiler","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"4487a4619b7b025a9aeba5b70aece887b8fd7eb9"},"previous_names":["magalhaesm/rinha-compiler"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magalhaesm%2Frinha-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magalhaesm%2Frinha-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magalhaesm%2Frinha-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magalhaesm%2Frinha-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magalhaesm","download_url":"https://codeload.github.com/magalhaesm/rinha-compiler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248703196,"owners_count":21148118,"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":["algorithms","compiler","cpp","cpp17","data-structures","interpreter","programming-challenges","tree-walk-interpreter"],"created_at":"2025-04-13T11:15:21.663Z","updated_at":"2025-04-13T11:15:22.433Z","avatar_url":"https://github.com/magalhaesm.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rinha-compiler\n\n## Description\n\nThis is a simple tree-walking interpreter developed for participation in a compiler and interpreter competition. The project supports the Rinha programming language and includes features such as function declarations, conditionals, and mathematical expressions. It interprets a JSON file that contains an Abstract Syntax Tree (AST) representation of the code.\n\nFor more details on the competition and to access the project repository, visit [rinha-de-compiler](https://github.com/aripiprazole/rinha-de-compiler).\n\n## Code Examples\n\nHere are some code examples in Rinha that can be executed using this interpreter:\n\n### Fibonacci\n\n```js\nlet fib = fn (n) =\u003e {\n  if (n \u003c 2) {\n    n\n  } else {\n    fib(n - 1) + fib(n - 2)\n  }\n};\n\nprint(\"fib: \" + fib(42))\n```\n\n### Combination\n\n```js\nlet combination = fn (n, k) =\u003e {\n    let a = k == 0;\n    let b = k == n;\n    if (a || b)\n    {\n        1\n    }\n    else {\n        combination(n - 1, k - 1) + combination(n - 1, k)\n    }\n};\n\nprint(combination(30, 12))\n```\n\n## Requirements\n\nTo run this interpreter locally, you will need the following tools and libraries:\n\n- [Make](https://www.gnu.org/software/make/)\n- [GCC](https://gcc.gnu.org/)\n- [RapidJSON](https://rapidjson.org/)\n\n## Data Preparation\n\nBefore interpreting a .rinha file, you need to prepare it by parsing it into a JSON file using the Rinha parser. To obtain it, you can use Cargo, Rust's package manager, from [Crates.io](https://crates.io/crates/rinha):\n\n```sh\ncargo install rinha\n```\n\nOnce you have the parser, you can proceed to parse your .rinha files into JSON as explained in the previous section.\n\n## Usage\n\n### Using Docker (Optional)\n\nTo run the interpreter using Docker in an isolated environment, follow these steps:\n\n1. Build the Docker image:\n\n   ```sh\n   docker build . -f Dockerfile -t interpreter-cpp\n   ```\n\n2. Run the interpreter with your Rinha file as input:\n\n   ```sh\n   docker run --rm -v ./source.rinha.json:/var/rinha/source.rinha.json --memory=2gb --cpus=2 interpreter-cpp\n   ```\n\n### Local Compilation\n\nIf you prefer to compile and run the interpreter locally, follow these steps:\n\n1. Compile the interpreter:\n\n   ```sh\n   make\n   ```\n\n2. Run the interpreter with your Rinha file as input:\n\n   ```sh\n   ./interpreter \u003cyourfile.json\u003e\n   ```\n\n## Contributions\n\nContributions to this project are welcome. If you wish to contribute, feel free to open issues, send pull requests, or contact the project maintainers.\n\n## License\n\nThis project is licensed under [MIT License](https://github.com/magalhaesm/rinha-compiler/blob/main/LICENSE), if applicable.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagalhaesm%2Frinha-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagalhaesm%2Frinha-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagalhaesm%2Frinha-compiler/lists"}