The Gateway to Computer Science Excellence
0 votes
139 views

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 by Loyal (7.1k points)
edited by | 139 views
0
C....??
0
I got C
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 .
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 ?
0

 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

0
:o  i didn't knew that

Brother can you please elaborate the difference I didnt get that properly what u are conveying :)
0

I solved this question

check here 

0
Brother had it been a top down parser what would have been the result ?
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

 i think so

never thought about it

@Shaik Masthan what are your views?

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
+1

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

1 Answer

0 votes
None ...no option are matching ...either question should mention ...top down parser
by (357 points)
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,833 questions
57,713 answers
199,427 comments
107,687 users