Compiler Design and Construction - Old Questions

4.  Consider the grammar:

        

    a. Show that this grammar is ambiguous by constructing two different leftmost derivations for sentence abab.

    b. Construct the corresponding rightmost derivations for abab.

    c. Construct the corresponding parse trees for abab.

6 marks | Asked in 2070

Given grammar;

 

a) Leftmost derivation:

Since the above grammar produces two different left-most derivation for the sentence abab, the given grammar is ambiguous.

b) Rightmost derivation:

c) The corresponding parse tree for abab is