Invocation

PyFunge supports a command-line front end for executing Funge program.

pyfunge(1)

pyfunge is a driver script, used for interpreting a Funge program. In short, you can simply execute Funge program by providing a file name:

$ pyfunge hello.bf

It can read the source code from the standard input (-), but you have to specify the version and number of dimensions (only if it is not Befunge) manually. (See also -v and -d.)

$ pyfunge -v98 -d3 -

General options

-h
--help
Shows the help message.
-V
--version
Shows the version of PyFunge.
-w
--warnings

Enables warnings. PyFunge generates warnings under the following circumstances:

  • Division by zero in Befunge-93 mode.
-x
--skip-first-line

Skips the first line of Funge code. This is useful for standalone script or CGI:

#!/usr/bin/env pyfunge -x -v98
a"!dlrow ,olleH">:#,_0q

Funge options

-v standard
--std standard

Selects the language standard to be used. PyFunge currently supports the following standards:

93, befunge93
The program will run in Befunge-93 mode: Funge space is bounded and every non-Befunge-93 commands do nothing.
98, funge98
The program will run in standard Funge-98 mode. This is default.

PyFunge tries to infer this option from source code extension, so you don’t have to use this generally. If the extension is .bf it is Befunge-93 code, and if it is one of .u98, .b98 and .t98 it is Funge-98 code. But if you have to run the standalone script or C-Funge polyglot this option will be useful.

-d dimension
--dimension dimension

Sets how many dimensions are in the Funge space. dimension can be 1 (Unefunge), 2 (Befunge) or 3 (Trefunge). Note that there is no Unefunge-93 nor Trefunge-93, so a combination like -v93 -d1 will raise an error.

PyFunge tries to infer this option from source code extension (like -v), and if it cannot the number of dimensions defaults to 2, i.e. Befunge.

-1
--unefunge
Short for --dimension 1.
-2
--befunge
Short for --dimension 2.
-3
--trefunge
Short for --dimension 3.
--statistics
Shows statistics after the program is terminated. It displays the elapsed time, the real time (excluding the user input), how many commands are executed and how many ticks are elapsed.

Befunge-93 options

These options will work only in Befunge-93 mode (-v 93).

--division-by-zero value

Selects the behavior when division by zero occurs. value can be one of the following:

number
Division by zero results in given value, no matter what the dividend is. If warnings are enabled it will issue the warning for it.
prompt
PyFunge will ask for a result of division by zero. This is default behavior.
stop
The program will be terminated when division by zero occurs. If warnings are enabled it will issue the warning for it.

Funge-98 explicitly states that division by zero results in zero, so this option cannot be applied.

Funge-98 options

These options will work only in Funge-98 mode (-v 98).

-f fingerprints
--fprint fingerprints
Uses the given fingerprints. Fingerprint names are given as comma-delimited list, and it defaults to every fingerprints in default search path (i.e. funge.fp package).
--disable-fprint
Disables all fingerprints.
-I fingerprintpath
--fprint-include fingerprintpath
Adds fingerprint search path. See PYFUNGE_FPRINT_PATH for the format and detail.
--concurrent
Enables the concurrent Funge. This is default in Funge-98 mode.
--filesystem
Enables the filesystem Funge. This is default in Funge-98 mode.
-C
--no-concurrent
Disables the concurrent Funge.
-F
--no-filesystem
Disables the filesystem Funge.
--list-fprints
Lists all available fingerprints and exits. If PYFUNGE_FPRINT_PATH or -I is set it is used to search additional fingerprints.

Environment variables

PyFunge internally recognizes the following environment variables, if any:

PYFUNGE_NO_PSYCO
If this is set to a non-empty string it disables JIT compilation provided by Psyco. It can slow down the execution quite much, but it is useful for debugging and profiling.
PYFUNGE_FPRINT_PATH

If this is set to a non-empty string it finds fingerprints from given paths separated by path separator, in addition to default search path (which points funge.fp package). A path separator is semicolon in Windows and colon in Unix.

Default search path has a priority over search paths set by this one, and this search paths have a priority over search paths set by -I option.