edited by
807 views
2 votes
2 votes

Consider the following grammar $\text{G:}$

  • $\text{P} \rightarrow \text{Q + R} \mid \text{Q – R} \mid \text{Q} \mid \text{R}$
  • $\text{Q} \rightarrow q \mid r$
  • $\text{R} \rightarrow r \mid s$

where $\text{P, Q,}$ and $\text{R}$ are non-terminal symbols, and $q,r,$ and $s$ are terminal symbols. Which of the following statement(s) is/are correct?

$\text{S1.  LL(1)}$ can parse all strings that are generated using grammar $\text{G}$

$\text{S2.  LR(1)}$ can parse all strings that are generated using grammar $\text{G}$

  1. Neither $\text{S1}$ nor $\text{S2}$ 
  2. Only $\text{S1}$ 
  3. Only $\text{S2}$ 
  4. Both $\text{S1}$ and $\text{S2}$
edited by

2 Answers

0 votes
0 votes
The Grammar is Ambigous.

P->Q->q

P->R->q

So none must be the answer.
0 votes
0 votes
this grammer is ambigous because its have more than one parse tree for r so that its not both

ans is (a) should be correcct.
Answer:

Related questions

1 votes
1 votes
2 answers
1
0 votes
0 votes
1 answer
2
admin asked Jan 5, 2019
365 views
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...
1 votes
1 votes
0 answers
3
admin asked Jan 5, 2019
265 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
4
admin asked Jan 5, 2019
274 views
Which phase during compilation does a compiler recognize the $\textbf{keywords}$ of a language?Code generationParsingDataflow analysisLexical analysis