This page holds a quick and dirty compiler for a tiny subset of Scheme into Befunge 98. The compiler is written in (hopefully ANSI) Common Lisp.
lambdawith proper lexical scope and closures. It doesn't support variadic argument lists.
(lambda (x y) (_+ x y))). The following datatypes are supported:
call/cc. However, since the compiler transforms the code to CPS, it shouldn't be difficult to add.
define... and in general no every other form not mentioned before :)
lambdas recursively, transforming them into toplevel definitions.
main program (row 0) memory ("heap") (row 1) error handling (row 2) routine handlers (from row 3 on)
p(put) instructions. The first cells are used as internal registers:
xinstruction) is used. The compiler calculates the offset and hardcodes it.
Here it is the compiler. The Scheme code to be compiled is hardcoded in the source code, and so is the output file. You might want to modify it to do something fancier such as reading the code from a file, like normal people do.
The Befunge object code is reeeally big, but it seems to work in at least some examples. Please be patient when you run the result!
Now writing an Unlambda to Befunge compiler should be almost a trivial task :)Happy hacking!