

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


CS 3304 Midterm Exam
Name:
ID:
S → aSbS S → bSaS S →
where S is a non-terminal, a, b are terminals, and is the empty symbol. Show that this grammar is ambiguous.
function try(a,b) = if a=0 return 1 else return b;
Assume we employ try in the expression
try(0,1/0)
Is it advisable that mystery use normal-order evaluation or applicative-order evaluation?
program main; var x : integer; procedure p1; var x: real; procedure p2; begin ... end;
begin ... end;
procedure p3; begin ... x ... (* line 1 *) end;
begin .... end.
If this language uses static scoping, what is the type of the variable x referred to in line 1? What if the language used dynamic scoping?
type range = -5..5; table1 = array [range] of char; table2 = table1; var x, y: array [-5..5] of char; z: table1; w: table2; i: range; j: -5..5;
State which variables are type equivalent under (a) structural equivalence, (b) name equiva- lence, and (c) declaration equivalence.