Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/daneelsan/brainfuckz
A Brainfuck interpreter written in Zig
https://github.com/daneelsan/brainfuckz
brainfuck virtual-machine zig
Last synced: about 1 month ago
JSON representation
A Brainfuck interpreter written in Zig
- Host: GitHub
- URL: https://github.com/daneelsan/brainfuckz
- Owner: daneelsan
- License: mit
- Created: 2021-03-17T05:49:02.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-09-08T19:08:11.000Z (over 1 year ago)
- Last Synced: 2024-11-14T20:37:40.462Z (3 months ago)
- Topics: brainfuck, virtual-machine, zig
- Language: Zig
- Homepage:
- Size: 205 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# brainfuckz
A Brainfuck interpreter written in [Zig](https://ziglang.org/).```bash
$ 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
```## Example
### **code**
Run a simple Brainfuck program that prints the letter 'H':
```bash
$ brainfuckz code '>+++++++++[<++++++++>-]<.'
H
```Print the classic "Hello world!":
```bash
$ brainfuckz code '>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]
>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++
.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.'
Hello world!
```### **file**
Run one of the many Brainfuck programs stored in the `program/` subfolder:
```bash
$ brainfuckz file program/MorseTranslate.brain
Brainfuck
-... ..--.- ..--.- ..--.- ..--.- ..--.- ..--.- ..--.- ..--.- -...-
```A [Mandelbrot](http://esoteric.sange.fi/brainfuck/utils/mandelbrot/) program:
```bash
$ brainfuckz file program/Mandelbrot.brain
```
![image](images/Mandelbrot.png)### **test**
Enter a simple Brainfuck REPL and test simple code:
```bash
$ brainfuckz test
brainfuckz> >+++++++++[<++++++++>-]<.
H
brainfuckz>
```## Build
```bash
# 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
```## Resources
* [Basics of BrainFuck](https://gist.github.com/roachhd/dce54bec8ba55fb17d3a.js)
* https://thorstenball.com/blog/2017/01/04/a-virtual-brainfuck-machine-in-go/
* http://www.bf.doleczek.pl/
* https://en.wikipedia.org/wiki/Brainfuck
* https://github.com/daneelsan/BrainVirtualMachine