CSE-504 Programming Project #2
Parser Module
Read the following description carefully before starting on the assignment.
Also, go through the brief overview of the project
path that describes the steps involved. A list of what
materials are available and what
you are expected to submit are also given. Finally, make sure you understand
and follow the submission
requirements.
Description:
The syntax of Decaf
programs is described in the Decaf
Language Reference Manual. Based on this information, you will construct a
parser in this project using JavaCC, the same parser-generator tool you used for
lexical analysis. Before using JavaCC however, you will have to remove left
recursion as discussed in the class.
The parser has to be appended to the token definitions you wrote for
the programming assignment #1. The way you write the grammar is described in the
JavaCC documentation. See also
the examples provided in /usr/local/javacc2.1/examples on the ug.cs.sunysb.edu
machine. The tokens you already defined can be used in the parsing grammar.
Project Path
You will be
writing the specifications for the parser in the same file you used for the
lexer (decaf.jj). You may use the same Makefile to get DecafParser.class.
To avoid ambiguity, the javacc compiler might propose you to use #k position
look ahead (your grammar is LL(k)). Update the specific decaf.jj parsing rules
with the proposed look ahead.
Available Material
- The driver (java code inside BEGIN{DecafParser} ... END{DecafParser})
should replace the while loop with a call to the start symbol
method.
- Please make sure you test your programs on compserv1 (e.g., compserv1.cs.sunysb.edu).
- Samples of javacc parsers are in /usr/local/javacc2.1/examples.
- Sample input files in* are in ~cse504/pub/parse/tests.
The outputs for these files is described in outputs, also located in
the same directory.
Deliverables
The
parser handin must contain:
- the source code for syntax analyzer (decaf.jj)
- the Makefile you used for the lexer. The Makefile must create an
executable called DecafParser.
- Any other files that are necessary to successfully recompile your program.
Please read carefully the submission requirements below.
Submission
Requirements
Please note the following submission requirements.
These are not simply conventions, but are requirements. They make grading
of the projects easier, and lets us spend more time wading through the code to
award partial credit! They are not difficult to follow, so failure to do so will
result in severe penalties (project may not be graded!). If you have trouble
with the set-up, send me an email
Radu Grosu