Prefunge

From Esolang
Jump to navigation Jump to search

Prefunge is a Befunge derivative by User:BoundedBeans.

Syntax

Prefunge is identical to Befunge, but now the C preprocessor is run on it. Additionally, the following restrictions are placed:

  • Unless the first non-whitespace character on a line is #, the only allowed character set is AB(), along with whitespace.
  • All defined macros must contain __TIME__. Obviously this means programs may run differently depending on when the program is preprocessed (which in this language is basically just compiling into Befunge).
  • Depending on which interpreter is used after preprocessing, the macros __FUNGE_FBBI (FBBI), __FUNGE_C (cfunge), __FUNGE_RC (rcfunge), __FUNGE_SHARP (BefungeSharp), __FUNGE_PY (pyfunge), or whatever else will be defined. Prefunge implementations can either immediately call the interpreter, or, if it doesn't, it can depend on the user for determining that by passing in a command-line flag.
  • Since a ton of extra lines are added by the C preprocessor apart from the actual preprocessed code, any line starting with # after the preprocessor has been run is removed.

Variations

There are a few flavors of Prefunge:

  • Prefunge-93 (Befunge-93)
  • Prunefunge-98 (Unefunge-98)
  • Prbefunge-98 (Befunge-98)
  • Prtrefunge-98 (Trefunge-98)

Examples

Hello, world!

#define AAAA __TIME__ $$$$$$$$"!dlrow ,olleH"zzzzzzz
#define AAAB @ __TIME__ $$$$$$$$ __TIME__ $$$$$$$$
#define AABA > __TIME__ $$$$$$$$ __TIME__ $$$$$$$$
#define AABB : __TIME__ $$$$$$$$ __TIME__ $$$$$$$$
#define ABAA v __TIME__ $$$$$$$$ __TIME__ $$$$$$$$
#define ABAB _ __TIME__ $$$$$$$$ __TIME__ $$$$$$$$
#define ABBA , $$$$$$$$ __TIME__ $$$$$$$$ __TIME__
#define ABBB ^ $$$$$$$$ __TIME__ $$$$$$$$ __TIME__
AAAA AABA AABB ABAA
AAAB ABBB ABBA ABAB AAAB

This expands to:

"00:00:00" $$$$$$$$"!dlrow ,olleH"zzzzzzz > "00:00:00" $$$$$$$$ "00:00:00" $$$$$$$$ : "00:00:00" $$$$$$$$ "00:00:00" $$$$$$$$ v "00:00:00" $$$$$$$$ "00:00:00" $$$$$$$$
@ "00:00:00" $$$$$$$$ "00:00:00" $$$$$$$$ ^ $$$$$$$$ "00:00:00" $$$$$$$$ "00:00:00" , $$$$$$$$ "00:00:00" $$$$$$$$ "00:00:00" _ "00:00:00" $$$$$$$$ "00:00:00" $$$$$$$$

and only runs in Prbefunge-98, because the lines are too wide for Prefunge-93 (Prefunge-93 is very limited due to the playfield limits and the wasted space from all the __TIME__ calls).