Project 2 is to build a parser for Appel's Tiger language using ML-Yacc. The Tiger language is defined in Appendix A of the course textbook. Documentation on ML-Yacc is available on the class web page, and also (in less detail) in chapters three and four of the textbook.
Your parser should produce an abstract syntax tree using the
datatypes defined in the
Absyn structure defined
in the file
Skeleton files to get you started are available in the
which you can find at Appel's textbook homepage.
In particular, these files will be useful:
tiger.grm— Skeleton ML-Yacc file to get you started
parsetest.sml— Test driver
parse.sml— Top-level test driver code
absyn.sml— AST datatypes
symbol.sml— Support library providing symbols
table.sig— Support library providing tables
prabsyn.sml— Useful library for printing ASTs
Remember to update your
Be certain to add
ml-yacc-lib.cm to it,
in addition to any other new files you are using.
You'll want to remove
tokens.sml from it,
because a tokens file will be automatically generated by ml-yacc now.
Also, you'll need to update some header information in your lex file—see
the end of chapter 3 for details.
You should submit:
tiger.grmfile, the ML-Yacc source for your parser.
Anything subtle about your grammar, such as ambiguity resolutions of various kinds, should be clearly commented. You knew that, of course.
Your parser should use the same error-reporting machinery you employ in your lexer.
Words to the wise:
$TIGER/testcases, then add semantic actions to the grammar to construct the AST while parsing tiger source code.
tiger.grm.descfile by ML-Yacc, you are going to be in a world of pain.
See the course text for more information, in particular chapters three and four and appendix A.
Good luck; have fun.–Olin