1 votes 1 votes 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 ? Compiler Design syntax-directed-translation compiler-design + – shekhar chauhan asked Jun 5, 2016 retagged Jun 5, 2016 shekhar chauhan 979 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes It is S attributed as the attributes are depending on their child Let me know if anything is wrong shivanisrivarshini answered Jun 5, 2016 shivanisrivarshini comment Share Follow See all 13 Comments See all 13 13 Comments reply shekhar chauhan commented Jun 5, 2016 reply Follow Share 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 . 1 votes 1 votes shivanisrivarshini commented Jun 5, 2016 reply Follow Share 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 0 votes 0 votes shekhar chauhan commented Jun 5, 2016 reply Follow Share Are we going to see this dependency in every production or in just one is enough. 0 votes 0 votes shivanisrivarshini commented Jun 5, 2016 reply Follow Share No if we find that all are s attributed we say it is s attributed 0 votes 0 votes shivanisrivarshini commented Jun 5, 2016 reply Follow Share If some are S attributed and other are L attributed then we say it as L attribute 0 votes 0 votes shekhar chauhan commented Jun 5, 2016 reply Follow Share 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 ? 0 votes 0 votes shivanisrivarshini commented Jun 5, 2016 reply Follow Share 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 ? 0 votes 0 votes shivanisrivarshini commented Jun 5, 2016 reply Follow Share where u get this question ?? 0 votes 0 votes shekhar chauhan commented Jun 5, 2016 reply Follow Share 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 0 votes 0 votes shivanisrivarshini commented Jun 5, 2016 reply Follow Share we need to consider unambiguous grammar for sdt if not we need to change it to unambiguous I think 0 votes 0 votes asu commented Jun 5, 2016 reply Follow Share @sekhar parse tree as per order of presedence.... 1 votes 1 votes srestha commented Jun 6, 2016 reply Follow Share @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 1 votes 1 votes Vamsi Vamsi commented Aug 30, 2017 reply Follow Share 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+# 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes S attribute....aaa++# ...every S attribute is L attribute ...but every L need not be S. Anup dogrial answered Jan 8, 2020 Anup dogrial comment Share Follow See all 0 reply Please log in or register to add a comment.