Compilers (CS362 2002F)

Project, Phase 2: Parser

Assigned: Monday, October 7, 2002
Due: Friday, November 1, 2002

Summary: In this stage of the project, you will design and build the parser for your Pascal compilers. The output from your parser should be a parse tree in which the internal nodes are all objects (members of classes).

Warning: You may be required to use each others' lexers at the next stage of the project.

Group Work: You should work in groups of size four or five. You will be assigned to groups.

Code Reuse You may use any of the lexers created for this class (or you may create a new one).

Building a Parser

1. Begin by deciding on the natural grammar for Pascal. You should do this in the next day or so. You can certainly rely on the grammar that appears in the Pascal User Manual and Report.

2. Design Java interfaces and classes for the various nonterminals. I'd suggest that you have a different interface for each nonterminal and subclass it for each of the different productions, but there are certainly many other alternatives (including a generic Nonterminal).

3. Implement the parser. It should read input (probably passed as a parameter) and return a parse tree with Program at the root. You may iomplement the parser using either (1) the procedure-based recursive-descent technique; (2) the stack-based recursive-descent technique; or (3) the SLR shift-reduce technique.

No matter what technique you choose, you should make sure that you can eventually add attributes to the nonterminal. Attributes are values associated with nonterminals, such as parse trees or compiled code.

 

History

Friday, 2 March 2001 [Samuel A. Rebelsky]

Monday, 7 October 2002 [Samuel A. Rebelsky]

Tuesday, 8 October 2002 [Samuel A. Rebelsky]

 

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Wed Nov 20 08:44:15 2002.
The source to the document was last modified on Tue Oct 8 07:39:18 2002.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS362/2002F/project.02.html.

You may wish to validate this document's HTML ; Valid CSS! ; Check with Bobby

Glimmer Labs: The Grinnell Laboratory for Interactive Multimedia Experimentation & Research
glimmer@grinnell.edu