ebf-compiler

A self hosting Extended brainfuck to pure brainfuck compiler

This project is maintained by westerp

Creating a self-hosting compiler

What I expect you to know to understand this

I expect you to know elementary brainfuck and I expect you to have tried to create your own brainfuck programs. You may try some of the links on this page or google it.

What is a compiler

According to Wikipedia it is a program
that converts a high level source code to a lower level source code or
machine code. brainfuck, how I see it, is machine code with readable
instructions so that there is no need for a Assembly language other than
the instructions themselves. A brainfuck CPU design
example is made by Clifford Wolf.


Has this been done before?

There are several approaches made by many to create extensions to
brainfuck.

By changing the language

Some create extensions in the interpreter/compiler so that you actually
change the CPU. a notable example would be
pbrain, where Paul M. Parks
used () to enclose procedures and : to call them. Which procedure you define
or call was the value of the current cell. Nice idea but it will never run
on any brainfuck CPU/interpreter og even be compiled by any brainfuck to
native/other compiler. (though Tim Rohlfs did write support in his IDE)


By creating a compiler in perl/c/other language

You define a language and create a compiler that creates valid and
standard brainfuck code. bfmacro by Alva L. Couch and 2 stage compiler bfc=>bfa=>bf by Clifford Wolf. Both of these compile their own invented
extensions to standard brainfuck but non of the compiler are written in
either brainfuck or the language the compiler supports.

The aim of this project

The aim of this project was to make a self-hosting (written in itself)
compiler and see how I could bootstrap this and how it will eventually
evolve. Beeing Turing complete there is nothing you cannot implement in
brainfuck. It's very inspired by Edmund GRIMLEY EVANS' Bootstrapping a simple compiler from nothing which I highly recommend.

If you are interested you may go to [Part 1: Design](/docs/Part1Design.html)