Brainimfuck is a Brainfuck interpreter written in Nim. It has some advanced features, such as syntax checking and highlighting errors (if any are encountered).
Nimble:
nimble install brainimfuck
Manually:
git clone https://github.com/nirokay/brainimfuck && cd brainimfuck && nimble install
Note:
Make sure your nimble binary directory (default on unix: ~/.nimble/bin/
) is in your path!
The interpreter will detect syntax errors such as lone brackets before attempting to execute your brainfuck code.
You can run brainimfuck -h
or brainimfuck --help
for a list of all operations:
-h, --help Displays this help message.
-v, --version Prints version number.
-s, --stats Prints statistics about runtime at the end of the execution.
-d, --debug Prints useful debug information.
-u, --unsafe-run Skips syntax checking and run potentially unsafe/incorrect code.
Stats will print out information about the runtime at the end of execution.
Example:
$ brainimfuck -s tests/brainfuck/helloworld.bf
Hello World!
Instructions:
Execution cicles: 908
Instructions: 110
Timers:
Initialisation Time: 50 microseconds and 627 nanoseconds
Execution Time: 431 microseconds and 620 nanoseconds
---
Total time: 482 microseconds and 247 nanoseconds
This will print debug information with each instruction executed.
Example:
$ brainimfuck -d tests/brainfuck/helloworld.bf
---- Cicle 0 ----
Instruction ID: 0 Instruction: loopBracketBegin Loop stack: {18: 37, 0: 3, 47: 49, 12: 52}
Tape pointer: 0
Current tape value: 0
Tape: {:}
---- Cicle 1 ----
Instruction ID: 4 Instruction: increaseTapeData Loop stack: {18: 37, 0: 3, 47: 49, 12: 52}
Tape pointer: 0
Current tape value: 0
Tape: {:}
---- Cicle 2 ----
Instruction ID: 5 Instruction: increaseTapeData Loop stack: {18: 37, 0: 3, 47: 49, 12: 52}
Tape pointer: 0
Current tape value: 1
Tape: {0: 1}
---- Cicle 3 ----
Instruction ID: 6 Instruction: increaseTapeData Loop stack: {18: 37, 0: 3, 47: 49, 12: 52}
Tape pointer: 0
Current tape value: 2
Tape: {0: 2}
...
This will not check your code for syntax errors. This will lead to a faster run time, but will not be able to output good error messages, if any errors are encountered.