https://github.com/creativcoder/brainfcuk
A brainfuck interpreter written in Rust
https://github.com/creativcoder/brainfcuk
brainfuck brainfuck-interpreter optimization rust-lang
Last synced: 11 months ago
JSON representation
A brainfuck interpreter written in Rust
- Host: GitHub
- URL: https://github.com/creativcoder/brainfcuk
- Owner: creativcoder
- License: mit
- Created: 2015-11-23T10:36:52.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-07-05T17:41:33.000Z (over 8 years ago)
- Last Synced: 2025-01-15T01:47:14.592Z (about 1 year ago)
- Topics: brainfuck, brainfuck-interpreter, optimization, rust-lang
- Language: Rust
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# brainfcuk
An optimizing brainfuck interpreter written in Rust
This implementation preprocess the source code with following optimizations:
1) Performs run length encoding (RLE) of the source text. This obviously shows best results when source has more repeated characters, which are folded into constant arithmetic operations.
2) Eliminates [-] which basically turns into an expression which sets the current cell to zero, replacing it with `|` symbol, which is handled by the interpreter appropriately.
3) Precomputes brace indices on the RLE source for close to constant time loop jumps.
The interpreter builds up its own custom IR and evaluates that IR to compute the end results from the cell.
TODO:
* Add LLVM backend to compile to native code.
* Optimize code to minimize string allocations.
* Better Error messages