bfrb
bfrb is a simple brainfuck interpreter written in Ruby.
It’s not the most robust code, but it does the job, and has handled all the example code I’ve managed to throw at it.
Usage
To install bfrb: % gem install bfrb Once bfrb is installed, you can use it to interpret your brainfuck code.
First, you can pass brainfuck code directly into it, using the -c parameter: % bfrb -c “,[.,]” Or, you can specify a file with the -f parameter:
% bfrb -f test.bf You can also start an interactive interpreter by running bfrb without any parameters: % bfrb The list of options is viewable with the -h parameter:
% bfrb -h Just in case you feel the need to use another language internally in a Ruby program, I guess you can:
require ‘rubygems’ require ‘bfrb’ bf = BfRb::Interpreter.new bf.run “,[.,]”
History
-
0.1.5 - Modified to use OptionParser for command line parameters, ‘help’ command to REPL
-
0.1.4 - Added a little more documentation, efficiency fixes and Ctrl-X to exit a program
-
0.1.3 - Unmatched brace checks
-
0.1.2 - Added unit tests
-
0.1.1 - Added REPL.
-
0.1.0 - Initial release. Allows running code passed in or from a file.