retagged by
501 views
3 votes
3 votes

Consider the following grammar:

  • $S \rightarrow  aMd \mid  bNd \mid aNe \mid bMe$
  • $M \rightarrow  c$
  • $N \rightarrow c$

The grammar above is:

  1. LR(1) but not LALR(1)
  2. LALR(1) but not SLR(1)
  3. SLR(1) but not LR(1)
  4. LALR(1)
retagged by

2 Answers

Best answer
2 votes
2 votes
LR(1) grammar does not have any conflict. while taking union of productions

M --> c

N --> c

it generates reduce/reduce conflict ( RR Conflict ). Hence, the grammar is not LALR(1) grammar.

so the option A is correct The grammar is LR(1) but not LALR(1) .
selected by
1 votes
1 votes

Approach:

1. you can easily see, M->c and N->c will reduce and they will come into the same state so, they will lead to conflict and for SLR(1), we need to find the follow of M and N then we got the RR conflict.so, not SLR(1) => not LR(0) also.

2. now, draw LR(1) canonical collection you will find no conflicts but For LALR(1), by merging the states with same productions but different lookaheads you will get the RR conflict and they are due to M and N productions.

so,LR(1) but Not LALR(1)

ANSWER : (A)

additional note: CLR(1) is same term for LR(1).

Answer:

Related questions

2 votes
2 votes
2 answers
1
Bikram asked Nov 25, 2016
667 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
3 votes
3 votes
1 answer
2
Bikram asked Nov 25, 2016
266 views
Which grammar causes recursive-descent parser to go into infinite loop?LL(1)Left recursive grammarRight recursive grammarGrammar with left factors
3 votes
3 votes
1 answer
3
Bikram asked Nov 25, 2016
449 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...