https://github.com/marklagodych/brainstorm
An optimized and extended Brainfuck interpreter
https://github.com/marklagodych/brainstorm
brainfuck brainstorm characters cpp optimization
Last synced: 2 days ago
JSON representation
An optimized and extended Brainfuck interpreter
- Host: GitHub
- URL: https://github.com/marklagodych/brainstorm
- Owner: MarkLagodych
- Created: 2020-11-01T17:12:35.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-01T17:19:05.000Z (over 5 years ago)
- Last Synced: 2025-02-24T17:14:39.723Z (over 1 year ago)
- Topics: brainfuck, brainstorm, characters, cpp, optimization
- Language: C++
- Homepage:
- Size: 5.86 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Brainstorm
## An optimized and extended Brainfuck interpreter
Brainstorm is an easy-to-use library for fast executing an extended version of Brainfuck.
Links:
- https://en.wikipedia.org/wiki/Brainfuck
- https://esolangs.org/wiki/Brainfuck
Some optimization ideas:
- https://habr.com/ru/post/321630/
## Usage
Build: `make`
Run: `./bin/brainstorm.exe path/to/script.txt`
# Syntax
**+ - . , < > [ ]** do the same things as in Brainfuck.
Any non-command symbols are ignored.
New:
- **`!`** -- works like . but prints the numeric value of current cell;
- **`?`** -- works like , but prompts a number to current cell;
- **`%...%`** -- comment; everything is ignored inside. Example: `+ %+% +` increments current cell only 2 times;
- **`$`** and **`&`** -- virtual console switches; `$` enters console mode and `&` exits the mode.
In virtual console mode all characters are put/got from the command line. After printing a null character to command line, all printed text is treated as command.
Built-in commands:
- `fread x` -- puts contents of file x to the cmd line; a terminating null character is put at the end
- `fwrite x "d"` -- puts d into file x; the double quotes are required and can not be escaped
- `color f b` -- changes console color; f is foreground color; b is background color. Available colors:
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
On Windows OS also these colors are available:
- darkblue
- darkgreen
- darkcyan
- darkred
- darkmagenta
- darkyellow
- grey
- darkgrey
## Example program
```
% This Brainstorm program writes "Hello, world!" into result.txt %
$ % switch to command line mode %
% fwrite result.txt "Hello, world!"\0 %
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++.+++++++++++++++++.-----.-----
----.+++++++++++.---------------.---------------------------------
------------------------------------.+++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++.------------
-.++++++++++++++.++.---------.++++++++.---------------------------
-------------------------------------------.++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++.++++.----.-------
------------------------------------------------------------------
-----------.++.++++++++++++++++++++++++++++++++++++++.++++++++++++
+++++++++++++++++.+++++++..+++.-----------------------------------
--------------------------------.------------.++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+.--------.+++.------.--------.-----------------------------------
--------------------------------.+.[-].
& % switch to console mode %
```