A Brainfuck interpreter made in Zig
| examples | ||
| src | ||
| .gitignore | ||
| build.zig | ||
| build.zig.zon | ||
| flake.lock | ||
| flake.nix | ||
| LICENSE | ||
| README.md | ||
| treefmt.nix | ||
Zig Brainfuck interpreter
A Brainfuck interpreter written in Zig
Build
Using Zig of course! Here are some examples of build commands:
# Build interpreter
zig build
# Run the tests
zig build test
# Disable value and pointer overflow wrapping
# If the value in the stack overflows, it will stay the same
# If the pointer to the stack overflows, it will panic and return an error
zig build -Dwrap_addr_overflow=false -Dwrap_val_overflow=false
# Non-debug build (debug build will return information about the stack on each Brainfuck call)
zig build -Doptimize=ReleaseFast
Usage
The interpreter takes any number of argument, each one can be a Brainfuck program. You can also pass a file with the -file parameter:
# Run an Hello world program
bf ">+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-]<.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>-]<+.[-]++++++++++."
# Run the sierpinski example
bf -file examples/sierpinski.b
EOF can be sent with Ctrl+D on UNIX systems, Ctrl+Z then Enter on Windows systems.