Headache (Lang that compiles to brainfuck)

From Esolang
Jump to navigation Jump to search

The Headache programming language is a Turing Complete language for generating brainfuck programs.

It borrows most of its syntax from C.

It is open source and its repository can be found here.

Purpose

Headache was designed to be the most lightweight technology to compile brainfuck programs.

One can be download Headache simple typing into an unix terminal

git clone https://github.com/LucasMW/Headache
make
make install

Examples

void main() {
    @"Hello World\n"; 
 }

would be compiled into:

[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++.+++++++++++++++++++++++++++++.+++++++..+++.--------------
-----------------------------------------------------------------.+++++++++++++++
++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++
+.+++.------.--------.-----------------------------------------------------------------
-------------------------.[-]Printing string


void main(){
	byte a;
	byte b;
	byte c;
	byte d;
	a = (10*6+3)/7; /* 63/7 = 9 */
	b = (10*23-5*23)/23; /* 5*23/23 = 5 */
	c = 0/0+10/10; /* 0/0 converts to zero in headache */
	d = a/a + b/b + c/c;
	@"a: "; @a; @"\n";
	@"b: "; @b; @"\n";
	@"c: "; @c; @"\n";
	@"d: "; @d; @"\n";
 }

would run:

a: 9
b: 5
c: 1
d: 3



Tools and Developer Environment

It's compiler, hac, is capable of transpiling headache programs into brainfuck. The generated brainfuck programs can be run in any decent 8 bit brainfuck interpreter.

Headache is also bundled with a custom brainfuck interpreter that includes extra features useful for debugging

Headache is also bundled with an expander program. This program can transform 8 bit brainfuck programs into 16 bit programs, 32 bit programs and so on.

Last, but not least, Headache is bundled with bfalgoConverter program, an utility for converting Brainfuck Algorithms webpage's sample pseudocode into bfalgo() calls inside Headache's source code, i.e. is a tool for developers to make it easier to update Headache with new algorithms.

See also

Official wiki