An overly-underengineered brainf**k interpreter written in Swift
- Brainfuck 37.9%
- Shell 35.8%
- Swift 17.2%
- Perl 9%
- Roff 0.1%
| .swiftpm | ||
| .vscode | ||
| Benchmarks | ||
| Programs | ||
| Sources | ||
| Tests | ||
| .gitignore | ||
| .spi.yml | ||
| .swift-version | ||
| .swiftlint.yml | ||
| License.md | ||
| Package.resolved | ||
| Package.swift | ||
| Readme.md | ||
BrainflipKit
An overly-underengineered brainfuck interpreter in Swift
Overview
BrainflipKit is a Swift command-line app that interprets brainfuck programs.
If you're here, then chances are you already know what brainfuck is (if not, here's a quick and dirty reference). So instead of dwelling on the basics, I'll go over what makes this interpreter marginally unique.
- Full Unicode support. That's just what happens when you're using Swift.
- The cells are 64-bit instead of 8-bit, due to the aforementioned Unicode support. Most well-written brainfuck programs shouldn't be heavily affected by this.
- The tape is infinite in both directions.
- The end-of-input behavior is customizable -- you can ignore EOI, set the cell to 0, or set the cell to its maximum.
- Some relatively basic optimizations are performed, including:
- Condensing repeated instructions
- Merging
+/-and</>instructions (and removing pairs that cancel each other out) - Replacing multiplication loops with a dedicated instruction