2 votes 2 votes Consider the following grammar: $S \rightarrow L = P \mid P$ $L \rightarrow ^*P \mid id$ $P \rightarrow L$ The above grammar is: Ambiguous SLR(1) LALR(1) None of the above Compiler Design tbb-cd-1 compiler-design grammar + – Bikram asked Nov 25, 2016 retagged Sep 14, 2020 by ajaysoni1924 Bikram 667 views answer comment Share Follow See all 6 Comments See all 6 6 Comments reply Show 3 previous comments shaktisingh commented Nov 18, 2019 reply Follow Share SLR(1) parsing table also have RR conflict, check the L->*p. and P->L. reductions we find the follow of both L and P as " * " so RR conflict occured here. 0 votes 0 votes shaktisingh commented Nov 18, 2019 i edited by shaktisingh Nov 18, 2019 reply Follow Share @Ashwani Kumar 2 the productions should be S->L.=P (shift move) and P->L. (reduce move) you write the second S instead of P. and also you wrong interpreted the logic, it should be like this : we first find the follow of S which is $ and then, find the follow of P which is also $ so same we then got the SR conflict here. how the follow of S contains ' = ' in this case? 0 votes 0 votes hello_manish commented Dec 11, 2021 reply Follow Share U have done minor mistake, follow of S is not '=', its for L. In S-> L.=P, P->L. Fo(P) = Fo(L)U Fo(S) = {\$,=} in S->L.=P shift on '=' and in P->L. Reduce on '=' is shift-reduce conflict in SLR(1). While in LALR(1), lookahead P->L. is $ only and shifting on '=', hence no conflicts. 0 votes 0 votes Please log in or register to add a comment.
Best answer 2 votes 2 votes there are no conflicts in any states and merging based on lookaheads is also possible. it is LALR(1) grammar. Bikram answered Dec 22, 2016 selected Aug 21, 2019 by Bikram Bikram comment Share Follow See all 0 reply Please log in or register to add a comment.
1 votes 1 votes Can someone explain me how this is checked? Jevi answered Dec 14, 2016 Jevi comment Share Follow See all 2 Comments See all 2 2 Comments reply Bikram commented Dec 22, 2016 reply Follow Share Please draw the DFA , it is LALR(1) Go through this thread : https://www.facebook.com/groups/core.cs/permalink/1373588902673359/ 0 votes 0 votes Bikram commented Dec 26, 2016 reply Follow Share The grammar is unambiguous. The construction of SLR(1) parsing table reveals shift reduce conflict, hence the grammar is not SLR(1). The grammar is LALR(1) as there is no conflict in LALR(1) parsing table of the grammar. 0 votes 0 votes Please log in or register to add a comment.