The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+2 votes

here it is given bottom up parsing still action is given in middle so output should be GAAAAT??? Is it true that in syntax tree tanslation bottom up and top down gives same answer???

asked in Compiler Design by Veteran (12.3k points) | 164 views

1 Answer

+6 votes
Best answer

bottom up will be TAAAAG..i have missed one A to write...

answered by Veteran (19.6k points)
selected by
It means in top down S---> p {"A"} P kind of production after "P" is encountered the only semantic action done right???? What if,     S-->{"A"}pP type of production is there??

And also S--->pP{"A"} production in bottom up.
sry i didnt see the comment
here actually these are L attributes SDTs so technically we should do top to down then left to right parsing...but since exclusively it is given that u have to bottom up..i have done this way.. if u go top down here answer would be GAAAAT here
i was having a doubt that even in bottom up we beigin from lead node that is leftmost so me must begin from p right???
no in bottom up we perform SDT only when there is a first reduction is r->P then
SP-> on...because we have to do reverse of go till bottom then make building upwards
Thanks @sudsho. Well expalined.

@Bikram sir, in page 1 of this pdf,it is mentioned that:

General rule: The actions are viewed as "dummy" terminals embedded in the parse tree. They are executed in the order of a preorder traversal of the tree. Thus, the result of the SDT is the same whether parsing is top-down, bottom-up, or something else.

In what sense they are saying that the result of SDT is same during both TDP and BUP.In this question also we can see TD and BU implementation are giving different results.

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

28,947 questions
36,793 answers
34,690 users