Compiler Design and Construction - Old Questions

Question Answer Details

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

Answer

AI Generated Answer

AI is thinking...

Official Answer

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