GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
114 views
Either L attribute or S attributed .

What kind of SDT it is  ?

S --->E#   Out('#')

E ---> E+E   Out('+')

E --->T

T ---> T#F   Out('*)

T ---> F

F ---> (E)

F ---> a   Out ('a')

For the sentence a+a+a

What will be the final Output of it ?
asked in Compiler Design by Veteran (40.8k points)  
retagged | 114 views

1 Answer

0 votes

It is S attributed as the attributes are depending on their child

Let me know if anything is wrong

answered by Veteran (13.5k points)  
where u get this question ??
Actually just by lookig at the SDT I dont know how to check whether it is L attributed or S attributed..Unless we have some Semantic rules with it .and i think it should be very imp to know what kind of SDT it is .otherwise we will make some mistake in evatuation process.mainly in case og ambiguous grammar like

E ---> E+ E

E --->E*E

E ---> id

if someone says evaluate it for like 1+1*1 then which way to do it . I don't know
we need to consider unambiguous grammar for sdt if not we need to change it to unambiguous I think
@sekhar parse tree as per order of presedence....
@shekhar yes as the tree is evaluated from all it's children , so it is a S attributed ,

+ is left associative, So, if the parse tree is evaluate from left to right it will be more accurate
Top Users Jan 2017
  1. Debashish Deka

    8968 Points

  2. sudsho

    5326 Points

  3. Habibkhan

    4798 Points

  4. Bikram

    4532 Points

  5. Vijay Thakur

    4486 Points

  6. saurabh rai

    4222 Points

  7. Arjun

    4196 Points

  8. santhoshdevulapally

    3808 Points

  9. Sushant Gokhale

    3596 Points

  10. Kapil

    3486 Points

Monthly Topper: Rs. 500 gift card

19,212 questions
24,104 answers
53,150 comments
20,319 users