PyFunge supports a command-line front end for executing Funge program.
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 -
- Shows the help message.
- Shows the version of PyFunge.
Enables warnings. PyFunge generates warnings under the following circumstances:
- Division by zero in Befunge-93 mode.
Skips the first line of Funge code. This is useful for standalone script or CGI:
#!/usr/bin/env pyfunge -x -v98
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.
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.
- Short for --dimension 1.
- Short for --dimension 2.
- Short for --dimension 3.
- 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.
These options will work only in Befunge-93 mode (-v 93).
Selects the behavior when division by zero occurs. value can be one of the following:
- Division by zero results in given value, no matter what the dividend is. If warnings are enabled it will issue the warning for it.
- PyFunge will ask for a result of division by zero. This is default behavior.
- 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.
These options will work only in Funge-98 mode (-v 98).
- 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).
- Disables all fingerprints.
- Adds fingerprint search path. See PYFUNGE_FPRINT_PATH for the format and detail.
- Enables the concurrent Funge. This is default in Funge-98 mode.
- Enables the filesystem Funge. This is default in Funge-98 mode.
- Disables the concurrent Funge.
- Disables the filesystem Funge.
- Lists all available fingerprints and exits. If PYFUNGE_FPRINT_PATH or -I is set it is used to search additional fingerprints.
PyFunge internally recognizes the following environment variables, if any:
- 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.
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.