retagged by
313 views
4 votes
4 votes

Consider the following grammar:

  • $Z \rightarrow  TZ'$
  • $Z' \rightarrow  +TZ'  \mid \epsilon$
  • $T \rightarrow Y T '$
  • $T ' \rightarrow ^* YT ' \mid \epsilon$
  • $Y \rightarrow (Z) \mid id$

Which of the following represents Follow(Y)?

  1. $\{ ), id \}$
  2. $\{ ), id, \$,  *,  + \}$
  3. $\{ ^*, +,  ),  \$ \}$
  4. $\{ +, ),  \$ \}$
retagged by

2 Answers

Best answer
3 votes
3 votes

$$\begin{array}{|l|l|l|l|} \hline  & \textbf{First} & \textbf{Follow} \\ \hline Z\rightarrow TZ' &  \{(,id\} &  \{\$,)\} \\ \hline Z'\rightarrow + TZ' \mid \epsilon & \{+,\epsilon\} & \{\$,)\}  \\ \hline T\rightarrow YT'& \{(,id\} & \{+,$,)\}  \\ \hline T'\rightarrow \ast YT' \mid \epsilon & \{\ast,\epsilon\} & \{+,$,)\}  \\ \hline Y\rightarrow (Z) \mid id & \{(,id\} & \{\ast,+,\$,)\} \\ \hline \end{array}$$ So, the correct answer is $(C)$.

Reference:

edited by
Answer:

Related questions

3 votes
3 votes
1 answer
1
Bikram asked Nov 25, 2016
469 views
Consider the following grammar:$E \rightarrow E + T \mid T$$T \rightarrow T ^* F \mid F$$F \rightarrow (E) \mid id$What are the productions for E, T and F after convertin...
3 votes
3 votes
1 answer
2
Bikram asked Nov 25, 2016
344 views
The grammar which has no epsilon transition or two adjacent nonterminals in the right side of any production is ___________.LL(1) grammarUnambiguous grammarOperator gramm...
3 votes
3 votes
2 answers
3
2 votes
2 votes
2 answers
4
Bikram asked Nov 25, 2016
692 views
Consider the following grammar:$S \rightarrow L = P \mid P$$L \rightarrow ^*P \mid id$$P \rightarrow L$The above grammar is:AmbiguousSLR(1)LALR(1)None of the above