Tim's Befunge Compiler
Overview
Tim's Befunge Compiler (or The Befunge Compiler, so as not to be possessive, or
simply TBC) is a pseudocompiler for
Befunge-93
source files. It is written in ANSI
C, and it outputs an ANSI C version of its input file. This output file
contains the Befunge program, already loaded into an array, and the guts of
Chris Pressey's b93 interpreter.
Just for kicks, I'll emphasize this. TBC does not actually
compile the Befunge program. Instead, it creates an
executable similar to Visual Basic, in that it is not compiled all the
way. However, since Befunge is already its own pseudocode, it gets
placed directly in the executable. This cuts down on speed, but also
lets you have self-modifying programs, which is a Cool Thing.
Usage
Compile the source code and place the executable where you normally place
executables. Put the core.int file in the current directory. This
contains the interpreter code, shamelessly yanked from Chris Pressey's b93
interpreter.
Type:
tbc infile.bf > outfile.c
Note the redirection. Unless you're going to do something else with the
output, you'll need that. Finally, run outfile.c through your C
compiler.
Bugs/Features
Off-by-one error
The first version of the Befunge interpreter had an off-by-one error. This
has since been fixed, but older Befunge programs are incompatible with the
newer interpreter. Chris has an option to emulate that bug; I don't. If you
don't want to bother fixing your program, change the variable
v10err_compat to 1 in the output C program.
Directives
TBC supports directives in a very simple way: it eats them. If you have a b97
program that uses them, it will probably crash in a spectacular way. Solution:
don't try compiling them, or add support.
Download it already!
Here are the super-duper extremely incredibly cool wonderful files you need:
If you want, you can also get precompiled binaries.
You are Befunger
to come here.
To my Funge page...
Comments to vsync@bigfoot.com.
Flames to /dev/null.