In this phase you will build and test your scanner and parser for the T programming language.
Implement your scanner in a way that you can both run the scanner as a stand-alone program and as part of your compiler. The stand-alone version of the scanner should dump tokens, one per line to stdout, in a human-readable format. The dump should include both the token name and its semantic value. Develop inputs to thoroughly test your scanner using the stand-alone version of the scanner.
Design an Abstract Syntax Tree (AST) data structure to be used by your compiler. Try to think ahead and anticipate the needs of both the semantic analysis and the code generation phases of the compiler. Be sure to capture source line numbers in the AST nodes so that good error messages can be generated during semantic analysis. Use an object-oriented approach so that you can easily modify your design later if needed.
Implement your AST design. Provide methods for constructing ASTs and a method for dumping an AST to stdout in human-readable form. The display method should dump the AST in prefix form, one AST node per line.
Implement a parser for the T programming language. The parser should use the scanner you are developing for this phase. The parser should use your AST implementation to build ASTs for the input source program. The parser should display the ASTs for debugging purposes. You do not need to do syntactic error recover. Your parser can stop on the first syntax error. Construct test source programs to thoroughly test your parser. Your tests can be restricted to syntactically correct programs.
Develop a Makefile for building and testing your scanner and parser, called "Makefile". The default Make target (topmost in the Makefile) should build your parser. You should have a Make target for the stand-alone scanner, called "lexdbg". And, have a Make target for cleaning up ALL files generated by any of the other Make targets, called "clean".
You can develop your scanner and parser on any system that you have access to, but for grading purposes I will execute it on turing.unh.edu, so be sure to test in that environment.
The deliverables for this phase include the source code for your scanner, parser and AST implementation, the Makefile and any other support files needed to build your scanner and parser. Also include a README file with your submission that describes the purpose of each file submitted.
Archive all your files in a tar file called "phase2.tar".
You should submit your tar archive from turing.unh.edu using my "submit"
script.
To turn in this assignment, type:
~cs712/bin/submit phase2 phase2.tar
Submissions can be checked by typing (also on turing.unh.edu):
~cs712/bin/scheck phase2
Points will be assigned in the following manner for this assignment:
To receive full credit for the assignment, you must turn in your files prior to 8am on Monday February 28. Late submissions will be accepted at a penalty of 2 points for one day late, 5 points for two days late, 10 points for three days late, 20 points for four days late, and 40 points for five days late. No program may be turned in more than 5 days late.
Remember: you are expected to do your own work on this assignment!
Comments and questions should be directed to hatcher@unh.edu