{"id":13846354,"url":"https://github.com/Ferdi265/preprocessor_brainfuck","last_synced_at":"2025-07-12T07:32:30.003Z","repository":{"id":84059973,"uuid":"236170132","full_name":"Ferdi265/preprocessor_brainfuck","owner":"Ferdi265","description":"A brainfuck interpreter using only the C preprocessor","archived":false,"fork":false,"pushed_at":"2020-01-25T20:47:15.000Z","size":21,"stargazers_count":87,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-01T10:10:18.037Z","etag":null,"topics":["brainfuck","joke","preprocessor"],"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/Ferdi265.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}},"created_at":"2020-01-25T12:54:33.000Z","updated_at":"2024-01-30T20:26:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"9cf5f9a9-4874-482e-88bb-d10457544636","html_url":"https://github.com/Ferdi265/preprocessor_brainfuck","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ferdi265%2Fpreprocessor_brainfuck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ferdi265%2Fpreprocessor_brainfuck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ferdi265%2Fpreprocessor_brainfuck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ferdi265%2Fpreprocessor_brainfuck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ferdi265","download_url":"https://codeload.github.com/Ferdi265/preprocessor_brainfuck/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225807260,"owners_count":17527221,"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":["brainfuck","joke","preprocessor"],"created_at":"2024-08-04T18:00:30.838Z","updated_at":"2024-11-21T21:30:25.227Z","avatar_url":"https://github.com/Ferdi265.png","language":"C++","funding_links":[],"categories":["Compilers/Interpreters"],"sub_categories":[],"readme":"# Preprocessor Brainfuck Interpreter\n\nThis project contains an interpreter for brainfuck programs that is written\nsolely in C preprocessor macros.\n\nThis implementation only uses simple preprocessor conditionals (`#if some-expression`), preprocessor defines without arguments (`#define FOO some-expression`), and inclusion of header files (`#include HEADER`). There exist other (IMO better) implementations of brainfuck for the C preprocessor that use other features, such as token pasting (such as [CPP_COMPLETE](https://github.com/orangeduck/CPP_COMPLETE)).\n\nThis implementation also makes use of generated header files to create modifiable variables whose size is dependent on the max number of steps, the max size of the tape, and the max value of each value on the tape. The only generated file that is dependent on the input brainfuck program is the file that defines the code tape and the input tape (`main.h`, generated by `bf_to_main.sh`), which is a simple 1:1 translation of the brainfuck code and input to a sequence of defines.\n\nSince the number of steps is limited and the size of variables is finite, this implementation is not turing complete. A recursive inclusion of the main run loop header file doesn't really help, because every major compiler has limits on the recursion depth of header files.\n\n## How to use\n\n1. Generate the headers\n\n```\n$ make\n```\n\n2. Encode your program into `main.h`, and provide the file used as input\n\n```\n$ ./bf_to_main.sh hello.bf /dev/null \u003e main.h\n```\n\n3. Run the brainfuck interpreter\n\n```\n$ make run\n```\n\nor\n\n```\n$ make run DEBUG=1\n```\n\n## Note\n\nThe preprocessor brainfuck interpreter is very very inefficient and will use\naround **16 GIGABYTES** of memory and **15 to 20 minutes of processing time**\nwhile running `hello.bf`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFerdi265%2Fpreprocessor_brainfuck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFerdi265%2Fpreprocessor_brainfuck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFerdi265%2Fpreprocessor_brainfuck/lists"}