548 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

edited | 548 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.

It is SLR paring not LR(0) so ans is 0(option A)
by (419 points)
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}
by (499 points)

1
2
3