COS 320, Spring 1999. Programming Assignment

Programming Assignment 3: Syntactic Analysis (Parsing)

Further details about this assignment are described in Modern Compiler Implementation, Chapter 3, pages 81, 82.  You will also need to refer to the Tiger reference manual in Appendix A.

Using ml-yacc

  1. Make a new directory as3 for this assignment.
  2. Copy the files /u/cos320/chap3/*.sml and /u/cos320/chap3/*.cm into as3.
  3. Please, familiarize yourself with the code that is already there.
  4. Copy your working tiger.lex from assignment 2 into as3. If your lexer is not working, then do NOT copy it into as3 and skip the next step. In this case, CM.make(); will automatically use the file tiger.lex.sml that is provided.
  5. Edit your tiger.lex to make sure it contains the following code: Make sure you delete the old definiton of type lexresult.
  6. Edit tiger.grm until it specifies a parser for the Tiger language (See Appendix A of Modern Compiler Implelmentation in ML).
  7. Compile using CM.make(); This will automatically run ml-lex and ml-yacc as necessary.
  8. Test your parser by invoking Parse.parse "filename". Debug, edit, recompile, test. Repeat.
  9. Write a README file with a detailed description of any shift/reduce conflict that your parser might have. Explain why it is not harmful. You must eliminate all reduce/reduce conflicts, though. (By the way, my parser has no conflicts. However, shift/reduce conflicts are ok as long as they correspond to phenomena, such as "dangling else", that are well understood.)
  10. Submit your solution with submit 3 README tiger.grm.