{"id":26536979,"url":"https://github.com/basemax/brainfuck2c","last_synced_at":"2026-02-15T15:04:27.204Z","repository":{"id":282273662,"uuid":"947528390","full_name":"BaseMax/brainfuck2c","owner":"BaseMax","description":"A simple Brainfuck-to-C transpiler that converts Brainfuck code into optimized C code. It features token merging, error detection, and clean C output for easy compilation and execution.","archived":false,"fork":false,"pushed_at":"2025-03-12T20:53:49.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-25T11:57:24.545Z","etag":null,"topics":["brainfuck","brainfuck-compiler","brainfuck-generator","brainfuck-interpreter","c","c-generator","compiler","compiler-generator","transpilation","transpile","transpiled-language","transpiler","transpilers","transpiling"],"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/BaseMax.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-12T20:41:51.000Z","updated_at":"2025-03-12T21:39:29.000Z","dependencies_parsed_at":"2025-03-13T18:07:05.676Z","dependency_job_id":"06b6033f-6b9a-4440-8d54-76278559cbbc","html_url":"https://github.com/BaseMax/brainfuck2c","commit_stats":null,"previous_names":["basemax/brainfuck2c"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BaseMax/brainfuck2c","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2Fbrainfuck2c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2Fbrainfuck2c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2Fbrainfuck2c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2Fbrainfuck2c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BaseMax","download_url":"https://codeload.github.com/BaseMax/brainfuck2c/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2Fbrainfuck2c/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29481925,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T11:35:25.641Z","status":"ssl_error","status_checked_at":"2026-02-15T11:34:57.128Z","response_time":118,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["brainfuck","brainfuck-compiler","brainfuck-generator","brainfuck-interpreter","c","c-generator","compiler","compiler-generator","transpilation","transpile","transpiled-language","transpiler","transpilers","transpiling"],"created_at":"2025-03-21T22:17:49.130Z","updated_at":"2026-02-15T15:04:27.190Z","avatar_url":"https://github.com/BaseMax.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Brainfuck to C Transpiler\n\nThis project is a Brainfuck-to-C transpiler written in C. It converts Brainfuck source code into equivalent C code by following three main phases:\n\n1. **Lexer Phase:**  \n   Reads the input Brainfuck code and produces an array of tokens.\n\n2. **Parser Phase:**  \n   Converts the token stream into an Abstract Syntax Tree (AST), merging consecutive operations and handling loops recursively. It also detects and reports unmatched brackets.\n\n3. **Generator Phase:**  \n   Traverses the AST and prints out the corresponding C code.\n\nThe generated C code creates a memory tape of `TAPE_SIZE` cells and uses standard C I/O (`getchar`/`putchar`) for Brainfuck’s input/output.\n\n## Features\n\n- **Optimized Token Merging:** Consecutive operations (e.g., multiple `+` or `\u003e`) are merged into a single statement.\n- **Robust Error Handling:** Reports unmatched brackets and handles memory allocation errors.\n- **Flexible Input:** Reads Brainfuck code from a file (provided as a command‑line argument) or from standard input.\n- **Readable Output:** The generated C code is clean, well-indented, and easy to understand.\n\n## Requirements\n\n- A C99 compliant compiler (e.g., GCC)\n- GCC (GNU Compiler Collection) for building the project\n\n## Building the Transpiler\n\nTo compile the transpiler, run:\n\n```bash\ngcc -Wall -Wextra -pedantic -Werror -o brainfuck2c brainfuck2c.c\n```\n\nThis command enables all warnings, treats warnings as errors, and produces an executable named brainfuck2c.\n\n## Usage\n\nYou can run the transpiler by specifying a Brainfuck source file:\n\n```bash\n./brainfuck2c program.bf \u003e program.c\n```\n\n### Compiling the Generated C Code\n\nAfter generating the C code, compile it with:\n\n```bash\ngcc -Wall -Wextra -pedantic -Werror -o program program.c\n```\n\nThen run the resulting executable:\n\n```bash\n./program\n```\n\n## Code Structure\n\n`brainfuck2c.c` - The main source file that implements the transpiler, organized into:\n\n  - Lexer Phase: Contains token definitions and the lex() function.\n  - Parser Phase: Implements the AST data structures and recursive parsing functions.\n  - Generator Phase: Traverses the AST to generate equivalent C code.\n\n## License\n\nThis project is distributed under the MIT License.\n\n## Contributing\n\nContributions are welcome! Feel free to fork the repository, make improvements, and submit pull requests. For any issues or suggestions, please open an issue on GitHub.\n\nDeveloped by Max Base (Seyyed Ali Mohammadiyeh).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Fbrainfuck2c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasemax%2Fbrainfuck2c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Fbrainfuck2c/lists"}