• edited by
481 views
1 1 vote

Consider the following grammar: 

Prog → {S}  

S→ Prog X; | Y = z;  

X →ϵ |S Prog  

Y → SZ  

Z→id  

Determine follow(S) from the above grammar. 

(A) { } , id}  

(B) { }, ϵ , id} 

(C) { },{ id}  

(D ) { },{ id,ϵ }

1 Answer

5 5 votes

 To find Follow(S), mark where is 'S' in given Productions : 

Prog → {S}  

S→ Prog X; | Y = Z;  

X →ϵ |S Prog  

Y → SZ  

Z→id 

 

Follow(S) = '}' $\cup$ First(Prog) $\cup$ First(Z) 

= '}' $\cup$ '{' $\cup$ 'id'


 

Follow(S) = { }, {, id }

Option C is Correct Answer.

Position:
Show:

Related questions

21 21 votes
4 4 answers
6.8k
6.8k views
Arjun asked Feb 27, 2025
6,812 views
Which of the following statement(s) is/are TRUE while computing $\operatorname{First}$ and $\operatorname{Follow}$ during top down parsing by a compiler?For a production ...
1 1 vote
1 answers 1 answer
1.2k
1.2k views
Prasanna 4 asked Feb 2, 2025
1,221 views
14. Compute FIRST and FOLLOW for the following grammar S->AS, S->b, A->SA, A- a