by eXerigumo Clanjor (哆啦比猫/兰威举), 2012.
Licensed under GPLv2.
alpha
Written in perl
git clone https://github.com/cjxgm/brainsuck.git
cd brainsuck
sudo ./install.pl
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!