9

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.

Get Build Your Own Programming Language - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.