1,613 views
0 votes
0 votes

If LALR(1) parser have shift reduce conflict then CLR(1) parser must have shift reduce conflict, why?

1 Answer

Best answer
7 votes
7 votes
  1. First we make CLR(1) table and then we check for SR and RR conflicts.
  2. If SR or RR conflict is there then it is not CLR(1) => it is also not LALR(1).
  3. If we don't find any SR and RR conflict in CLR(1) then we compress the table of CLR(1) to make the LALR(1) table by merging the states which have same production and different look ahead symbols.
  4. Since we have already checked for SR and RR conflict in CLR(1) so there is no chance of SR conflict in LALR(1) but reduce reduce conflict may be there ( due to merging of states ).

=> In order to have a SR conflict in LALR(1) , CLR(1) should also have SR conflict.

If LALR(1) parser have shift reduce conflict then CLR(1) parser must have shift reduce conflict.

selected by

Related questions

2 votes
2 votes
0 answers
2
Na462 asked Jan 19, 2019
922 views
Which one of the following is true about LALR(1) Parser ?It can resolve SR Conflict in favor of reducedIt can resolve SR Conflict in favor of ShiftIt can resolve RR Confl...
2 votes
2 votes
1 answer
3
sripo asked Nov 10, 2018
3,265 views
Can you give an example which is not LL(1) but is CLR(1)
8 votes
8 votes
3 answers
4
Parshu gate asked Nov 13, 2017
15,519 views
Suppose we are given a grammar and asked to find the type of that grammar , what is the algorithm which needs to be followed for each of them? LL(1), OR LR(0) , OR CLR(1...