GATE CSE
First time here? Checkout the FAQ!
x
+2 votes
137 views

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 (10.8k points)   | 137 views

1 Answer

+6 votes
Best answer

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

answered by Veteran (17.8k 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 reduction..like first reduction is r->P then
SP->Q..so on...because we have to do reverse of rmd..so 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.



Top Users Sep 2017
  1. Habibkhan

    7142 Points

  2. Warrior

    2640 Points

  3. Arjun

    2480 Points

  4. rishu_darkshadow

    2466 Points

  5. A_i_$_h

    2214 Points

  6. nikunj

    1980 Points

  7. manu00x

    1846 Points

  8. makhdoom ghaya

    1770 Points

  9. Bikram

    1744 Points

  10. SiddharthMahapatra

    1718 Points


26,133 questions
33,705 answers
79,886 comments
31,105 users