Skip to content
Compile a C-like language to brainfuck.
Perl Shell
Find file
Latest commit 9720b0e Sep 2, 2012 @cjxgm @ fixed README.md bug
Failed to load latest commit information.
image
src
README.md
install.pl
uninstall.pl

README.md

brainsuck - painlessly brainfucking

bslogo


by eXerigumo Clanjor (哆啦比猫/兰威举), 2012.
Licensed under GPLv2.
alpha Written in perl

Have a try!

Clone this repo and install

git clone https://github.com/cjxgm/brainsuck.git
cd brainsuck
sudo ./install.pl

Try some program:

This test program is included in the source code(src/bs/test.bs):

# test

main()
{
    @ x;

    while (x != 'x') {
        "what? ";
        x = getc();
        while (x == 10 || x == 13) x = getc();  # skip newline

        if (x == 'a') "Hi!";
        else if (x-'0' == 2) "Wow!";
        else {"> "; putc(x);}
        putc(10);   # newline
    }
}

You can compile this by:

brainsuck < src/bs/test.bs

Then you will get something like this (formated):

>>>+[<[->-]>[-<>+>->]<+[<[->-]>[-<<[->+>+<<]>>[-<<+>>]++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++[-<->]<[[-]>+<]+>[-<+>>]<[++>]->]<+[
<[->-]>[-<++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++
+.[-],<[-]>[-<+>]++++>->]<+[<[->-]>[-<<[-]>>+<<->]<+[<[->-]>[-<<[->+>+
<<]>>[-<<+>>]++++++++++[-<->]<[[-]>+<]+>[-<->]<[[-]>+<]>[-<+>]<<[->>+>
+<<<]>>>[-<<<+>>>]+++++++++++++[-<->]<[[-]>+<]+>[-<->]<[[-]>+<]>[-<+>]
<[-<+>]<[[-]>+<]+>[-<++++>>]<[+++++>]->]<+[<[->-]>[-<,<[-]>[-<+>]++++>
->]<+[<[->-]>[-<<[->+>+<<]>>[-<<+>>]++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[-<->]<
[[-]>+<]+>[-<->]<[[-]>+<]+>[-<++++++++>+++++++>>]<[++++++++>++++++++>]
->]<+[<[->-]>[-<++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++
++++++++++++++++++++++++.[-]->]<+[<[->-]>[-<<<[->>+>+<<<]>>>[-<<<+>>>]
++++++++++++++++++++++++++++++++++++++++++++++++[-<->]++[-<->]<[[-]>+<
]+>[-<->]<[[-]>+<]+>[-<+++++++++++>++++++++++>>]<[+++++++++++>++++++++
+++>]->]<+[<[->-]>[-<++++++++++.[-][-]+>->]<+[<[->-]>[-<++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++.[
-]->]<+[<[->-]>[-<++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++.[-]++++++++++++++++++++++++++++++++.[-]<<<[->>>+>+<<<<]>>>>
[-<<<<+>>>>]<.[-][-]->]<+[<[->-]>[-<->]<+[-]]]]]]]]]]]]]+>>[-<<->>]<<]
<<

Then you can run it on any brainfuck interpreters or compilers. I highly recommend you use my bf2nasm compiler, program compiled by which may run faster than any other compilers. (And don't use a Javascript brainfuck interpreter! It will be REALLY SLOW!)

Have fun!

Something went wrong with that request. Please try again.