in Compiler Design recategorized by
3,648 views
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.

in Compiler Design recategorized by
3.6k views

4 Comments

Here  S→  ϵ will take as reduce/ shift action or not effect on LR(0) DFA??

0
0
So we cannot write LR(0) items if grammar is ambiguous?
0
0
afaik, LR(0) items can be constructed if the grammar is ambiguous.
2
2

2 Answers

14 votes
14 votes
Best answer

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.

selected by

4 Comments

@abir_banerjee

Yes. s -> ss. and s->. is also one.

0
0

@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
0

@Godlike

No, $S’→ S.$ is the acceptance state not the reduced state.

2
2
1 vote
1 vote

Augmented production S'-->S

 

reshown by

4 Comments

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
1
Thats all is asked in the question rt?
3
3
Yes..
0
0
Yes this grammar is not LR(0)

And the question only asked to draw the DFA
1
1

Related questions