in Compiler Design edited by
1,411 views
1 vote
1 vote

 

in Compiler Design edited by
by
1.4k views

4 Comments

Sir wants to ask how are you making decisions while reducing bB
0
0
edited by

@Arjun sir, Using SLR(1) parsing table i tried to parse the above string.. no reduce reduce conflict was there..Only one B -> bB reduce move was possible.

By making DFA for it, i made sure that this grammar is LR(0) and so SLR(1), LALR(1) and LR(1) too. After that I just parsed the strings by reducing at "handles" only..

0
0
edited by
Answer c
0
0

1 Answer

0 votes
0 votes

As, None of the option says "Grammar is not SLR(1)", I am directly trying to parse the string here.

Try to derive the string from the given productions, by following Right most derivation.(Cause we are dealing with bottom-up parsers,this is useful at the end)

S->AB (B is bolded to indicate that it is expanding in the next step)

  ->Ac (you can see, we are producing 'B' first, as we are following Right most derivation)

  ->aAc

  ->aaAc

  ->aabBc

  ->aabbBc

  ->aabbcc

Now, start looking, bottom up, just like how, bottom up parsers do: Right most derivation in reverse.

We can observe the order : B,B,A,A,A,B,S.

So,  C is correct choice.

 

edited by

1 comment

Can we same procedure for a given grammar,input string and any one of the lr parsers(lr(0),lr(1),lalr(1)),when asked to find the reduction order?
0
0