A Name Analyzer for C--

Purpose

To solve the name analysis problem for c--:

Due dates

You must complete the PEP tasks (individually), and then hand in the requested material (as a group) at the beginning of class on Monday, October 5. This assignment is worth 40 points.

Background

The last homework assignment familiarized you with the consistent renaming subtask of name analysis. Detecting and reporting errors in consistent renaming involves checking bindings, and thus follows the consistent renaming task itself. Although it is often possible to combine the two in simple cases, there is really nothing to be gained by such a combination.

Section A.1.2.3 of Waite places two constraints on declarations and uses of identifiers in C--:

Once consistent renaming has been completed, detecting a violation of these constraints is trivial:

Other languages may have more complex rules, but they are all straightforward to state in terms of a set of existing bindings.

To verify the results of name analysis, you need to demonstrate that the proper entity has been associated with each identifier and that error reports are issued when constraints have been violated.

It is relatively easy to demonstrate that error reports are being issued correctly: Simply apply the name analysis to programs that violate the constraints imposed by the language definition and observe the resulting error reports. In many cases, this process is also used to attempt to verify correct association. After all, if no error report is issued then the association must have been correct.

Using a lack of error reports to verify correct association is a very tricky business, however, because it relies on indirect evidence. For example, the fact that there is no error report for an applied occurrence of an identifier means that that identifier can be associated with some definition but there is no guarantee that the associated definition is the one required by the visibility rules of the language!

An attribution module that prints all identifier bindings is available in the Eli Library. Even if you are not using Eli, the documentation for that module may give you some ideas about how bindings could be verified.

Task

Implement a name analyzer for C--, using any tools and techniques you wish. Combine your name analyzer with the structural analyzer that you implemented for an earlier assignment. The resulting program must read input text, construct the corresponding source program tree, perform name analysis and report violations of the visibility rules if the text is lexically and syntactically correct. If the input text is incorrect according to the lexical or syntactic rules of C--, your program must report at least the first error. It may terminate immediately after reporting the first error, or it may continue in an attempt to detect further errors.

Test your structural analyzer by applying it to the C-- test suite. If you feel that the test suite is inadequate, provide any additional tests you deem necessary. Note that since you are not doing type analysis, deviance tests that contain only type errors will not generate error reports.

Hand in your verification of the bindings in the factorial program. A directory containing the complete source code (or specifications, if you used tools) for your program must be permitted for world read by 1700 on the due date for this assignment. You need not make it available to be read by others before that time. Hand in the location of this directory (machine and path name).

Complete your personal postmortem for this assignment and your personal project plan for the next assignment, and submit them via the web before class on the due date of this assignment.


Instructor
Revision 1.9 (1998/09/20 20:39:15)