in Compiler Design edited by
810 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}$
in Compiler Design edited by
810 views

4 Comments

$Q\rightarrow .r, R\rightarrow .r$, reduce reduce conflict on $r$
0
0
but look ahead is different in both these productions.

Q -> r.    +/-

R-> r.   q/r

 

then how will there be a r r conflict?
0
0
ohh my bad didn't check, but isn't the above grammar ambiguous, as we can have $2$ different parse tree for $r$. So, not $LR(1)$
0
0

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