GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
162 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 (42.9k points)  
retagged | 162 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 (14k points)  
How do you know it is s attributed . I mean how did you figure out .Given a SDT how can i find out which one is what .its seems almost same to me.

it is said that S attributed is evaluated Bottom up manner and in L attributed we use Depth First .Right to Left but i dont find any difference we do the same procedure for evaluation.

how do you distinguish the parse tree of L attributed from this one ?

And one more thing in this production E ---->E+E  we can choose any side fro further evaluation why did you choose right side . if we use left side answer will be different .

Please clear the confusion b/w Procedure of evaluation .and figuring out what is what .
Yeah ur right if we use that to left sided we get result as aa+a+#

Since S couldn't be finished untill E gets finished it means here S is depending on its Child E so it is S attributed
Are we going to see this dependency in every production or in just one is enough.
No if we find that all are s attributed we say it is s attributed
If some are S attributed and other are L attributed then we say it as L attribute
I have one more Question as you said it is s attributed but L attributed definition itself contains both definition synthesized as  well as inherited definition then if a SDT is s attributed then we can apply both S attributed as well as L attributed  definition for solving the question and there will be ambiguity in Answer.

What do you think ?
every s attrbuted could be L -attributed but not vice versa

in this question their is not dependency on siblings i think what do u say ?
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
if the string is in the form of a+a+a then we have to evaluate by using left associativity but u made this as right associativity i think thats why u got a diff ans

i got ans as    aa+a+#


Top Users Sep 2017
  1. Habibkhan

    8796 Points

  2. rishu_darkshadow

    3572 Points

  3. Warrior

    2914 Points

  4. Arjun

    2840 Points

  5. A_i_$_h

    2550 Points

  6. manu00x

    2268 Points

  7. nikunj

    1990 Points

  8. Bikram

    1874 Points

  9. makhdoom ghaya

    1820 Points

  10. SiddharthMahapatra

    1718 Points


26,346 questions
33,928 answers
80,524 comments
31,231 users