Homework7 - print x main set x(0 first print x second print...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
COP 5555 Programming Language Principles Homework 7 Assigned: July 13, 2011 Deadline: 11:59pm July. 20, 2011 NOTE: This homework is worth 200 points (so it’s worth 2% of your whole grade) *Note: Please submit your solution to the e-learning system by the deadline. No late submission is allowed. 1. Problem 1 (20 Points) Languages that employ a reference model of variables also tend to employ automatic garbage collection. Is this more than a coincidence? Explain. 2. Problem 2 (20 Points) Most binary arithmetic operators are left-associative in most programming languages. However, most compilers are free to evaluate the operands of a binary operator in either order. Are these statements contradictory? Why or why not? 3. Problem 3 (30 Points) Consider the following pseudocode: x : integer – global procedure set x(n : integer) x := n procedure print x write integer(x) procedure first set x(1) print x
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
procedure second x : integer set x(2)
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: print x main() set x(0) first() print x second() print x end What does this program print if the language uses static scoping? What does it print with dynamic scoping? Why? 4. Problem 4 (20 Points) Why don't we use PP[<program C>] = CC[C] o (lambda(m,i,o).o) instead of the definition of PP[<program C>] on PPT 26, slide 23 ? Explain. 5. Problem 5 (40 Points) Modify the attribute grammar for Tiny, so that "read" is no longer an intrinsic function, but instead a statement. Instead of assign i := read; we would have read(i); The read statement would handle exactly ONE identifier. 6. Problem 6 (40 Points) Add a 'swap' statement to Tiny. It would look like this: swap i :=: j; Assume a parser ensures i and j are names, not expressions. Also, assume they are type compatible. 7. Problem 7 (30 Points) Build the functional graph for the binary number 101.11, according to the attribute grammar for binary numbers developed in class....
View Full Document

{[ snackBarMessage ]}

Page1 / 3

Homework7 - print x main set x(0 first print x second print...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online