retagged by
689 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.
retagged by

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

553
views
1 answers
2 votes
GO Classes asked Jan 21
553 views
Consider the following grammar:$\begin{aligned}& S \rightarrow a S^{\prime} \\& S^{\prime} \rightarrow b S^{\prime} \mid \epsilon\end{aligned}$Which of the following is/are ... $bS'$a S^{\prime} b$bbS$
450
views
1 answers
4 votes
GO Classes asked Jan 21
450 views
Consider the following context-free grammar, with start symbol $S$ and terminals $a, ; , \lt , \gt .$ ... many different parse trees are there for the string $\lt \lt a \gt ;a\gt ?$
534
views
1 answers
5 votes
GO Classes asked Jan 21
534 views
$\begin{aligned}& S \rightarrow S1 \;T \\& S 1 \rightarrow a \mid(S S) \\& T \rightarrow \varepsilon \mid b \;T\end{aligned}$In the $\text{LL(1)}$ ... \{T \rightarrow \varepsilon\}$\{S 1 \rightarrow a\}$ and $\{T \rightarrow \varepsilon\}$