Funge++ is Befunge interpreter originally written by Conlan Wesson in Java for a Programming Language Concepts course
with minimal functionality. It has since been converted to C++, supports all Funge-98 instructions and N-dimensional
Funge. The Funge++ handprint is 0x464E2B2B (FN++
).
The Funge++ executable funge
uses the first file argument to load the funge program. The first character of the
file is an instruction at (0,0). Each subsequent character is an instruction at X+1. Both carriage returns and
line feed (as well as CRLF) are treated as Y+1 and reset X to zero. Form feeds in the file represent Z+1 and reset
X and Y to zero. Carriage returns and line feeds following a form feed are ignored (i.e FF may be own its own line).
See the man page for more information.
Vertical Tabs in the file represent 4D+1 and reset X, Y, and Z to zero. Carriage returns and line feeds following a vertical tab are ignored. This is not part of the Funge-98 specification, but provides a simple way to create 4-dimensional funges.
Trefunge frunges can be loaded as funge-lib formatted .fl
files.
Higher dimension funges can be loaded as BeQunge formatted .beq
files. Loading a .beq
file implies -lNFUN
.
The split instruction t
can use native threads rather than the tick mechanism described in the Funge-98
specification. This mode can be enabled with -fthreads=native
.
The dimensionality (up to 4D) is determined automatically based on the file contents. This can be overriden with
the -std
argument. Funge-lib formatted files are 3D. Higher dimensions can be determined automatically from BeQunge
formatted files with or without the Dimensions
directive.
Standard instructions which operate on vectors (g
, p
, x
, ?
), operate with vector lengths equal to the number of
dimensions detected. This enables those instructions to function in a standardized way in higher-dimension funges. For
example, in 4D mode, ?
will change the delta to one of 8 possible directions, while x
can move in all possible
directions.
C-style strings can be enabled with -fstrings=c
. In this mode, backslashes in strings are not pused to the stack,
instead, it and the following character are interpretted as an escape sequence. This happens in one tick. In addition
to special characters, this allows quotes and ANSI escape codes in strings.
Funge++ stack and funge-space are 64-bit values. For that reason, FPDP numbers use a single stack cell, and LONG numbers are 128-bit.
Funge++ also supports ><> (Fish) and *><> (Starfish). These can be selected using -std=fish
or -std=sfish
respectively. Alternatively, Funge++ will automatically detect the languge if a .fish
or .sf
file is loaded.
The Funge-98 specification is inconsistent about the delta of the h
and l
instructions (catseye/Funge-98#10).
Funge++ uses thedefinition in the program flow section, that is h
is "delta <- (0,0,1)" and l
is
"delta <- (0,0,-1)". This makes it compatible with BeQunge and Rc/Funge-98. The -finvert-hl
argument flips this
behavior.
Funge++ supports the following fingerprints. These can either be loaded at runtime by the (
instruction, or by
specifying the -l
command line argument.
Funge++ also supports dynamic Funge fingerprints. When a fingerprint is loaded, Funge++ will search for funge-lib files
in the fing
directory before loading a built-in fingerprint. This allows users to override the built-in fingerprints.
Instructions from dynamic Funges run with the same stack as the IP that called them.
BASE
I/O for numbers in other bases.
BITW
Bitwise Operators.
BOOL
Boolean Operators.
CPLI
Complex Integer Extension.
DBUG
Debugger Control.
DIRF
Directory Functions.
FING
Operate on single fingerprint semantics.
FISH
><> and *><> commands.
FIXP
Fixed point math functions.
FPDP
Double precision floating point.
FPRT
Formatted print.
FPSP
Single precision floating point.
FRTH
Some common forth commands.
HRTI
High Resolution Timer Interface.
IIPC
Inter IP Communication.
JSTR
3d string vectors.
LONG
Long Integers.
MODE
Standard Modes.
MODU
Modulo Arithmetic Extension.
MVRS
Multiverse extension.
NFUN
N-Dimensional Funge.
NULL
Null Fingerprint.
ORTH
Orthogonal Easement Library.
PERL
Generic Interface to the Perl Language.
REFC
Referenced Cells Extension.
ROMA
Roman Numerals.
STRN
String functions.
SUBR
Subroutine extension.
TERM
Terminal extension.
TOYS
Standard Toys.
The Funge++ debugger, known as defunge, can be run on any Befunge program by specifying the -g
command line argument.
See Defunge for details.