Structure of Compilers - Project 2
Recursive-Descent Predictive-Parser
Due Thursday, March 23, 2006

Code a recursive-descent predictive-parser using the symbol table package and lexical analyzer from Project 1.

Grammar: The parser must parse the language described by this grammar. Since the parser is recursive-descent, the grammar must be modified to eliminate all left-recursion. Since it is a predictive-parser, the grammar must also be left-factored. Show your modified grammar in a large comment in your source code.

Type-expressions: Type-checking is necessary to know when to convert between reals and integers, to know when a no-argument function is being called, and to check for type-errors in the Pascal source file. You can adopt your own format for type-expressions or use this format. Every ID, NUM, and BCONST token is assigned a type-expression which is held in the type-expression field of its entry in the symbol table. Project 1 can set the type-expressions for NUM and BCONST tokens - project 2 sets the type-expressions for ID tokens when they are declared.

Quadruples: Project 2 generates intermediate code as a file of quadruples. Click here for the list of quadruples.

Generated Labels and Variables: Project 2 will have to generate some quadruple labels and some temporary variables. Use $2000, $2001, $2002, ..., $9999 as the names of these labels and variables. Every temporary variable should be entered into the symbol table when it is generated so it can be assigned the correct type expression. Labels don't have to be entered into the symbol table.

Testing: You can de-bug your project using test2pas as a source file: the output file should look like test2code. To help you de-bug the project test2sym is a listing of the symbol table.

Submitting the Project: Follow these guidelines when submitting your project.

Hints: Follow these hints to start the project.


Kenneth E. Batcher - 1/3/2006