Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/udxs/bizcardbf
Portable C interpreter for BF
https://github.com/udxs/bizcardbf
brainfuck brainfuck-interpreter c esolang esoteric-interpreter esoteric-language esoteric-programming-language gcc interpreter programming-language
Last synced: 2 days ago
JSON representation
Portable C interpreter for BF
- Host: GitHub
- URL: https://github.com/udxs/bizcardbf
- Owner: UDXS
- License: mit
- Created: 2017-10-03T18:28:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-25T18:46:21.000Z (about 7 years ago)
- Last Synced: 2024-11-18T20:57:59.544Z (2 months ago)
- Topics: brainfuck, brainfuck-interpreter, c, esolang, esoteric-interpreter, esoteric-language, esoteric-programming-language, gcc, interpreter, programming-language
- Language: Brainfuck
- Homepage:
- Size: 35.2 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BizCardBF
Portable C interpreter for Brainf*** for my business card## Features
* Interpreter with all Brainf*** features
* Loop depth of 256
* about 65,536 cells (unsigned short)
* max program/input size of about 65,536 characters
* Cell width of 1 byte(char)
* Error Reporting## Compilation/Minification
You may use any C compiler you want on any platform but the build script runs GCC**On Linux, you can easily compile and minify by running the following script:**
chmod 777 build.sh
./build.shThis build script will:
* Download a C minifier from Github (https://github.com/Scylardor/cminify)
* Minify bf.c, storing the output to bf.min.c
* Remove the minifier afterwards
* Compile bf.c with GCC with compiler optimizations, leaving you with the executable "bf"
Compiler optimizations have been shown to reduce runtimes to about a third of what they were.This was tested by running a brainf*** mandelbrot program by Erik Bosman and using the linux time command.
In the test, the program was first compiled without optimizations and took about 1m 32s seconds to run the program.
Then it was compiled with the `-O3` argument in GCC, providing the highest level optimizations
possible. This took about 35s to run, showing a massive speed increase.## Usage
./bf "program" "input"
For example, here is a "cat" program that outputs the input:./bf "+[,.]" "Hello World"
On Windows, it would just be:bf "+[,.]" "Hello World"
### Advanced Bash Usage
If you would like to read the program or input from a file,
use this format:"$(cat program.bf)"
This will place the file contents (from "cat") in place of one of the inputs.For example, you could run:
./bf "$(cat program.bf)" "$(cat program.in)"
If you would like to store the output as well, you can run it like this:
./bf "$(cat program.bf)" "$(cat program.in)" > program.out
**Keep in mind: The first line will always be the credits and, if there is an error, it will be on the third line.**
## Implementation Details
Cells:
* 1 byte cell width
* As many cells as the maximum size of the "short" type
* Over/underflow on cell values/pointersInput/Output:
* Output is printed to "stdout" with two lines of credits before it
* Input can be as long as the max value of the "short" typeLoops:
* Stack depth of 255
* Current stack position stored in char
* Stores current stack depth and the next one to run. This is used to prevent execution of code witin untriggered loopsProgram:
* Used command arguments as input
* First and second line are used for credits
* Third line is where output starts/error is printed
* Prints error if it is missing arguments
* Prints error if loop brackets are unbalanced## Samples/Tests
Samples and tests can be found in the `tests` folder.
All credit to their original authors.To test execution speed, run the program with the `time` command.
## License
This program is licensed under the MIT license.For more information, open the [LICENSE](https://github.com/UDXS/BizCardBF/blob/master/LICENSE) file.
## Credits
Made By Davit Markarian (UDXS) @ udxs.meThanks to [rdebath](https://github.com/rdebath) for helping me find issues and [Scylardor]() for his c minifier - [cminify](https://github.com/Scylardor/cminify)
As well as the creators of the various test programs I used.