EXERCISES

  1. Why do we use separate Scanner and parser in a compiler? Can the parser not do both the jobs?
  2. Why in the Scanner shown in Section 3.2 the symbols like ‘=’ do not appear in the Symbol Table?
  3. Implement a lex based Scanner for the simple language discussed in Chapter 2. Compare it against the hand-coded C language implementation given there, in terms of the size of the programs and ease of developing the Scanner.
  4. Implement lex based Scanners for all the examples for regular expressions given in this chapter.
  5. If you are familiar with Perl or Python language, try to implement the Scanner for the simple language given in Chapter 2 in that language. Compare with the hand-coded C Scanner.
  6. Can you implement a compiler for a programming language ...

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.