The Gateway to Computer Science Excellence
0 votes
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

in Compiler Design by Loyal (9.3k points)
edited by | 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.

2 Answers

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

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,306 answers
198,314 comments
105,010 users