Chapter 2: Introduction to compilers

Bootstrapping a Compiler

Using the technique described in the last slide, we try to use a compiler for a language L written in L. For this we require a compiler of L that runs on machine M and outputs code for machine M. First we write LLN i.e. we have a compiler written in L that converts code written in L to code that can run on machine N. We then compile this compiler program written in L on the available compiler LMM. So, we get a compiler program that can run on machine M and convert code written in L to code that can run on machine N i.e. we get LMN. Now, we again compile the original written compiler LLN on this new compiler LMN we got in last step. This compilation will convert the compiler code written in L to code that can run on machine N. So, we finally have a compiler code that can run on machine N and converts code in language L to code that will run on machine N. i.e. we get LNN.