retagged by
241 views
3 votes
3 votes

Consider the following grammars:
$Z \rightarrow  TZ'$
$Z' \rightarrow ^* TZ' \mid \epsilon$
$T \rightarrow  YT'$
$T ' \rightarrow ^*YT '  \mid \epsilon$
$Y \rightarrow (Z) \mid id$

 

Which of the following is First(Z)?

  1. $\{T, ) \}$
  2. $\{(, id \}$
  3. $\{ ), \$ \}$
  4. None of the above
retagged by

2 Answers

Best answer
1 votes
1 votes

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

Reference:

selected by
Answer:

Related questions

3 votes
3 votes
1 answer
1
Bikram asked Nov 25, 2016
478 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
3
Bikram asked Nov 25, 2016
360 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...
2 votes
2 votes
2 answers
4
Bikram asked Nov 25, 2016
695 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