v4.05
[language-befunge.git] / lib / Language / Befunge.pm
blob59647fd01f5cdbfbecf943ca89af6ae33dd400e6
2 # This file is part of Language::Befunge.
3 # Copyright (c) 2001-2008 Jerome Quelin, all rights reserved.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the same terms as Perl itself.
10 package Language::Befunge;
11 require 5.010;
13 use strict;
14 use warnings;
16 use Carp;
17 use Language::Befunge::Interpreter;
19 # Public variables of the module.
20 our $VERSION = '4.05';
21 $| = 1;
23 sub new {
24 shift;
25 return Language::Befunge::Interpreter->new(@_);
29 __END__
31 =head1 NAME
33 Language::Befunge - a generic funge interpreter
36 =head1 SYNOPSIS
38 use Language::Befunge;
39 my $interp = Language::Befunge->new( { file => 'program.bf' } );
40 $interp->run_code( "param", 7, "foo" );
42 Or, one can write directly:
43 my $interp = Language::Befunge->new;
44 $interp->store_code( <<'END_OF_CODE' );
45 < @,,,,"foo"a
46 END_OF_CODE
47 $interp->run_code;
50 =head1 DESCRIPTION
52 Enter the realm of topological languages!
54 This module implements the Funge-98 specifications on a 2D field (also
55 called Befunge). It can also work as a n-funge implementation (3D and
56 more).
58 This Befunge-98 interpreters assumes the stack and Funge-Space cells
59 of this implementation are 32 bits signed integers (I hope your os
60 understand those integers). This means that the torus (or Cartesian
61 Lahey-Space topology to be more precise) looks like the following:
63 32-bit Befunge-98
64 =================
66 |-2,147,483,648
68 | x
69 <-----------+----------->
70 -2,147,483,648 | 2,147,483,647
72 y|2,147,483,647
76 This module also implements the Concurrent Funge semantics.
79 =head1 PUBLIC METHODS
81 =head2 new( [params] )
83 Call directly the C<Language::Befunge::Interpreter> constructor. Refer
84 to L<Language::Befunge::Interpreter> for more information.
87 =head1 TODO
89 =over 4
91 =item o
93 Write standard libraries.
95 =back
98 =head1 BUGS
100 Although this module comes with a full set of tests, maybe there are
101 subtle bugs - or maybe even I misinterpreted the Funge-98
102 specs. Please report them to me.
104 There are some bugs anyway, but they come from the specs:
106 =over 4
108 =item o
110 About the 18th cell pushed by the C<y> instruction: Funge specs just
111 tell to push onto the stack the size of the stacks, but nothing is
112 said about how user will retrieve the number of stacks.
114 =item o
116 About the load semantics. Once a library is loaded, the interpreter is
117 to put onto the TOSS the fingerprint of the just-loaded library. But
118 nothing is said if the fingerprint is bigger than the maximum cell
119 width (here, 4 bytes). This means that libraries can't have a name
120 bigger than C<0x80000000>, ie, more than four letters with the first
121 one smaller than C<P> (C<chr(80)>).
123 Since perl is not so rigid, one can build libraries with more than
124 four letters, but perl will issue a warning about non-portability of
125 numbers greater than C<0xffffffff>.
127 =back
130 =head1 ACKNOWLEDGEMENTS
132 I would like to thank Chris Pressey, creator of Befunge, who gave a
133 whole new dimension to both coding and obfuscating.
136 =head1 SEE ALSO
138 =over 4
140 =item L<perl>
142 =item L<http://www.catseye.mb.ca/esoteric/befunge/>
144 =item L<http://dufflebunk.iwarp.com/JSFunge/spec98.html>
146 =back
149 =head1 AUTHOR
151 Jerome Quelin, E<lt>jquelin@cpan.orgE<gt>
153 Development is discussed on E<lt>language-befunge@mongueurs.netE<gt>
156 =head1 COPYRIGHT & LICENSE
158 Copyright (c) 2001-2008 Jerome Quelin, all rights reserved.
160 This program is free software; you can redistribute it and/or modify
161 it under the same terms as Perl itself.
164 =cut