44 votes 44 votes A canonical set of items is given below $S \to L .> R $ $Q \to R.$ On input symbol $<$ the set has a shift-reduce conflict and a reduce-reduce conflict. a shift-reduce conflict but not a reduce-reduce conflict. a reduce-reduce conflict but not a shift-reduce conflict. neither a shift-reduce nor a reduce-reduce conflict. Compiler Design gatecse-2014-set1 compiler-design parsing normal + – go_editor asked Sep 26, 2014 edited Jan 17 by Arjun go_editor 24.3k views answer comment Share Follow See all 12 Comments See all 12 12 Comments reply Show 9 previous comments Souvik33 commented Dec 3, 2022 reply Follow Share A rare example, when the question setter decided to conduct a small prank, and the answer key along with the answer prints the line “Look at the camera and say Hi!” You’ve been pranked. 2 votes 2 votes iamsubhrajit commented Jan 8, 2023 reply Follow Share @Souvik33 hahaha 1 votes 1 votes Sachin Mittal 1 commented Jul 28, 2023 reply Follow Share I think the given state itself is invalid. Which means we can not have that as a state in any parsing. $S \rightarrow L .> R :$ This item indicates that the parser is in a state where it has derived the L. $Q \rightarrow R.$ : This item indicates that the parser is in a state where it has derived the R. Having both items in the same state is not possible and violates the rules of a valid parsing state. 4 votes 4 votes Please log in or register to add a comment.
Best answer 48 votes 48 votes The question is asked with respect to the symbol ' $<$ ' which is not present in the given canonical set of items. Hence it is neither a shift-reduce conflict nor a reduce-reduce conflict on symbol '$<$'. Hence D is the correct option. But if the question would have asked with respect to the symbol ' $>$ ' then it would have been a shift-reduce conflict. Regina Phalange answered Apr 7, 2017 edited Jun 21, 2021 by Lakshman Bhaiya Regina Phalange comment Share Follow See all 11 Comments See all 11 11 Comments reply bhuv commented Jan 16, 2018 reply Follow Share S→L.>R // we can reach here by reading L in the previous state only. Q→R.// we can reach here by reading R how those both belong even to the same canonical state? We can't have any type of conflict here. 2 votes 2 votes Barney Ross commented Sep 29, 2018 reply Follow Share How would there be a conflict on '>' 0 votes 0 votes Ejaz Ali commented Sep 30, 2018 reply Follow Share If we consider the grammar to be LR(0) there would be S-R conflict in the given canonical form. > $ I0 R2/S1 R2 Suppose that the present state is I0 and on transition on > it goes to I1 state. S->L.>R --production number :1 (on correction of existing question) Q->R. ---production number:2 In LR(0) reduced move will be placed in entire row.(under terminal columns) Here we cant determine SLR(1) paring table as the follow of Q is unknow so we dont know how to place the reduced move. Suppose we go with the given question(on transition on <) S->L.>R Q->R. it wont go to any state so no S-R or R-R as that terminal (<) is not present in the canonical set of LR(0). 1 votes 1 votes jatin khachane 1 commented Nov 15, 2018 reply Follow Share Case 1: If "<" is a valid terminal i.e < is in Grammar Considering given item as LR(0) item as no lookahead State < > $ Given item state Q->R Q->R / Shift J Q->R .. ... ... ... In this case there will be reduce operation performed. So no conflict Case 2: If "<" is a Not valid terminal i.e < is nowhere Grammar State > $ Given item state Q->R / Shift J Q->R .. ... ... In this case there will be ERROR...But still no conflict Please correct me if i am wrong 0 votes 0 votes Antaroop commented Dec 19, 2018 reply Follow Share Shift reduce conflict will be there if there would have been '>'. 0 votes 0 votes Blackcode00 commented Jun 6, 2020 reply Follow Share There will not be a conflict even if in Question symbol " > " is given. Because Given 2 productions will not be in Same state for sure . So they will be in different state. So still NO SR or any conflict will be by considering only given information. using any LR(0) or SLR(1) parser. 8 votes 8 votes arpit_18 commented Jan 28, 2021 reply Follow Share How to determine the SR or RR conflicts by looking at the states? 0 votes 0 votes abir_banerjee commented Oct 22, 2022 reply Follow Share @Arjun Sir @Lakshman Patel RJIT Sir please update the answer . “ But if the question would have asked with respect to the symbol ' > ' then it would have been a shift-reduce conflict.”“ This statement is wrong because even after reading ‘>’ there will be no SR or RR conflict. 3 votes 3 votes Abhrajyoti00 commented Dec 27, 2022 reply Follow Share @abir_banerjee Why do you think so? It is a collection of LR(0) items, then? 0 votes 0 votes Ray Tomlinson commented Jan 17 reply Follow Share I also think @abir_banerjee is correct 0 votes 0 votes pranavbhosle_ commented Feb 2 reply Follow Share I also think that there will not be any shift reduce conflict even if they had asked about '>'. It's because, on input '>', only first production rulw gets into next item(state). Isn't that right ? 0 votes 0 votes Please log in or register to add a comment.
25 votes 25 votes Ans : The given input symbol no where in the given grammar so with given symbol we have neither a shift-reduce nor a reduce-reduce conflict. So, correct answer is (D.) ... Card Wizard answered Dec 15, 2014 edited Dec 11, 2017 by kenzou Card Wizard comment Share Follow See all 15 Comments See all 15 15 Comments reply Show 12 previous comments habedo007 commented Dec 7, 2017 reply Follow Share Even if the question had ">", there won't be any conflict on its canonical collection. There will only be shift to $S\rightarrow L>.R$ and enumerations of R. The current state itself is in SR conflict, and that's a different matter. 0 votes 0 votes Barney Ross commented Sep 10, 2018 reply Follow Share Can someone send some resources for this topic? 0 votes 0 votes Rajesh Panwar commented Dec 11, 2018 reply Follow Share may be printing mistake in the question? but according to the question Option D is right 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes The input symbol is “<” which is not in canonical set of item, so it is neither a shift-reduce nor a reduce-reduce conflict with reference to “<” symbol. But if it would have asked about “>” then it will be a SR conflict. varunrajarathnam answered Sep 19, 2020 varunrajarathnam comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes d ans as <. is not in the grammer akankshadewangan24 answered Apr 22, 2017 akankshadewangan24 comment Share Follow See 1 comment See all 1 1 comment reply paraskk commented Mar 29, 2019 reply Follow Share this question is just to trap students marking in a hurry! 2 votes 2 votes Please log in or register to add a comment.