The compiler is an odd thing.
Firstly, and I don't recall this anywhere else, it compiles backwards. Literally. When you figure out how it works, it actually makes a lot of sense though.
Secondly it's not really a compiler. It produces P-Code - a simple bytecode - from tokens. The sensible thing to do is to work out some sort of correlation between the tokens and the P-Code. So with the odd exception - the data operations, constants, identifiers, if/then/else all the compiler does is copy the input.
Backwards ;-)
It is also bootstrapping. So the compiler is written in the language. I don't know how the first compiler was created (I'd guess it was BASIC) but I'll probably use Python.
No comments:
Post a Comment