Compiler Design and Construction - Old Questions

Question Answer Details

6.  Given the following grammar:

      

Construct the parsing table for this grammar for non-recursive predictive parser.
6 marks
Asked in 2072

Answer

AI Generated Answer

AI is thinking...

Official Answer

Given Grammar;

  

Now, Calculating First and Follow:

FIRST

First(E) = First(T) = First(F) = { (, id }

First(E) = { +, ∈ }

First(T’) = { *, ∈ }

FOLLOW

Follow(E) = { ), $}

Follow(E) = { ), $}

Follow(F) = { *, +, ), $ }

Follow(T) = { +, ) , $}

Follow(T’) = { +, ) , $}

Now, the Parsing table for given grammar is as below: