Submission Instructions: Please hand in a hard copy of your solutions to all problems, with a suitable cover page with your name, the date, the course, and the number of the assignment. Do each problem on a separate sheet clearly labelled at the top (e.g., "Problem 3"), and staple all pages together in the upper-left-hand corner (do NOT submit solutions separately or update your solutions after handing in your assignment). For any problem statement that asks multiple questions, answer each in a separate paragraph, labelled (1), (2), etc. Submit "pencil and paper" problems into the CS 525 mail slot (not the shelf) in the CS homework station; submit code or files produced by software using Gsubmit as specified on the course home page. A small penalty will be taken for any homework that does not follow these guidelines.
Late Policy: Both parts of the homework (pencil and paper, and electronic submission) are due at 5 pm the due date; late homeworks will be penalized at the rate of 25% for each weekday late (each day ending at 5pm, weekends not included).
Policy on Academic Honesty: Please see the end of this homework for comments on the University policy for academic honesty that I adhere to.
These problems all involve extending the class notes to account for various features of C that we did not implement. You do not need to repeat text from these notes verbatim, but may abbreviate your answer by referring to the notes. Just show the changes that would occur in modifying the notes to account for the feature in question.
The first two involve showing extensions of the attribute grammar scheme for code generation; the third an fourth involve essay-type questions on more complex modifications of the type checking and translation process. All of these questions are typical of what I might ask on the final exam.
There are two features of the expression language of C that we did not account
for. The first is use of the increment and decrement operators ++ and --.
The second is the use of assignments as expressions (that is, and assignment
is considered to be an expression whose value is the value assigned). Show
how to
modify the class notes on code generation to account for these two features.
(You do not need to show how type checking changes). Show the IC code that
would be generated for the following C program:
main() {
int A, B;
A = 3;
++A;
A--;
B = ( ( A = ++A ) + ( B = A-- ) );
}
In C, function definitions are allowed only in file scope, that is, a C program consists of a list of function and variable declarations, and no function can be defined inside another function or inside a struct. Some language do allow this, for example in Java you may define a function inside a class, and in Pascal you can define a function inside another function.
Explain what would be necessary to change in our translation scheme to account for both functions defined within functions, and functions defined within structs. Be sure to discussion what would change in the type-checking process (i.e., how does scoping work for these extensions) and in the code generation process. Again, confine your answer to about a page in length, and be as precise as possible. You do not need to give the attribute grammar for this.
Whenever you submit a piece of academic work and sign your name to it, you are verifying that this work is the result of your own intellectual efforts; it is Plagiarism to submit work solely under your own name in which:
In this course, I will not allow you to submit any joint work, although in other courses and in other contexts you may be permitted to do this. In general, you must always provide proper attribution of authorship by naming all persons, books, or resources that provided intellectual content towards the final result. In some cases, you will need to describe the extend of the contribution, particularly when literally copying the words or artistic artifacts of another. To fail to provide proper attribution is plagiarism. Plagiarism demeans the seriousness of what we do in class, and does not allow you as a student to obtain a fair grade for the results you worked hard for.
I will discuss the issue of plagiarism with the grader, and use, when appropriate, automated tools to check submitted programs and files for copying. I don't like to be involved in this, but it is necessary in order to provide a fair environment for your work. In cases of suspected plagiarism, I will discuss the matter with the student(s) involved and, when warrented, submit the case to the Academic Conduct Committee (of which I was chairman for three years). Unfortunately, students in my classes violate these policies several times a year on average; it is my hope that by being completely clear and straight-forward about my policy that I can reduce this number. Please take this issue serious and talk to me if you have any concerns or questions.