Skip to content

lifthrasiir/esotope-bfc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 

Repository files navigation

  __ __ _ ___ _  _  __    _  _  _ ___    __    _      __ _     _ ___    __ _ 
 |_ (_ / \ | / \|_)|_    |_)|_)|_| | |\||_ | |/ |/   /  / \|V||_) | |  |_ |_)
 |____)\_/ | \_/|  |__   |_)| \| |_|_| ||  |_|\_|\   \__\_/| ||  _|_|__|__| \

                  by Kang Seonghoon <esotope+bfc@mearie.org>


This is the Esotope Brainfuck Compiler: the world's most optimizing Brainfuck-
to-something compiler. Well, it is not a Something-to-Brainfuck compiler like
Jeffry Johnston's BFBASIC, but it translates the Brainfuck code into efficient
target language code (and possibly human-readable), so in this sense it is
actually a _decompiler_ rather than compiler.

There are many Brainfuck-to-C compilers (or Brainfuck-to-ELF compiler, and so
on) available, but there are almost no compiler which can translate the
following Brainfuck code:

    >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.>>>++++++++[
    <++++>-]<.>>>++++++++++[<+++++++++>-]<---.<<<<.+++.------.--------.>>+.

...into something like the following code:

    /* generated by esotope-bfc */
    #include <stdio.h>
    #include <stdint.h>
    #define PUTS(s) fwrite(s, 1, sizeof(s)-1, stdout)
    static uint8_t m[30000], *p = m;
    int main(void) {
        PUTS("Hello World!");
        return 0;
    }

Surprisingly I had seen no compiler reached this one! So I started to make my
own compiler; Esotope Brainfuck Compiler is the result. (Actually, there are
now one or two other compilers reached this state, but they are inspired by
Esotope Brainfuck Compiler.)


                                   ==========
                                   HOW TO USE
                                   ==========

Esotope Brainfuck Compiler requires Python 2.5 or later. Optionally you can
use Psyco JIT compiler for better performance; Psyco is certainly required for
very large Brainfuck code, including Jon Ripley's The Lost Kingdom.

Use "esotope-bfc" Python script to invoke Esotope Brainfuck Compiler. It can
read the code from the given file, or standard input ("-"):

    $ ./esotope-bfc -
    +[]
    ^D
    /* generated by esotope-bfc */
    #include <stdio.h>
    #include <stdint.h>
    static uint8_t m[30000], *p = m;
    int main(void) {
        while (1); /* infinite loop */
    }


                                    =======
                                    LICENSE
                                    =======

Esotope Brainfuck Compiler is written by Kang Seonghoon. It can be freely
used and redistributable under the terms of MIT license.

About

Esotope Brainfuck Compiler (2009)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages