Assignment 2. Lexical analysis

This assignment contains the following two parts:
  • Programming exercise described in Appel's Modern Compiler Implementation in ML, Chapter 2, on page 31 - 32. The files mentioned there are in the /c/cs421/as/as2 directory on all zoo machines. You need to submit the following two files: README for the documentation and tiger.lex for the lexer. The ML-Lex manual can be found here. Some sample tiger programs can be found in the /c/cs421/as/testcases directory on the zoo machines.
  • Exercise 2.8 on page 36 of Appel. Please submit a file named dist.txt using the same submit command as before.
  • In addition, you can also work on the Extra Credits. The extra credits will be added to your final grade, so they serve as some kind of insurance. Warning: do not even think about working on extra credits unless you are 100% done with your Tiger lexer.
    Extra credit:
  • While we are on the topic of writing the lexers, check out the "Lexical Structure" of other more popular languages such as Java. Read the Java Lexical Structure definition; and explain what changes you need to make in order to let your Tiger lexer work for Java. In particular, how would you deal with the unicode ? Please submit a file named extra for your extra credit work.