NAME
Language::BF - BF virtual machine in perl
SYNOPSIS
my $bf = Language::BF->new(<<EOC);
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<
+++++++++++++++.>.+++.------.--------.>+.>.
EOC
$bf->run;
print $bf->output; # "Hello World!\n";
DESCRIPTION
Language::BF is a straightforward (rather boring) implementation of Brainfuck programming language.
Language::BF is a OOP module that offers following methods
METHODS
- new([$code, $input])
-
Constructs the BF virtual machine.
- new($filename)
-
Constructs the BF virtual machine from BF source file.
- reset
-
Resets the virtual machine to its initial state
- code($code)
- parse($code)
-
$econstruct the virtual machine. does.
$bf->reset
- input
-
Sets the stdin of the virtual machine.
- run([$mode])
-
Runs the virtual machine. By default it runs perl-compiled code. By setting
$mode
to non-zero value, it runs as an iterpreter. - step
-
Step-executes the virtual machine.
- output
-
Retrieves the stdout of the virtual machine.
- as_source
-
Returns the perl-compiled source code that implements the virtual machine.
- as_perl
-
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.perl -MLanguage::BF \ -e 'print Language::BF->new_from_file(shift)->as_perl' source.bf\ | perl
is equivalent to running source.bf.
- as_c
-
Returns the c source.
EXPORT
None by default.
SEE ALSO
http://en.wikipedia.org/wiki/Brainfuck
AUTHOR
Dan Kogai, <dankogai@dan.co.jp>
COPYRIGHT AND LICENSE
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.