daneelsan/brainfuckz
A Brainfuck interpreter written in Zig
A Brainfuck interpreter written in Zig.
$ brainfuckz help
Usage: brain [command]
Commands:
code [BRAIN] Give brainfuck code to execute
file [PATH] Execute the code found in a .brain file
help Print this help message and exit
test Enters interactive mode
Run a simple Brainfuck program that prints the letter 'H':
$ brainfuckz code '>+++++++++[<++++++++>-]<.'
H
Print the classic "Hello world!":
$ brainfuckz code '>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]
>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++
.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.'
Hello world!
Run one of the many Brainfuck programs stored in the program/
subfolder:
$ brainfuckz file program/MorseTranslate.brain
Brainfuck
-... ..--.- ..--.- ..--.- ..--.- ..--.- ..--.- ..--.- ..--.- -...-
A Mandelbrot program:
$ brainfuckz file program/Mandelbrot.brain
Enter a simple Brainfuck REPL and test simple code:
$ brainfuckz test
brainfuckz> >+++++++++[<++++++++>-]<.
H
brainfuckz>
# Pull down this project
$ git clone https://github.com/daneelsan/brainfuckz.git
$ cd brainfuckz
# Tested on
$ zig version
0.11.0
# Build in ReleaseFast mode to speed up performance by >10x compared to the default debug mode
$ zig build -Doptimize=ReleaseFast
# For convenience, copy the executable to the top-level directory
$ cp zig-out/bin/brainfuckz brainfuckz