in Compiler Design retagged by
533 views
5 votes
5 votes

Consider the following grammar-
$$
\begin{aligned}
& S \rightarrow b T \\
& T \rightarrow A b \mid B a \\
& A \rightarrow a S \mid C B \\
& B \rightarrow b D \\
& C \rightarrow c D \\
& D \rightarrow \varepsilon \mid c D
\end{aligned}
$$
Which of the following is/are true about first and follow sets of non-terminals?

  1. $\text{Follow(B)}$ and $\text{Follow(D)}$ are same.
  2. $\text{Follow(A)}$ and $\text{Follow(C)}$ are same.
  3. $\text{Follow(S)}$ and $\text{Follow(T)}$ are same.
  4. $\operatorname{First}(\mathrm{A})$ and $\operatorname{First}(\mathrm{T})$ are same.
in Compiler Design retagged by
533 views

3 Comments

can anyone help in option A….I am getting follow(B) ={a,b} and follow(D) ={b}
0
0

@yash panjwani
Follow(B) = {a, b} this one is correct
Follow(D) =  Fo(B) {since  B → bD} union Fo(C) {since C → cD}
                 = {a, b}

Follow(C) = {Fi(b)} = {b}

3
3
got my mistake thanks bro..👍
0
0

1 Answer

3 votes
3 votes

Option A). True.

Follow (B) = {a, Follow(A)} ={a,b}

Follow(D) ={Follow(C), Follow(B), Follow(D)} 

Follow(C) = {First(B)} = {b}

Follow(B) = {a,b}

Follow(D) ={a,b} = Follow(B)

Option(B) True.

Follow(A) ={b}

Follow(C) ={First(B)} ={b}

Option C). True

Follow(S) = {Follow(A)} ={b}

Follow(T) = Follow(S) ={b}

Option D).False

First (A) = {a, First(C)} ={a,c}

First(T) ={First(A), First(B)} ={a,b,c}

Answer:

Related questions