SR conflict in LR(0) and SLR(1) will always be equal for some context free grammar?

871 Views Asked by At

I was told by someone that this statement is false, but I think it is true.

Consider the grammar which have no SR conflict in LR(0) then it should not have SR conflict in SLR(1) also because it is more powerful than LR(0). So in this case SR conflicts in both are equal. So the given statement should be true. Am I getting it wrong somewhere?

1

There are 1 best solutions below

0
rici On

The LR(0) algorithm will produce shift-reduce conflicts in any state with a mixture of shift and reduce actions, because there is no lookahead available. An SLR(1) parser can resolve those conflicts when the token to be shifted is not in the FOLLOW set for the symbol to be reduced. Thus, the LR(0) parser has shift-reduce conflicts which are not in the SLR(1) parser for the same grammar, but every conflict in the SLR(1) parser is also in the LR(0) grammar.