COS 320, Spring 2000. Programming Assignment

Programming Assignment 2: Lexical Analyzer

Further details about this assignment are described in Modern Compiler Implementation, Chapter 2, pages 31, 32.  Please read these pages.  You will also need to refer to the Tiger reference manual in Appendix A. 

Using ml-lex

  1. Make a new directory as2 for this assignment.
  2. Copy the files /u/cs320/chap2/*.sml and /u/cs320/chap2/*.cm into as2.
  3. Please, familiarize yourself with the code that is already there.
  4. Run sml and compile the code using CM.make();
  5. Directory /u/cs320/testcases contains several files with sample Tiger code. You can test the parser by running
    Parse.parse "filename".
  6. If you want to test your code with input entered from the command line, then invoke the parser as
    Parse.parse "/dev/tty". In this case you should press Ctrl-D to indicate the end of the input stream.
  7. Edit the code in tiger.lex. You will have to remove some of the sample code and add a lot of your own.
  8. Recompile, test, debug, edit. Repeat as necessary.
  9. Submit by submit 2 tiger.lex.