Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here

brainfuck

Brainfuck interpreter written in C

Subscribe to updates I use brainfuck


Statistics on brainfuck

Number of watchers on Github 147
Number of open issues 2
Average time to close an issue 28 days
Main language Brainfuck
Average time to merge a PR 5 days
Open pull requests 0+
Closed pull requests 8+
Last commit almost 3 years ago
Repo Created almost 9 years ago
Repo Last Updated over 2 years ago
Size 693 KB
Organization / Authorfabianishere
Latest Release2.7.1
Contributors5
Page Updated
Do you use brainfuck? Leave a review!
View open issues (2)
View brainfuck activity
View on github
Book a Mock Interview With Me (Silicon Valley Engineering Leader, 100s of interviews conducted)
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating brainfuck for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

brainfuck Build Status

Brainfuck interpreter written in C.

Usage

brainfuck [-veh] file...
-e --eval       run code directly
-v --version    show version information
-h --help       show a help message.

The interactive console can be accessed by passing no arguments.

We also provide a C api:

#include <stdio.h>
#include <stdlib.h>
#include <brainfuck.h>

int main() {
    BrainfuckState *state = brainfuck_state();
    BrainfuckExecutionContext *context = brainfuck_context(BRAINFUCK_TAPE_SIZE);
    BrainfuckInstruction *instruction = brainfuck_parse_string(",+++++.");
    brainfuck_add(state, instruction);
    brainfuck_execute(state->root, context);
    brainfuck_destroy_context(context);
    brainfuck_destroy_state(state);
    return EXIT_SUCCESS;
}

Examples

Look in the examples directory for a large amount of brainfuck examples.

Getting the source

Download the source code by running the following code in your command prompt:

$ git clone https://github.com/fabianishere/brainfuck.git

or simply grab a copy of the source code as a Zip file.

Building

Create the build directory.

$ mkdir build
$ cd build

Brainfuck requires CMake and a C compiler (e.g. Clang or GCC) in order to run. It also depends on libedit, which is available in the main repositories of most Linux distributions (e.g. as libedit-dev on Debian) and comes with the macOS XCode command line tools. Then, simply create the Makefiles:

$ cmake ..

and finally, build it using the building system you chose (e.g. Make):

$ make

License

See LICENSE file.

Contributors

Fabian Mastenbroek https://github.com/fabianishere
aliclubb https://github.com/aliclubb
diekmann https://github.com/diekmann
SevenBits https://github.com/SevenBits
Alex Burka https://github.com/durka
outis https://github.com/outis
rien333 https://github.com/rien333
brainfuck questions on Stackoverflow (View All Questions)
  • Making an if(x==y) statement in Brainfuck
  • Brainfuck challenge
  • Print text multiple times in Brainfuck
  • How does the Brainfuck Hello World actually work?
  • Port dos2unix to brainfuck
  • Brainfuck interpreter in c printing trouble
  • Fastest brainfuck interpreter?
  • Brainfuck. How check on palindrome?
  • Code for multiplying two one digit numbers in Brainfuck
  • What is wrong with my beginner Brainfuck addition program?
  • Hello, World! in Brainfuck
  • BrainFuck implementation problems:
  • Detecting infinite loop in brainfuck program
  • Sum of number in brainfuck
  • What's wrong with brainfuck on ideone?
  • Divmod algorithm in brainfuck
  • How to calculate the sum of 2 numbers with BrainFuck
  • Why do I get a Perl error in this brainfuck program?
  • Regex for brainfuck loops
  • How to write a "comment" containing a period (.) in Brainfuck?
  • Brainfuck interpreter in Nimrod
  • Memory Index in Brainfuck Language
  • Creating a Brainfuck parser, whats the best method of parsing loop operators?
  • What's wrong with my brainfuck parser code?
  • Brainfuck interpreter misbehaving
  • Brainfuck compare 2 numbers as greater than or less than
  • Turing-completeness of a modified version of Brainfuck
  • "Access is denied" error when running brainfuck interpreter from cmd
  • Extracting brainfuck code from HTML
  • Print characters in brainfuck
brainfuck list of languages used
brainfuck latest release notes
2.7.1 2.7.1
  • Add a make install option (#52)
  • Add option to install a shared library (#48)
  • Add Travis CI integration (#46)
  • Add option to toggle an editline enabled build (#43)
2.7.0 2.7.0
  • add basic readline functionality from the NetBSD editline library to interactive console.
  • reduce newline output in interactive console as to make it more like other consoles.
  • read in only one byte of input on the , command, as per the bf language specification.
  • make codebase c89 compatible
Other projects in Brainfuck
Powered by Autocode - Instant Webhooks, Scripts and APIs
Autocode logo wordmark