Language::BF - BF virtual machine in perl
my $bf = Language::BF->new(<<EOC); ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<< +++++++++++++++.>.+++.------.--------.>+.>. EOC $bf->run; print $bf->output; # "Hello World!\n";
Language::BF is a straightforward (rather boring) implementation of Brainfuck programming language.
Language::BF is a OOP module that offers following methods
Constructs the BF virtual machine.
Constructs the BF virtual machine from BF source file.
Resets the virtual machine to its initial state
$econstruct the virtual machine. does. $bf->reset
$bf->reset
Sets the stdin of the virtual machine.
Runs the virtual machine. By default it runs perl-compiled code. By setting $mode to non-zero value, it runs as an iterpreter.
$mode
Step-executes the virtual machine.
Retrieves the stdout of the virtual machine.
Returns the perl-compiled source code that implements the virtual machine.
Returns the executable perl code; the difference between this and as_source is that this one adds interface to STDIN/STDOUT so it can be directly fed back to perl.
as_source
perl -MLanguage::BF \ -e 'print Language::BF->new_from_file(shift)->as_perl' source.bf\ | perl
is equivalent to running source.bf.
Returns the c source.
None by default.
Acme::Brainfuck
http://en.wikipedia.org/wiki/Brainfuck
Dan Kogai, <dankogai@dan.co.jp>
Copyright (C) 2006 by Dan Kogai
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install Language::BF, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Language::BF
CPAN shell
perl -MCPAN -e shell install Language::BF
For more information on module installation, please visit the detailed CPAN module installation guide.