Search code examples
compiler-construction

Incremental Bootstrapping in Compiler Design


I have a question regarding the nature of Incremental Bootstrapping. Let's say that I would like to design a bootstrapped compiler for some language. So I write an initial compiler for a small subset of that language (A) in some other language. Now I want to extend A to become B (which is closer to the desired language), and I write the compiler for B in A. My question is: Should the B compiler compile B to A or B fully?

Essentially:

  • B -> A (compiled by A, then the A is then compiled by the initial compiler)

    OR

  • B -> target code (compiled completely by A)

Or is there something else entirely that should occur? I have been looking around for a while and it is still somewhat unclear to me. Thanks!


Solution

  • I would make the B compiler produce target code unless there is a very good reason not to. There is very little point in making the B compiler generate A, but if you want a quick way to make a compiler that compiles for many different target platforms you could consider generating C code as an intermediate step since then your compiler targets any system that has a C compiler. You could also consider generating Java byte-code or LLVM-IR.