Parser V and the Symbol Table
Posted Thursday, March 20
Due at the beginning of your next lab period
Objectives
The objectives of this assignment are
- ongoing polishing of your parser with a correct LL(1) table
- modifying your parser to include generation of a file that contains the
leftmost parse of the program being compiled.
- the inclusion of a symbol table in your compiler.
To Do
- Insert code in your parser to create a text file called "parse-tree" Each time a rule is
expanded, print the rule number used to the file, as described in class. Make sure the file
can be opened and read easily by the Unix cat command, or by Notepad in Windows. In other
words, be sure to put in linefeeds at appropriate intervals.
- Save your polished parser with the rule generation of the previous bullet in a separate file.
The purpose for this is so that your parser can be tested without the new semantic information you
are about to include beginning with this milestone. For completion of this milestone
continue to work on the compiler as described next.
- Construct a symbol table ADT for your compiler.
- Modify the LL(1) grammar for mPascal so that it includes action
symbols where appropriate to cause identifiers and their attributes to be inserted into the symbol
table at declaration time.
- The action symbols you insert into the mPascal grammar
for the insertion of identifiers into the symbol table are to become calls inserted
into your parser to corresponding methods in your symbol table ADT.
- Modify the parser to include calls to the action methods to insert identifiers and
their attributes into the symbol table. If an error occurs (e.g., an identifier has
been declared multiple times), your compiler should terminate with a useful error
message about what happened and where.
To Turn In
Use the standard submit procedure to turn in your parser source and executable.