search
Log In
5 votes
989 views

Consider the following grammar:

  • $S \rightarrow S$
  • $S \rightarrow SS \mid a \mid \epsilon$

Construct the collection of sets of LR (0) items for this grammar and draw its goto graph.

in Compiler Design
edited by
989 views
0
i think this is ambigous grammer try to gererate string "a" you will gate 2 LMD
0
It is ambiguous grammar and we can't parse it by LR(0) parser. right na?
0

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

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

2 Answers

7 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
0
The grammar is not LR(0) right?
0
No, it's not. I0, I1, and I3 have shift-reduce conflicts.
1 vote

Augmented production S'-->S

 


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

And the question only asked to draw the DFA

Related questions

0 votes
3 answers
1
505 views
Consider the following grammar: $S \rightarrow S$ $S \rightarrow SS \mid a \mid \epsilon$ Indicate the shift-reduce and reduce-reduce conflict (if any) in the various states of the LR(0) parser.
asked Dec 19, 2016 in Compiler Design jothee 505 views
0 votes
1 answer
2
423 views
Translate the executable statements of the following Pascal Program into quadruples. Assume that integer and real values require four words each. repeat flag[i]:=true; while turn !=i do begin while flag[j] do skip turn:=i; end critical section flag[i]:=false; until false Program Test; var i:integer; a: array [1...10] of real; begin i:=0; While i:<=10 do begin a[i]:=0; i:=i+1 end; end.
asked Dec 19, 2016 in Compiler Design jothee 423 views
2 votes
1 answer
3
657 views
Consider the procedure declaration: Procedure P (k: integer) where the parameter passing mechanism is call-by-value-result. Is it correct if the call, P (A[i]), where A is an array and i an integer, is implemented as below. create a new local variable, say z; assign to ... the body of P using z for k; set A [i] to z; Explain your answer. If this is incorrect implementation, suggest a correct one.
asked Dec 19, 2016 in Compiler Design jothee 657 views
5 votes
1 answer
4
1.1k views
Construct a DAG for the following set of quadruples: E:=A+B F:=E-C G:=F*D H:=A+B I:=I-C J:=I+G
asked Dec 19, 2016 in Compiler Design jothee 1.1k views
...