CS 370
Homework Assignment 5: Semantic Analysis

Due: Tuesday April 18, start of class

Write a semantic analyzer, in C or C++, for the ANSI C language. This consists of symbol tables and type checking information for all variables and functions. In this phase you should handle ALL of the language, but report a large number of features as "unimplemented", since they are not part of the 370-C language you will generate code for. For features that are unimplemented your program should print a file name, line number, and what unimplemented feature is being used, and then halt.

Your semantic analyzer must meet the following requirements:

Symbol Tables

You should first build symbol tables, a global one, and a separate one for each function. Test your symbol tables by reporting any use of an undeclared variable as an error.

Type checking

Extend your symbol tables to check the types of variables. Disallow attempts to mix types illegally. For example, it is legal to add a char to an int, it is illegal to assign an int to an array variable.

Unimplemented

You can refuse any program that makes use of any of the following features. This list is subject to additions; check back from time to time. List of Things Not To Implement