retagged by
368 views
0 votes
0 votes

The following grammar $\text{G}$ is left recursive.

  • $\text{E} \rightarrow \text{E + T}\; \mid \; \text{T} $
  • $\text{T} \rightarrow \text{T * F} \; \mid \; \text{F} $
  • $\text{F} \rightarrow \text{(E)} \mid \textbf{id} $

Which of the following is a correct left-recursive variant of $\text{G}$?

  1. $\text{E} \rightarrow \text{E}’\text{T} \\ \text{E}' \rightarrow \text{+TE}’ \mid  \epsilon \\ \text{T} \rightarrow \text{T}’\text{F} \\ \text{T}' \rightarrow \text{*FT}’ \mid \epsilon \\ \text{F} \rightarrow \text{(E)} \mid \textbf{id} $

 

  1. $\\ \text{E} \rightarrow \text{TE}' \\ \text{E}' \rightarrow \text{+TE}’ \mid  \epsilon  \\ \text{T} \rightarrow \text{FT}' \\ \text{T}' \rightarrow \text{FT}’* \mid \epsilon \\ \text{F} \rightarrow \text{(E)} \mid \textbf{id} $

 

  1. $\text{E} \rightarrow \text{TE}' \\ \text{E}' \rightarrow \epsilon \mid \text{TE}' \\ \text{T} \rightarrow \text{FT}' \\ \text{T}' \rightarrow \text{*FT}’ \mid \epsilon \\ \text{F} \rightarrow \text{(E)} \mid \textbf{id} $

 

  1. $\text{E} \rightarrow \text{TE}' \\ \text{E}' \rightarrow \text{T + E}' \\ \text{T} \rightarrow \text{FT}' \\ \text{T}' \rightarrow \text{F* + T}' \\ \text{F} \rightarrow \text{(E)} \mid \textbf{id} $
retagged by

1 Answer

Answer:

Related questions

1 votes
1 votes
0 answers
2
admin asked Jan 5, 2019
266 views
Match all items in Group $1$ with correct options from those given in Group $2.$$$\begin{array} {|l|l|} \hline \qquad \qquad \textbf{Group 1} & \qquad \textbf{Group 2} \\...
1 votes
1 votes
0 answers
3
admin asked Jan 5, 2019
275 views
Which phase during compilation does a compiler recognize the $\textbf{keywords}$ of a language?Code generationParsingDataflow analysisLexical analysis
1 votes
1 votes
0 answers
4
admin asked Jan 5, 2019
254 views
Which of the following data structures is used by a compiler to manage information about variables and their attributes?abstract syntax treesymbol tablesemantic stackpars...