EXERCISES

  1. Some languages distinguish between keywords and reserved words. Suppose we want to allow a keyword as an identifier under some circumstances, how can it be done?
  2. We have a variable declaration statement int a, available in the simple language. Will it not be better to have a declaration plus initialization like int a 15 which will not only reserve space for variable ‘a’ but also initialize it to a value 15? What changes are required in the grammar, Scanner, parser and code generation to implement this?
  3. The if statement has rather limited power, as no relational operators are available in simple. Suggest a set of relational operators to be included in simple and investigate what modifications are required in various phases of the compiler ...

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.