Write a compiler in its own language
There are a few possible approaches. You can see the final code on GitHub.
Bootstrapping a compiler from nothing
Running the Action Tree Once we have the action tree, running the code is easy. There are a number of reasons for this, which I will explain later on. Donald Knuth used this for his WEB literate programming system. Generally, interpreting tends to be more flexible, while compiling tends to have higher performance. For example, the first C compiler was probably written in assembler. The first stage is a string containing the entire input source file. Advantages[ edit ] Bootstrapping a compiler has the following advantages:   it is a non-trivial test of the language being compiled, and as such is a form of dogfooding. Interpreted languages are generally easier design, build and learn. Bison works a lot like Flex. And it works. You have new source code and a new runnable version of the compiler, so you have no need for the old versions any more. Gcc, one of the most popular C compilers, was built using this technique.
Generally, interpreting tends to be more flexible, while compiling tends to have higher performance. Also this is the method used for Free Pascal after the initial bootstrap.
The final stage is something that can be run. I made a number of bad choices along the way, but I have rewritten most of the code affected by such mistakes.
Bison works a lot like Flex. This was an important decision to make early on, because a lot of language design decisions are affected by it for example, static typing is a big benefit to compiled languages, but not so much for interpreted ones.
based on 69 review