v3.03
[language-befunge.git] / lib / Language / Befunge.pm
blob747a5425e8d4e2eab82d3923a29320657d2ce26a
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.006;
13 use strict;
14 use warnings;
16 use Carp;
17 use Language::Befunge::Interpreter;
19 # Public variables of the module.
20 our $VERSION = '3.03';
21 $| = 1;
23 sub new {
24 shift;
25 return Language::Befunge::Interpreter->new(@_);
29 __END__
31 =head1 NAME
33 Language::Befunge - a Befunge-98 interpreter
36 =head1 SYNOPSIS
38 use Language::Befunge;
39 my $interp = Language::Befunge->new( "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 Trefunge implementation (3D).
57 This Befunge-98 interpreters assumes the stack and Funge-Space cells
58 of this implementation are 32 bits signed integers (I hope your os
59 understand those integers). This means that the torus (or Cartesian
60 Lahey-Space topology to be more precise) looks like the following:
62 32-bit Befunge-98
63 =================
65 |-2,147,483,648
67 | x
68 <-----------+----------->
69 -2,147,483,648 | 2,147,483,647
71 y|2,147,483,647
74 This implementation is meant to work on unix-like systems, because
75 this interpreters only handle the character which ordinal value is 10
76 (also known as \n) as an End-Of-Line chars. In particular, no warranty
77 is made neither for Microsoft systems (\r\n) nor for Macs (\r).
79 This module also implements the Concurrent Funge semantics.
82 =head1 PUBLIC METHODS
84 =head2 new( [params] )
86 Call directly the Language::Befunge::Interpreter constructor. Refer to
87 L<Language::Befunge::Interpreter> for more information.
90 =head1 TODO
92 =over 4
94 =item o
96 Write standard libraries.
98 =back
101 =head1 BUGS
103 Although this module comes with a full set of tests, maybe there are
104 subtle bugs - or maybe even I misinterpreted the Funge-98
105 specs. Please report them to me.
107 There are some bugs anyway, but they come from the specs:
109 =over 4
111 =item o
113 About the 18th cell pushed by the C<y> instruction: Funge specs just
114 tell to push onto the stack the size of the stacks, but nothing is
115 said about how user will retrieve the number of stacks.
117 =item o
119 About the load semantics. Once a library is loaded, the interpreter is
120 to put onto the TOSS the fingerprint of the just-loaded library. But
121 nothing is said if the fingerprint is bigger than the maximum cell
122 width (here, 4 bytes). This means that libraries can't have a name
123 bigger than C<0x80000000>, ie, more than four letters with the first
124 one smaller than C<P> (C<chr(80)>).
126 Since perl is not so rigid, one can build libraries with more than
127 four letters, but perl will issue a warning about non-portability of
128 numbers greater than C<0xffffffff>.
130 =back
133 =head1 ACKNOWLEDGEMENTS
135 I would like to thank Chris Pressey, creator of Befunge, who gave a
136 whole new dimension to both coding and obfuscating.
139 =head1 SEE ALSO
141 =over 4
143 =item L<perl>
145 =item L<http://www.catseye.mb.ca/esoteric/befunge/>
147 =item L<http://dufflebunk.iwarp.com/JSFunge/spec98.html>
149 =back
152 =head1 AUTHOR
154 Jerome Quelin, E<lt>jquelin@cpan.orgE<gt>
156 Development is discussed on E<lt>language-befunge@mongueurs.netE<gt>
159 =head1 COPYRIGHT & LICENSE
161 Copyright (c) 2001-2008 Jerome Quelin, all rights reserved.
163 This program is free software; you can redistribute it and/or modify
164 it under the same terms as Perl itself.
167 =cut