Project

rbf

0.0
No commit activity in last 3 years
No release in over 3 years
A simple Brainfuck interpreter.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

RBF - Ruby BrainFuck

Yay, birthday, dragon book, let's code.

With this thingy you can parse and evaluate brainfuck and brainfuck-like languages, you can define your own syntax (aka aliases) to use as a brainfuck language.

This is the default syntax:

{ 
  :forward  => '>',
  :backward => '<',

  :increase => '+',
  :decrease => '-',

  :output => '.',
  :input  => ',',

  :while_start => '[',
  :while_end   => ']' 
}

And this is a custom syntax:

{ 
  :forward  => '!!!!',
  :backward => 'ASD',

  :increase => 'XD',
  :decrease => 'LOL',

  :output => 'PLS',
  :input  => 'CMQ',

  :while_start => '[',
  :while_end   => ']' 
}

You can also run brainfuck sources or run a brainfuck repl, just use the rbf binary.

Examples

require 'rbf'

RBF.parse('++[.]')                              # => ["+", "+", ["."]]
RBF.parse('XD XD [PLS]', RBF::Syntax::Nintendo) # => ["+", "+", ["."]]

RBF['++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.'] # => "Hello World!\n"