loading...

CS606 Compiler Construction Assignment 2 Solution Fall 2012

Assignment No. 02
Semester Fall 2012
Compiler Construction CS606
Total Marks: 20
Due Date: 04-12-2012

Question No 1: Marks 10
Considering the following grammar, find the first sets for each non-terminal of the grammar.
S →aS | Ab
A →XYZ | ε
X →cX | ε
Y →dS | ε
Z →eS | ε

Solution:

 
Question No 2: Marks 10
Prove that the following grammar is ambiguous because the sentence if ( id == id) then if ( id == id)
then id := id ; else id := id ;can be derived using two different parse trees.
S →id := id ;
S →if (E) then S
S →if (E) then S else S
E →id == id ;

Solution:

question # 2  is from LECTURE 12

DOWNLOAD SOLUTION HERE
loading...