Compiler Design and Construction - Old Questions

4.  Consider the following grammar:

            

a.       Eliminate Left recursion.

b.      Compute FIRST & FOLLOW for the symbol in the grammar.

6 marks | Asked in 2068

Given grammar,

a) Removing left recursion of the given grammar;

    → (L) | a

    → SL'

    L' → ,SL' | 

b) Now, the FIRST and FOLLOW for the given symbols are:

Non-terminals

FIRST()

FOLLOW()

S

{(, a}

{$, , , )}

L

{(, a}

{)}

L’

{, , }

{)}