Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lifthrasiir/esotope-bfc

Esotope Brainfuck Compiler (2009)
https://github.com/lifthrasiir/esotope-bfc

Last synced: 2 months ago
JSON representation

Esotope Brainfuck Compiler (2009)

Awesome Lists containing this project

README

        

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

by Kang Seonghoon

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
#include
#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
#include
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.