198:515 Programming Languages and Compilers I
Problem Set 8
Sample Solution.
Problem 1 - Dependence Analysis
Give the direction vectors, and if possible the distance vectors for all dependences in the
following loop nests. State explicitly whether a depen
CS 314 Principles of Programming Languages
Due date: Thursday, April 1, beginning of lecture
Problem 1
Recall the type checker based on an attribute grammar that we discussed in lectures 13 / 14.
For an additional reference, see Sethi Ch. 13.2 and/or ASU
198:515 Programming Languages and Compilers I
Problem Set 6
Sample Solution
Problem 1 - let and let* in TINY
1. How can the let and let* constructs be expressed in the TINY language? In other
words, can you rewrite a let and let* with TINY language constr
198:515 Programming Languages and Compilers I
Problem Set 7
Sample Solution
Problem 1 - Unication in Prolog
Unify (if possible) the following Prolog lists and report any variable bindings imposed.
a) [a,b,c] = [X|Y].
X = a, Y = [b,c]
b) test(a,b,c) = test
198:515 Programming Languages and Compilers I
Problem Set 5
SAMPLE SOLUTION
Problem 1 - normal form
Using CR-I as discussed in class (see lecture 6, page 6), prove that if a normal form exists
for -term M, is has to be unique.
Proof by contradiction:
Assu
CS 515 Homework 2 Sample Solution
1.1)
I1
g goal ,$
I0
g goal ,$
goal expr ,$
expr term AND expr ,$
expr term ,$
Term factor OR term ,$/AND
Term factor ,$/AND
factor TRUE ,OR/AND/$
factor FALSE ,OR/AND/$
goal
expr
I2
goal expr ,$
I3
expr term AND expr ,$
198:515 Programming Languages and Compilers I
Problem Set 4
SAMPLE SOLUTION
Problem 1 - -term abbreviations
Give the fully expanded -terms for the following -term abbreviations as discussed in class
(lecture 5, page 15).
1. (f g x v) w
(f g) x) v) w)
2. x
CS 515 Programming Languages and Compilers I
Problem Set 2
Sample Solution
Problem 1 Predictive Parsing
Assume the following CFG for predicate logic prex expressions.
1:
2:
3:
4:
5:
6:
7:
8:
Start := Expr
Expr := or Expr Expr
Expr := and Expr Expr
Expr :=