10 votes 10 votes Consider the following grammar: $S \rightarrow S$ $S \rightarrow SS \mid a \mid \epsilon$ Construct the collection of sets of $\text{LR (0)}$ items for this grammar and draw its goto graph. Compiler Design gate1988 compiler-design descriptive grammar parsing + – go_editor asked Dec 19, 2016 recategorized Apr 16, 2021 by Lakshman Bhaiya go_editor 3.6k views answer comment Share Follow See all 5 Comments See all 5 5 Comments reply Show 2 previous comments Hira Thakur commented Dec 31, 2018 reply Follow Share Here S→ ϵ will take as reduce/ shift action or not effect on LR(0) DFA?? 0 votes 0 votes Arjun commented Jun 29, 2019 reply Follow Share So we cannot write LR(0) items if grammar is ambiguous? 0 votes 0 votes Sukanya Das commented Jul 6, 2019 reply Follow Share afaik, LR(0) items can be constructed if the grammar is ambiguous. 2 votes 2 votes Please log in or register to add a comment.
Best answer 14 votes 14 votes The augmented production is $S^{'} \rightarrow S$. $\textbf{GOTO Graph:}$ Here, each of $I_0$, $I_1$, $I_2$, $I_3$ is a set of $LR(0)$ items. And hence $I_0$, $I_1$, $I_2$, $I_3$ are the collection of sets of $LR(0)$ items. Sukanya Das answered Jul 7, 2019 selected Jul 7, 2019 by Arjun Sukanya Das comment Share Follow See all 7 Comments See all 7 7 Comments reply Naren226 commented Dec 18, 2020 reply Follow Share The grammar is not LR(0) right? 0 votes 0 votes Abhilash Behera commented Dec 20, 2020 reply Follow Share No, it's not. I0, I1, and I3 have shift-reduce conflicts. 0 votes 0 votes raja11sep commented Dec 25, 2021 reply Follow Share And I1 and I3 also contains reduce/reduce conflict. 0 votes 0 votes abir_banerjee commented Oct 22, 2022 reply Follow Share @raja11sep you must be considering S--->S. and S-->. for RR conflict right?? 0 votes 0 votes Pranavpurkar commented Nov 28, 2022 reply Follow Share @abir_banerjeeYes. s -> ss. and s->. is also one. 0 votes 0 votes Godlike commented Dec 18, 2022 reply Follow Share @Arjun sir do we consider augmented productions in RR conflict? for example a state with S’->S. and S->a. will these two be taken as rr conflict in LR(0) parser? 0 votes 0 votes Pranavpurkar commented Dec 19, 2022 reply Follow Share @Godlike No, $S’→ S.$ is the acceptance state not the reduced state. 2 votes 2 votes Please log in or register to add a comment.
1 votes 1 votes Augmented production S'-->S Verma Ashish answered Jun 29, 2019 reshown Jun 29, 2019 by Verma Ashish Verma Ashish comment Share Follow See all 4 Comments See all 4 4 Comments reply Verma Ashish commented Jun 29, 2019 reply Follow Share Sir we can write LR(0) items.. But there will be conflicts in dfa (of canonical collection of LR(0) items).. so the grammar will not be LR(0) 1 votes 1 votes Arjun commented Jun 29, 2019 reply Follow Share Thats all is asked in the question rt? 3 votes 3 votes Verma Ashish commented Jun 29, 2019 reply Follow Share Yes.. 0 votes 0 votes shashankrustagi commented Dec 15, 2020 reply Follow Share Yes this grammar is not LR(0) And the question only asked to draw the DFA 1 votes 1 votes Please log in or register to add a comment.