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
Make a new directory as3 for this assignment.
Copy the files /u/cos320/chap3/*.sml and
/u/cos320/chap3/*.cm into as3.
Please, familiarize yourself with the code that is already there.
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.
Edit your tiger.lex to make sure it contains the
following code:
In the first section:
type svalue = Tokens.svalue
type pos = int
type ('a,'b) token = ('a,'b) Tokens.token
type lexresult = (svalue, pos) token
Make sure you delete the old definiton of type lexresult.
Edit tiger.grm until it specifies a parser for the Tiger
language (See Appendix A of Modern Compiler Implelmentation in ML).
Compile using CM.make(); This will automatically
run ml-lex and ml-yacc as necessary.
Test your parser by invoking
Parse.parse "filename".
Debug, edit, recompile, test. Repeat.
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.)
Submit your solution with submit 3 README tiger.grm.