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

Consider the following Translation rules for the Grammar G :

What will be the output for input string abebebe for bottom up parser ?

  1. CBBPBPBP
  2. CBBBPPBB
  3. CBPBPBPB
  4. CBPBBPPB
in Compiler Design edited by
by
1.3k views

15 Comments

moved by
C....??
0
0
I got C
0
0
My doubt is in bottom up parser the print statement should be executed when reduction is performed so according to that no option matches

Instead C was the only option I got .
1
1

......

0
0
But brother according to me in bottom up parser the print statement is executed i.e. the semantic action when the reduction will perform na

So the answer should be the reverse of what is printed ?

Why u did what u did brother ?
1
1

 yes it is bottom up and mostly semantic actions are placed are rightmost end like this 

$S \rightarrow$ a A {print a}

that's why a is printed while we move up

but in this specific question the semantic action is in the middle of productions and non-terminals are right end so while going down we will do all semantic actions except the last one 

A $\rightarrow \epsilon$

because semantic action is on rightmost end

1
1
:o  i didn't knew that

Brother can you please elaborate the difference I didnt get that properly what u are conveying :)
0
0
0
0
Brother had it been a top down parser what would have been the result ?
0
0
Actually my doubt is you're simply executing the print statement when you encounter one, i do that in case of top down so does it mean here in this case the output will be same as the one for top down ?
0
0

 i think so

never thought about it

@Shaik Masthan what are your views?

0
0
Now the way i think in bottom up the print statement is at the last so the first print which i will encounter will eventually be last so there also i am using the same funda right ? i.e. to execute a print statement the moment i encounter one
0
0

 had it be top down or bottom up, print when you encounter any semantic action

1
1
Its private . Can you please make available? @Mk Utkarsh
0
0
I think

Option C is correct according to TOP DOWN parser.

Is it BPBPBPBC in BOTTOM UP parser??

Please check and explain

Thanks.
0
0

1 Answer

1 vote
1 vote
None ...no option are matching ...either question should mention ...top down parser

1 comment

Option ‘C’ is definitely correct. And yes, here even top-down will produce the same answer.
0
0