Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/profan/brainiac
A F# brainfuck interpreter/compiler, compiles brainfuck to .NET IL and performs some basic optimizations.
https://github.com/profan/brainiac
Last synced: 29 days ago
JSON representation
A F# brainfuck interpreter/compiler, compiles brainfuck to .NET IL and performs some basic optimizations.
- Host: GitHub
- URL: https://github.com/profan/brainiac
- Owner: profan
- License: mit
- Created: 2023-09-24T22:57:02.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-04T19:47:26.000Z (about 1 year ago)
- Last Synced: 2024-04-24T04:43:15.454Z (8 months ago)
- Language: F#
- Size: 164 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
brainiac
-----------
... If you're here and you're wondering what this is, it's a simple F# program that compiles [brainfuck](https://en.wikipedia.org/wiki/Brainfuck) to [.NET IL](https://en.wikipedia.org/wiki/Common_Intermediate_Language).Some simple optimizations are also applied in the process, some of which are the same as in my [old brainfuck interpreter in C](https://github.com/profan/yet-another-brainfuck-interpreter), but this time the optimizations actually compose much better... and the optimization pass code is a lot easier to read because it's not written in C.
# General Details
* Uses a 65536 * 4 cell space by default.
* Uses (unsigned) byte cells, wrapping on overflow.
* ~~Includes a special '#' instruction to dump the contents of all 65536 cells in a 16 column format, with a newline between each cell printed (as a number, not as a character).~~ (TODO)
* Can directly execute your program, or optionally builds it to a .NET assembly and writes it to file.
* Reads your program from an input string (the --input flag) or from file (with the --file flag).
* Accepts an unbounded input program size.# Compilation Details
* Compiles the executed brainfuck to .NET IL, executing by invoking a method generated in the dynamic assembly.
* Optimizes a few common brainfuck patterns to more specific instructions before compiling to .NET IL, such as:
* \>\>\>, ++++, etc.. optimizes continuous sequences of ptr mov/arithmetic into single operations
* [-] (which is equal to set current cell to zero) to a direct set to zero
* cleans up obviously no-op operations# License
See attached LICENSE file.