How to translate easily?
In order to translate a high level code to a machine code one needs to go step by step, with each step doing a particular task and passing out its output for the next step in the form of another program representation. The steps can be parse tree generation, high level intermediate code generation, low level intermediate code generation, and then the machine language conversion.
As the translation proceeds the representation becomes more and more machine specific, increasingly dealing with registers, memory locations etc.
. Translate in steps. Each step handles a reasonably simple, logical, and well defined task
. Design a series of program representations
. Intermediate representations should be amenable to program manipulation of various kinds (type checking, optimization, code generation etc.)
. Representations become more machine specific and less language specific as the translation proceeds
|