braindamage

From Esolang
Jump to navigation Jump to search

braindamage is a programming language based on Brainfuck that have the same syntax as Brainfuck with a few additions

Syntax

Original brainfuck syntax

Command Description
> Move the pointer to the right
< Move the pointer to the left
+ Increment the memory cell at the pointer
- Decrement the memory cell at the pointer
. Output the character signified by the cell at the pointer
, Input a character and store it in the cell at the pointer
[ Jump past the matching ] if the cell at the pointer is 0
] Jump back to the matching [ if the cell at the pointer is nonzero

Single-character additions

@ changes the pointer to the value of the current cell
~ does bitwise not to the value in the current cell
! changes the value in the current cell to it's index
( the start of a for loop, from i = 0 to i = the current cell value, even if the value in this cell wil change, the maximum for i won't
) end of a for loop
* multiplies the cell by itself
: breaks from the current loop
# left-shifts the current cell by 1
$ right-shifts the current cell by 1

Variable additions

There is also a variable called a that you can change there is { to change the value of the variable (the charecter after will determine what change will be made) and } to change the value of the current cell from the variable (the charecter after will determine what change will be made)

{= sets the variable to the current cell value, }= does the opposite
{+ adds to the variable the current cell value, }+ does the opposite
{- subtracts from the variable the current cells value, }- does the opposite
{* multiplies the variable by the current cell value, }* does the opposite
{~ sets the variable to the bitwise not of the current cell value, }~ does the opposite
{, sets the variable to an input, like the brainfuck ','
}. outputs the variable, like the brainfuck '.'
{# sets the variable to the current cell left-shifted by 1, }# does the opposite
{$ sets the variable to the current cell right-shifted by 1, }$ does the opposite
{& sets the variable to the bitwise and of itself and the current cell value, }& sets the current cell to the same value
{^ sets the variable to the bitwise xor of itself and the current cell value, }^ sets the current cell to the same value

any other charecter is a comment

Hello world example

+++++ +++++ adds 10 to cell 0
(           starts a for loop for 10 times because the current cell value is 10
> +++++ ++  moves to cell 1 and adds 7
> +         moves to cell 2 and adds 1
> +++       moves to cell 3 and adds 3
<<<         comes back to cell 0
)           end of the loop, now cell 1 have 70, cell 2 have 10 and cell 3 have 30
> ++ .      moves to cell 1 (the loop ended in cell 0), addes 2 so the value is 72 and prints the ASCII charecter 'H'
> *+ .      moves to cell 2, multiplies it itself so now it's equal 100, adds 1 and prints 'e'
+++++ ++ .  adds 7 to cell 2 and print 'l'
.{=         prints 'l' again and stored this value into a so a = 108
+++ .       adds 3 and prints 'o'
> ++ .      moves to cell 3 which is 30, adds 2 so it's 32 and prints ' '
<< +++++ +++++ +++++ . moves to cell 1 which is 72, addes 15 so its 87 and print 'W'
> .         moves to cell 2 which is 111 and prints 'o'
+++ .       adds 3 and prints 'r'
}=.         sets cell 2 to a which is 108 and prints 'l'
----- --- . subtracts 8 and prints 'd'
> + .       moves to cell 3 which is 32, adds 1 and print '!'
<<< .       moves to cell 0 which is 10 and prints a new line

History

created by thejoni (otherwise known as jonigrin) in 2023 using c++

External resources

the language github page