COSC 170 Compiler Construction
Spring 2007
Project #3
Parser
Implement a Parser for our dialect of the MiniJava programming
language, as detailed below.
Project may be completed in teams of two.
Due date: 2007 Feb 23 (Fri) 2:00PM CST.
Submit: E-mail compressed archive of Java source to professor,
with a subject header "COSC 170 P3".
Read Chapters 3 and 4 of Appel.
Use JavaCC to implement
the scanner and parser rules for our dialect of MiniJava.
Run the reference implementation of the scanner on Morbius with
the command: ~brylow/cosc170/Projects/parser program.java
Create your parser in a package called "Parse" with a
main program in class "Main". My grading protocol will
assume that your project can be compiled and run with the following
command line: cd Project3; make; java Parse.Main
inputfile.java.
Build a decent set of MiniJava testcases. Several exist in the
book, and on the web. Having a good set of test inputs will be
critical to your success in later phases of the project. The majority
of project points will be assigned by running diff to compare
your output against mine.
Debug until done.
The Scanner should take a MiniJava program file name on the command
line and write the abstract syntax tree to stdout.
Our language will consist of:
Identifiers as defined in appendix A.1
Decimal Integer Literals as defined in A.1
The MiniJava Grammar as specified here,
which is a subtly enhanced version of the book's MiniJava grammar.
The grammar will need to be modified to eliminate left recursion,
enforce proper Java operator
precedence and associativity, and to eliminate parsing conflicts.
The grammar as given also accepts various non-sensical constructs,
like having a Boolean expression on the left hand side of an
assignment statement, which you may eliminate in your parser.
You must build and output an Abstract Syntax Tree. The JavaDoc description
of the AST classes is here.
Other useful links:
Java Language Specification
Textbook
Website
E-mail compressed archive of Java source to professor,
with a subject header "COSC 170 P3". My grading protocol will
assume that your project can be compiled and run with the following
command line: cd Project3; make; java Parse.Main
inputfile.java. Please do not send .class files or other detritus.
A listing of project ERRATA.
Back
[Rev 1.4 2007 Feb 05 23:03 DWB]