29 votes 29 votes Consider the following grammar $S \rightarrow S * E$ $S \rightarrow E$ $E \rightarrow F + E$ $E \rightarrow F$ $F \rightarrow id$ Consider the following LR(0) items corresponding to the grammar above $S \rightarrow S *.E$ $E \rightarrow F. + E$ $E \rightarrow F + .E$ Given the items above, which two of them will appear in the same set in the canonical sets-of-items for the grammar? i and ii ii and iii i and iii None of the above Compiler Design gatecse-2006 compiler-design parsing normal + – Rucha Shelke asked Sep 16, 2014 • edited Dec 8, 2017 by kenzou Rucha Shelke 11.7k views answer comment Share Follow See all 3 Comments See all 3 3 Comments reply Utkarsh Pathak commented Dec 9, 2020 reply Follow Share As we can see in the below given LR(0) items, that all three belongs to different state (sets). 0 votes 0 votes HitechGa commented Jan 13, 2022 reply Follow Share $S→S∗.E$ $E→F.+E$ $E→F+.E$ Quite intuitively, in very less time, we can say that answer is none i.e. option (D). Why? means that we have just seen $*$. Now if this item is with item ii, it would mean that we have seen a * and we are about to see a +, a situation as *+ should be there in the string input to the parser. Which is something not generated by the input grammar. Similarly, i cannot be with iii, it would mean that we have just seen a * and also we have just seen a +. means that we are about to see a + next. And iii means we have just seen a +. This would mean, ++ shall be present as a substring in the string input to parser. But this sort of thing cannot be generated by the grammar given. The grammar generates expressions having + and *. 5 votes 5 votes KartikGawande commented Aug 11, 2022 reply Follow Share Really good approach HitechGa 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes Since in first production s->s*.E, in this state the production of E will be there similarly in other 2 also productions can't be together for the same reason. Arvnd answered Nov 17, 2018 Arvnd comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes D. is the answer. Also, it is not LL(1) as it is left recursive and also it is not LR(0) because there is shift-reduce conflict and hence it is not SLR(1), LALR(1), CLR(1). Shubhm answered Jul 13, 2019 Shubhm comment Share Follow See all 3 Comments See all 3 3 Comments reply raja11sep commented Sep 18, 2021 reply Follow Share hence it is not SLR(1), LALR(1), CLR(1). Can we say that if grammar is not LR(0) then it is not SLR(1), LALR(1), CLR(1) ? 0 votes 0 votes ankit3009 commented Nov 9, 2021 reply Follow Share No , because every LR(0) grammar is also SLR(1), but not all SLR(1) grammars are LR(0). 0 votes 0 votes raja11sep commented Nov 9, 2021 reply Follow Share Read again 0 votes 0 votes Please log in or register to add a comment.