Skip to content

cjxgm/brainsuck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!