Language::Befunge::Interpreter - an interpreter for Language::Befunge
version 5.000
Create a new Befunge interpreter. As an optional first argument, you can pass it a filename to read Funge code from (default: blank torus). All other arguments are key=>value pairs. The following keys are accepted, with their default values shown:
Dimensions => 2, Syntax => 'befunge98', Storage => 'laheyspace'
The following is a list of attributes of a Language::Befunge object. For each of them, a method get_foobar and set_foobar exists, which does what you can imagine - and if you can't, then i wonder why you are reading this! :-)
get_foobar
set_foobar
the current Instruction Pointer processed (a L::B::IP object)
the number of dimensions this interpreter works in.
the script filename (a string)
the handprint of the interpreter
the current set of IPs travelling in the Lahey space (an array reference)
the set of IPs that will travel in the Lahey space after the current tick (an array reference)
the current supported operations set.
the parameters of the script (an array reference)
the current return value of the interpreter (an integer)
the LB::Storage object containing the playfield.
LB::Storage
the LB::Wrapping object driving wrapping policy. Private.
LB::Wrapping
Move the $ip according to its delta on the storage.
$ip
If $regex ( a qr// object ) is specified, then $ip will move as long as the pointed character match the supplied regex.
$regex
qr//
Example: given the code ;foobar; (assuming the IP points on the first ;) and the regex qr/[^;]/, the IP will move in order to point on the r.
;foobar;
;
qr/[^;]/
r
Abort the interpreter with the given reason, as well as the current file and coordinate of the offending instruction.
Preload the input buffer with the given value.
Fetch a character of input from the input buffer, or else, directly from stdin.
Read a file (given as argument) and store its code.
Side effect: clear the previous code.
Store the given code in the Lahey space.
Run the current code. That is, create a new Instruction Pointer and move it around the code.
Return the exit code of the program.
Finish the current tick and stop just before the next tick.
Process the current ip.
Write standard libraries.
Although this module comes with a full set of tests, maybe there are subtle bugs - or maybe even I misinterpreted the Funge-98 specs. Please report them to me.
There are some bugs anyway, but they come from the specs:
About the 18th cell pushed by the y instruction: Funge specs just tell to push onto the stack the size of the stacks, but nothing is said about how user will retrieve the number of stacks.
y
About the load semantics. Once a library is loaded, the interpreter is to put onto the TOSS the fingerprint of the just-loaded library. But nothing is said if the fingerprint is bigger than the maximum cell width (here, 4 bytes). This means that libraries can't have a name bigger than 0x80000000, ie, more than four letters with the first one smaller than P (chr(80)).
0x80000000
P
chr(80)
Since perl is not so rigid, one can build libraries with more than four letters, but perl will issue a warning about non-portability of numbers greater than 0xffffffff.
0xffffffff
Jerome Quelin
This software is copyright (c) 2003 by Jerome Quelin.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Language::Befunge, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Language::Befunge
CPAN shell
perl -MCPAN -e shell install Language::Befunge
For more information on module installation, please visit the detailed CPAN module installation guide.