Intermediate Code Generation
After the semantic analysis is complete, you can contemplate how to execute the program. For compilers, the next step is to produce a sequence of machine-independent instructions called intermediate code. This chapter starts by defining intermediate code and then shows you how to generate intermediate code, by looking at examples for the Jzero language. After the preceding chapters, where you learned how to write tree traversals that analyze and add information to the syntax tree constructed from the input, in this chapter we finally begin the process of constructing the compiler’s output. Intermediate code generation is usually followed by an optimization phase and final code generation for a target machine.
This chapter covers the following main topics:
- What is intermediate code?
- An intermediate code instruction set
- Generating code for expressions
- Generating code for control flow
We will start by gaining...