So I’ve already posted this question on Stack Overflow, but I wanted to ask it here as well, since I am not sure if they will simply say it is a duplicate (even though the other answers from other questions don’t answer what I asked in a way that helps me).
[https://stackoverflow.com/questions/78539284/in-bootstrapping-how-is-the-compiler-written-in-the-other-langauge-such-that-it](https://stackoverflow.com/questions/78539284/in-bootstrapping-how-is-the-compiler-written-in-the-other-langauge-such-that-it)
So I was wondering if there were direct examples people could give of how the bootstrap compiler is actually written such that it actually represents the language you want to write in another language, because my head can’t wrap itself around it and most sources are fairly vague and just assume you know how it is done.
Hell, maybe if people try and explain it in a metaphorical way and walk me through how the bootstrap compiler is written to represent language X in language Y, that might help too, since I am not a programmer, but this concept is stressing me out from knowing I don’t understand it.
In: Technology
The general idea isn’t that hard. A compiler is a program that takes some input written in some language L (set of grammar, symbols) and outputs something in another language L’. Usually L’ is machine code, which can be directly executed by the CPU.
Denote as L -> L’ meaning “something written in L transformed into something written in L’ “ … in other words a compiler.
Then it should be possible to daisy chain compilers, as long as the input language of one compiler matches the output of another:
L -> L’ -> L’’ -> … -> L_final
The trick is, if we group arrows together…
L -> (L’ -> L’’) the stuff inside the parentheses is just a compiler.
What this is telling me is that I can write a L’ -> L’’ compiler in L.
And we’re done because I just basically described bootstrapping.
Latest Answers