--------------------------------------------------------------------------- README : The Hamster BF Compiler v0.04 --------------------------------------------------------------------------- Jon Simons (simonsj at the domain ccs dot neu dot edu) November, 2008 --------------------------------------------------------------------------- The Hamster BF compiler is the world's most diverse, highly-optimizing, well-commented, and modularly designed BF compiler ever implemented. Hamster was written because I wanted to code something in Scheme, and I think that the idea of a highly-optimizing BF compiler which can emit a perverse number of target languages is rather hilarious. The source code is arranged as follows: bf-lex.scm The lexing module. Lexes tokens from an input file. bf-parser.scm The parsing module. Converts lexed tokens into a BF AST via a hand-written recursive descent parser. bf-ast-to-ir.scm The AST -> IR translation module. Defines a BF Intermediate Representation and provides an ast->ir transformation function. optimizations/ This directory contains IR optimization modules. Each module exports a function mapping IR -> IR, and contains a detailed description of the optimization that it performs. ops.scm A single point of inclusion for all of the optimization files. collapse-mults.scm Collapses multiplication loops. collapse-zeroes.scm Collapses zero loops. dead-loops.scm Eliminates dead loops. emitters/ This directory contains code-emitter modules for all of the target languages. bf-emit-ir.scm BF Intermediate Representation bf-emit-c.scm ANSI C bf-emit-java.scm Java bf-emit-mips.scm MIPS Assembly bf-emit-x86m.scm MASM x86 Assembly (16-bit for DOS) bf-emit-llvm.scm LLVM Assembly bf-compiler.scm Contains the main entry point. Imports lexing, parsing, IR transformation, and target language emitter modules. The source code is full of great comments, ready for your viewing pleasure. Running the compiler requires MzScheme version 4, which can be downloaded here: http://www.plt-scheme.org/software/mzscheme/ The command I use to run the compiler is: mzscheme bf-compiler.scm If you'd like more information on the BF language, the Esolang Wiki is an excellent source: http://www.esolangs.org/wiki/Brainfuck That's all.