EXERCISES

Several of the following exercises are to be done on a computer system. A Linux system is recommended. You should have gcc and Java Development Kit (JDK) installed.

  1. The function traverse_parse_tree() in Section 8.1.1 traverses the parse tree in pre-order. Modify it to traverse in in-order and post-order.
  2. In Section 8.2.1 on generating RPN, we saw that certain local values were to be stored in the functions for the Non-Terminals and we used the return-stack for the purpose. This decision was really a hack. It may work in demo programs, but in real-life code, which will be required to handle source programs of arbitrary size, the return-stack will get heavily loaded and may put a limit on the size of the programs which can be translated. ...

Get Compilers: Principles and Practice 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.