CSCI 435: Compiler Construction
Assignment 10

Overview

Create a symbol table class and use it to process declaration and "use" nodes in the AST. The declaration nodes are derived from DeclarationNode, and include ParameterNode-s. There are three "use" nodes, which I will leave for you to determine.

An outline of a symbol table class is given in SymbolTable.h. Use this class as a starting point. Implement your symbol table class (use the same name, though) and test your methods carefully before proceeding.

Create a "SymbolTableVisitor" class that walks the AST and pairs uses with declarations. Modify the appropriate AST node definitions for this purpose. Only minor modifications should be necessary. Also, set the nest level for each declaration node. It will be used later for code generation.

Output errors for undeclared variables and multiply-declared variables, including location information.

Input Specification

Take the name of a C- program as a command-line argument. If no argument is specified read from standard input. Use ".cm" as the extension for C- source files.

Output Specification

Output errors as in the previous assignment. If a program is valid, create a symbol table visitor to pair use nodes with declaration nodes. Report any undeclared or multiply-declared variables, along with location information. If there are no errors, print the AST as before, but now annotated with type information. See InsertionSortTypes.cm for an annotated tree corresponding to the insertion sort example from the last assignment.

For valid programs use the EXACT format below.

Valid!
Writing AST to "InsertionSort.ast"

Logistics

You may work with a partner. Only ONE team member should submit. Ensure each team member's name is listed in all submitted files.

Submission

Submit your driver file "CMinus.cc", "Lexer.cc", "Parser.cc", "CMinusAst.cc", "SymbolTable.cc", other necessary source files, header file(s), and Makefile. ENSURE your Makefile is named "Makefile" and that it properly builds your program, and that "make clean" removes the executable and all generated files.

ALSO, submit a text file "Team.txt" listing your team members, their contributions, what functionality works, what doesn't, and the areas with which you struggled.

Hints

Ensure you insert the I/O functions "input" and "output" into the symbol table.


Gary M. Zoppetti, Ph.D.