search
Log In
0 votes
1k views

Consider the grammar-

$S \rightarrow BB$

$B \rightarrow aB/bB/a/b$

How many shift-reduce conflicts will occur when we try to make SLR parsing table for the above grammar?

A. 0

B. 1

C. 2

D. None

in Compiler Design
edited by
1k views
0
is it 2?
0
Answer is 2. I am getting 4.
1

I0:

S->.BB

B->.aB

B->.bB

B->.b

B->.a

I0 on B (i.e shift B)

I1:

S->B.B

B->.aB

B->.bB

B->.b

B->.a

shift a on I1

I2: Here you get shift reduce conflicts for 'a'

shift b on I1

I2: Here you get shift reduce conflicts for 'b'

Now, no more SR conflicts arise

0

@Sushant

See this once. Where is my mistake?

0
@Sushant
0
follow of b is $ only na then in slr why did u write reduce on all the columns i think u have done lr and answered this question
0
only 2 conflict.

2 Answers

0 votes
It is SLR paring not LR(0) so ans is 0(option A)
0 votes
There will be only two SR conflicts in two states one conflict is with  B->b.(R), B->.bB(S) {b comes in follow of B} and the other one is with B->a.(R) , B->.aB(S) {a comes in Follow of B so conflict}

Related questions

0 votes
3 answers
1
1k views
Please anyone create a $LR(0)$ Parsing table on this grammar and show the working of each step: $S' \rightarrow S$ $S \rightarrow S$;$A \mid A$ $A \rightarrow E \mid id := E$ $E \rightarrow E+id \mid id$ Non-Terminals: $S'$ $S$ $A$ $E$ Terminals$: ; := + id$ Please take a screenshot of copy and show in the answer the whole working.
asked Mar 18, 2018 in Compiler Design rahuldb 1k views
0 votes
0 answers
2
805 views
Consider the following augmented grammar G which is used to build LR (0) parsing table. E' __> E E __> E+T/T T __> T*F/F F -->(E)/id How many rows are there in the parsing rable ? a)11 b)12 c)13 d)14
asked Oct 14, 2017 in Compiler Design rahul sharma 5 805 views
4 votes
1 answer
4
5.3k views
Consider a Grammar G as follows : $S\rightarrow W$ $W \rightarrow ZXY / XY$ $Y\rightarrow c/\epsilon$ $Z\rightarrow a/d$ $X\rightarrow Xb/\epsilon$ Draw the LL(1) parsing table for the given grammar ? NOTE :- The above grammar is NOT LL(1) .
asked Dec 27, 2016 in Compiler Design Kapil 5.3k views
...