Class 7: Specifying Syntax and Scanning

Slides

Display version (pdf).

Downloads

Homework

Reading: PLP, Sections 2.1 "Specifying Syntax" and 2.2 "Scanning".

Solutions to the following exercises should be typed or printed neatly and turned in at the beginning of Friday's class.

  1. Do we need to have separate scanning and parsing phases in compilation? Which one could technically be eliminated? Why would this be a bad idea?
  2. Why do automatic scanner generators generally start with NFAs?
  3. Why do automatic scanner generators generally create DFAs?
  4. Can a scanner specification from regular expressions be ambiguous in the way that grammars can be? Explain why not, or give an example of an ambiguous scanner specification.