brainduck is an esoteric programming language based on Brainfuck.
You sould compile brainduckc.c
and use it like compiler
gcc brainduckc.c -o brainduckc
./brainduckc main.bd [-o OutputPath] [-m MemSize]
By default compile to a.out
. Can be configured by -o OutputPath
By default MemSize = 30'000
. Can be configured by -m MemSize
Start position = 0
There must be a main
function in your code.
You can use comment line:
//some comment
Or comment block:
/* line 0
line 1
line 2 */
>
- Increase position
<
- Decrease position
+
- Increase memory current position
-
- Decrease memory current position
,
- Read char and put it to memory current position. If EOF - return 0.
This operation is equal to int _ = getchar(); mem[pos] = (_ == -1 ? 0 : _)
in C.
.
- Write char from memory current position. This operation is equal to putchar(mem[pos])
in C.
[
- If memory current position equal zero - go to the end bracket.
]
- Go to the start bracket.
{
- If memory current position equal zero - go to the end bracket.
}
- End bracket.
You can create subtasks using syntax:
name: code
For example:
plus10: ++++++++++
plus11: plus10|+
n
- Print EOL. Equal putchar('\n')
in C.
feof
- Check EOF in stdin. Equel mem[pos] = feof(stdin)
in C.
You can call subtasks using syntax:
name|
You can inline C code using syntax:
C{C code}
You can include other brainduck file using syntax:
#include filename
Now all paths are relative from compiler. Will be change to relative from current file soon.
Read char, write it and write EOL:
main:,.n|
Write all chars from 1 to 255:
main:+[.+]
Read string until \0
, print it reversed and print EOL:
main:>,[>,]<[.<]n|
Print string using C inline code:
main: C{printf("%s\n", "hello from C inline code!");}
,
will read every char.
If you needn't command line arguments, you can clear them by clearArgs
function.