The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+17 votes

Consider the grammar shown below

S $\rightarrow$ i E t S S’ | a

S’ $\rightarrow$ e S | $\varepsilon$

E $\rightarrow$ b

In the predictive parse table, M, of this grammar, the entries M[S’ , e] and M[S’ , $] respectively are

  1. {S’ $\rightarrow$ e S} and {S’ $\rightarrow \varepsilon$}
  2. {S’ $\rightarrow$ e S} and { }
  3. {S’ $\rightarrow \varepsilon$} and {S’ $ \rightarrow \varepsilon$}
  4. {S’ $\rightarrow $ e S, S’ $\rightarrow \varepsilon$} and {S’ $ \rightarrow \varepsilon$}
asked in Compiler Design by Veteran (69k points) | 1.5k views

2 Answers

+31 votes
Best answer

First (S)={i,a}

First(S')={e, episolon)



Only when first contains episolon we need to consider follow

M[S',e]={S' $\rightarrow$ eS(first),S' $\rightarrow$ episolon(considering follow)}

M[S',\$}={S $\rightarrow$ episolon}

S S $\rightarrow$ a S $\rightarrow$ ietSS'        

S' $\rightarrow$ eS

S' $\rightarrow$ episolon

  S' $\rightarrow$ episolon
E     E $\rightarrow$ b      

answer is D

answered by Veteran (34.3k points)
edited by

from table

M[S’ , e] =S'->eS , S'->episolon

M[S’ , $]=S'->episolon

So ans will be D

Can you please explain how follow(S') =  (e, \$).


FOLLOW(S)={FIRST(S') , $} 


So, FOLLOW(S') ={e,$}

–1 vote
Solution: A

Since predictive parse table is constructed by filling the entry $T[A,\alpha]$ with productions of the form $A-> B$ , where $First(B)$ contains $\alpha$ and productions of the form $A-> \epsilon$ are filled in $T[A,\beta]$ ,where $\beta \in Follow(A)$
answered by Active (1.4k points)
Predective parse table means LL1 Parser. Ans is D

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

33,704 questions
40,252 answers
38,859 users