This is cfunge - a fast Befunge93/98/109 interpreter in C.
cfunge offers some features that many other standard conforming interpreters don't. For example:
cmake (http://www.cmake.org/) to generate a Makefile for cfunge. At least version 3.12 is required.
A C99 compiler, or one that supports a large subset of C99, such as GCC or clang. Any relatively modern versions should work. Other compilers may or may not work.
A POSIX.1-2001 system with the memory mapped file option. It also needs the function strdup() which is part of the XSI extension. (For POSIX.1-2008 both strdup() and memory mapped files are mandatory and part of the base.) Operating systems known to work:
Windows most likely won't work. Nor do I plan to support it. Cygwin may work, but you are on your own if it doesn't.
Warning: Out of tree builds are highly recommended. Building in the source tree will not work. Building in a sub-directory of the source tree may work but is completely untested.
Warning: Only the make and ninja backends for cmake have been tested. Other backends may work, but are untested.
To build using cmake, you can run these commands in the top source directory:
$ mkdir ../build && cd ../build
$ cmake ../cfunge # Adjust path as needed.
If you are on a 32-bit system you may want to use 32-bit integers (instead of 64-bit integers) for speed. It is also slightly faster on some 64-bit systems to use 32-bit integers. This may vary between architectures. To use 32-bit integers you could use these commands instead of the above ones:
$ mkdir ../build && cd ../build
$ cmake -DUSE_64BIT=OFF ../cfunge # Adjust path as needed.
If you want to see a list of available options use ccmake. It will allow you to select options in a ncurses based user interface. Help is always shown at the bottom of the screen.
$ mkdir ../build && cd ../build
$ ccmake ../cfunge # Adjust path as needed.
(press c)
(change options - use t to show advanced options)
(press c again)
(press g to generate make file)
For more information see:
$ cmake --help
and/or
$ ccmake --help
After having run cmake as described in the above section, just run:
$ make
Not needed, cfunge can be run from build directory, but if you want to (after having compiled cfunge):
$ make install
It is planned to implement most or all of the existing fingerprints, with some exceptions:
Short descriptions of implemented fingerprints:
Finger print | Description |
---|---|
3DSP | 3D space manipulation extension |
BASE | I/O for numbers in other bases |
BOOL | Logic Functions |
CPLI | Complex Integer extension |
DATE | Date Functions |
DIRF | Directory functions extension |
FILE | File I/O functions |
FING | Operate on single fingerprint semantics |
FIXP | Some useful math functions |
FPDP | Double precision floating point |
FPSP | Single precision floating point |
FRTH | Some common forth commands |
HRTI | High-Resolution Timer Interface |
INDV | Pointer functions |
JSTR | Read and write strings in Funge-Space |
MODU | Modulo Arithmetic Extension |
NCRS | Ncurses Extension |
NULL | Funge-98 Null Fingerprint |
ORTH | Orthogonal Easement Library |
PERL | Generic Interface to the Perl Language |
REFC | Referenced Cells Extension |
REXP | Regular Expression Matching |
ROMA | Funge-98 Roman Numerals |
SCKE | TCP/IP async socket and dns resolving extension |
SOCK | TCP/IP socket extension |
STRN | String functions |
SUBR | Subroutine extension |
TERM | Terminal control functions |
TIME | Time and Date functions |
TOYS | Funge-98 Standard Toys |
TURT | Simple Turtle Graphics Library |
For more details please see the specs for each fingerprint. In cases of undefined behaviour in fingerprints, cfunge mostly tries to do the same thing as CCBI.
The Befunge98 standard leaves some things undefined, here is what we do for some of those cases:
y
pushes time in UTC not local time.k
with a negative argument reflects.#
across edge of funge-space may or may not skip first char after wrapping
depending on exact situation.(
and )
with a negative count reflects and doesn't pop any fingerprint.t
).,
instruction.The option -s 93
does not prevent the program from accessing outside the first
80x25 cells. Nor does it disallow instructions that didn't exist in 93. It does
however change space behaviour to match 93 style.
If a program depends on a instruction that is undefined in 93 to reflect, it
should be easy to replace such instructions with a r for reflect or any in the
range A
-Z
(and not load any fingerprint).
Further division by zero always returns 0 in all modes, though the Befunge93 specs says the interpreter should ask the user what result he/she wants in that situation.
Sandbox mode prevents Funge programs from doing "harmful" things, this includes, but is not limited to:
cfunge uses decimal versions as of 1,0. That is, 1,15 is between 1,1 and 1,2, treating the number as a proper decimal number. In addition, the widely used (outside English that is) convention of comma (,) as the decimal separator is used instead of a period.
For the y
instruction, the version number multiplied by 10000 is used. Should
more than 4 decimals ever be used, the versioning scheme will change.