in Compiler Design retagged by
651 views
1 vote
1 vote

How to solve this ? Please help.

in Compiler Design retagged by
651 views

2 Comments

These  are option A and B.

0
0

Option C and D.

0
0

1 Answer

2 votes
2 votes

For approaching such questions one must be clear about how LR(1) parsers actually work.

I am inserting image of stack content after reading each input symbol left to right one by one.

Hope it helps

3 Comments

Inserting next image in the comment section. 

1
1

Thanks for the ans...But your stack content is wrong..5th stack contains a,T,b,c from bottom to top. Which is invalid ,after b you can not puch c ..here ‘b’ is a handle so viable prefix (Stack contains at any time) can not exist beyond ‘b’ , pop ‘b’ and push ‘T’.

0
0

@raja11sep My stack content is right , c will be there after b as this is what LR(1) does .Instead of blindly reducing b into T it will check lookahead of b i.e. c . Is c follow of my stack content after reduction of b into T or not ?

1
1