CS1621
Assignment 3
Due: November 3, 2003

You are to implement a system which does analysis of a program and provides information about the characteristics of the variables. As you debug an application, there are many things that you may want to know about such as if a variable is an actual constant (or an effective constant where it is assigned one and one time only). A variable may also only ever contain a non-computed value. You may want to know if a variable may be used before initialized or has a path through a program where it can be used before initialized. You may want to know about variables that are assigned but never used.

A C compiler front end is available in /afs/pitt.edu/usr/bigrigg/public/cs1621/proj3. It takes in a C source file, performes lexical and syntax analysis on it (no semantic analysis), puts the program into an internal syntax tree, and then outputs an equivalent C program. Additional information on the internal syntax tree is provided here. You are to create a SEPARATE PASS to determine each set of variables.

PROJECT HELP

You will be provided with test cases. You must also make your system available to the grader in order for additional test cases to be run. On the due date you are to submit a hard copy of your program along with the output of the test cases after they have been passed through your system. You will also provide a one page README file that details how to run your system.

Test cases can be found in /afs/pitt.edu/usr/bigrigg/public/cs1621/proj3. The tests are test1.c and test2.c.

Make modifications to the compiler one step at a time. Grading is based on SUCCESSFUL accomplishment as determined by the progression of steps for a group of two. Groups of three require more additional work (such as 1 provides only 55%) and individuals require less work (such as 1 provides 75%). Create a table that contains a list of all global variables and table for each function containing the local/parameter variables. Treat all arrays as one variable. Treat all structs as separate variable instances.

  • (D 65%) [1] Identify those that are L-values.
  • (C 75%) [2] Identify the constants (only ever assigned in the declaration). [3] Identify the variables that are never assigned.
  • (B 85%) [4] Identify the effective constant variables which are assigned once and once only. [5] Identify the variables that have a path through the program where they are never assigned.
  • (A 95%) [6] Identify the constant-like variables which are only ever assigned simple values and never a computed (or return) value. [7] Identify all constant-like variables which are assigned values only from other constant-like variables.
  • (A+ 100%) [8] Identify the variables whose values are passed into functions. [9] Identify the variables whose address is gotten. [10] Identify the variables that are used to compute the index of an array.

    *TR