Skip to content

David17c/Headache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Headache

A simple programming language that makes Brainfuck easier to read and write. It replaces Brainfuck's symbols with words like increment, mov eright, and print, while still compiling directly into standard Brainfuck code.

Language Commands

Values in square brackets ([]) are optional.

Command Brainfuck Description
move right [amount] > × amount Move the pointer right by 1 cell, or by amount cells.
move left [amount] < × amount Move the pointer left by 1 cell, or by amount cells.
increment [amount] + × amount Increment the current cell by 1, or by amount.
decrement [amount] - × amount Decrement the current cell by 1, or by amount.
input [amount] , × amount Read 1 byte into the current cell, or read amount bytes.
print [amount] . × amount Output the current cell once, or amount times.
loop [ Begin a loop.
end ] End the current loop.
clear [-] Resets the current cell to 0.

Case Insensitive

The translator converts everything to lowercase before parsing:

increment 65
Print

mOVe RiGht 2
incremeNT 10
PRINT

is equivalent to:

increment 65
print

move right 2
increment 10
print

Complete Syntax Example

increment 5
loop
    decrement
    move right
    increment
    back
end

move right
print
input
decrement 10
print 2
back 1
move right 3

CLI Usage

Run a Headache program

headache run program.ha

Translates the file to Brainfuck and executes it.

Run a Brainfuck program

headache run program.bf

Executes a Brainfuck file directly.

Compile to Brainfuck and print to terminal

headache program.ha

Example:

increment 3
print

Output:

+++.

Compile to a Brainfuck file

headache program.ha output.bf

Example:

headache hello.ha hello.bf

Generates:

hello.bf

containing the translated Brainfuck code.

"Hello, World!" in Headache

increment 10
loop
    move right
    increment 7
    move right
    increment 10
    move right
    increment 3
    move right
    increment 1
    move left 4
    decrement 1
end

move right
increment 2
print

move right
increment 1
print

increment 7
print
print

increment 3
print

move right
increment 2
print

move left 2
increment 15
print

move right
print

increment 3
print

decrement 6
print

decrement 8
print

move right
increment 1
print

move right
print

About

A programming language built on top of Brainfuck

Resources

License

Stars

10 stars

Watchers

0 watching

Forks

Contributors

Languages