 So, quickly to recapture what we were discussing towards the previous class we started looking at all attributed definitions and once we introduced all attributed definitions we also introduced translation schemes where we said that the code need not be at the end of any rule and we can embed the code anywhere in the right hand side. And then we looked at positioning of the code we said that this code should be evaluated in a position. So, that we have all the attributes which are required to evaluate it and a general position we found was that for inherited attributes the code must be evaluated in the immediately of the left of the grammar symbol and for synthesized attributes the code can be evaluated at the end of the rule. This is what we were discussing and then we took an example this example came from. So, these were examples we were discussing for the placement of attribute rules and then we took an example from equation type setter and introducing the rules here we were trying to position these rules. So, that value of these attributes get evaluated in the right place and then we looked at the placement of these and this turned out to be the placement where we said that each of the inherited attribute is getting evaluated on the immediately left of the grammar symbol. So, this is what we were doing and once again just to set the tone right for the discussion we had two parsing methods and two kind of attributes synthesized and inherited attributes and two parsing methods which are top down and bottom up and we saw that at least for bottom up parser and synthesized attribute we could always evaluate all the attributes while we were building the parse tree or doing the parsing and we also found that as far as L attributed definitions were concerned we could also use a top down parser and could finish off evaluation of all the L attributed definitions right. Two things which we have not managed so far that how do we evaluate translation schemes and the most critical problem was that how do we use a top down parser along with synthesized attributes and how do we use a bottom up parser along with the inherited attributes. These two problems were still not clear so everyone is sort of is able to recall what we were doing is that the same footing you can start our discussion from here. So, first problem that comes is that when I have a top down parser and I have some embedded rules, rules could be embedded anywhere or they could be on the right hand side also. So, first thing I need to do is in a top down parser I need to worry about whether I have problem of left recursion or not ok. So, here is an example where I have a grammar I have some attributes which are synthesized attributes and I want to write a top down parser for this. So, this is the first problem I am attacking that we have a top down parser and we are synthesized attributes. So, first problem that will come in top down parser is that I start building my tree from top to bottom and then I will see that somehow if you are talking of synthesized attributes synthesized attributes will go in this direction and my parser will go in this direction how do I handle this situation ok. So, here is a typical situation where you have a rule set of rules which are left recursive and then you have a set of synthesized attribute equations or a set of equation right. So, how do I solve this problem first any idea anything or can this problem be solved first let me ask this question can this problem be solved or the problem is just not solvable and therefore, there is no point attempting even to try to find a solution anything I will just start thinking allow. So, again what should come to your mind is a attributed definitions ok. Now, suppose I say that I am trying to build this parse tree and I am saying that I am using synthesized attributes. Now, when I build this part of the parse tree remember that when I do top down parsing this part will be built before this part will be built. That means it is possible at least that if I evaluate all the attributes in this part and I want to evaluate certain attribute equations then I can take the value on the right hand side. So, basically what is happening is look at it this way that because of the limitation we have put on the attributes. Now, we only want to deal with the all attributed definitions all attributed definitions will have both inherited as well as synthesized attributes. So, if somehow I change my synthesized definition to all attributed definitions then I can do a top down parsing right. Suppose all these synthesized attributes get translated into all attributed definitions then I can use a top down parser to crack this problem ok. Now, the way I want to do this translation is I will first take an example and then I will give you a general rule. Basically conceptually this is saying that since I have built this part of the parse tree first evaluate all the attributes here and then somehow take them on the right hand side. So, first problem let us focus on the grammar and forget about the attribute part and then we will see how to change all these attribute equations from S attributed definition to L attributed definitions. So, it is a reverse transformation right. So, here is a grammar if I remove first left recursion from this grammar because this says e goes to e plus t and e goes to e minus t I cannot handle left recursive grammars as far as top down parser are concerned. So, I need to remove left recursion and if I remove left recursion this is how the grammar will look I have introduced now a new non-terminal R and this e goes to t R and R goes to plus t R and R goes to minus t R and R goes to epsilon ok and these two rules remain as it is because there is no left recursion there ok. Now, if I compare the two grammars how will my parse trees look ok. So, let us look at this grammar this grammar will say that I will go down into something like this thing that e goes to e plus t and then e goes to e minus t and then e can go to t and e can go to num and then goes to num and it goes to num ok standard technique for removal of the left recursion is I now say that e goes to t R and then R goes to let us say minus t R and then this e goes to num this e goes to num and this goes to plus t and R and this e goes to num and this R goes to epsilon right this is how the parse trees will look ok. Now, if I say that I want to use certain definitions to find out this value which are synthesized attributes it is equivalent to saying that if the same value becomes available here and then if I now use instead of only synthesized attributes L attributed definitions then I can solve this problem, but how do I convert that now I say that since I am evaluating from left to right that means when I say that I want to know the value of this e I must know this value and this value. Now, similarly if I say that if I am at this point I must know this I must know the operator and I must know this value then I can find out what is the value corresponding to this part of the tree. And once I know this then knowing this value and this operator I can find out this value which I am saying that knowing this value this operator and this value I can find out the same it is making sense what I am saying or not at all just not sinking in explain what ask the question. So, that is a very generic statement explain it again I can do it 10 times, but that still does not solve the problem. So, look at it this way that suppose I have this value so, let me just put some numbers here. So, suppose this number is 9 this number is 5 this number is 2 and I want what I want is I want value of this expression to be available at this point. So, what will be the value you will take this value this operator and this value evaluate it and we will say this value is 4 and therefore, this value becomes 4 and then you will say I know this value I know this operator I know this value and therefore, this value becomes 6 right this is how you will do it. So, it is basically a left to right evaluation nothing else. Now, I can do the same left to right evaluation here if I say this value is 9 and this value is 5 I know the operator here somehow if I say that if I carry this value on the right hand side and then use this operator and use this value and associate that value at let us say this r. So, what will the value I will get for 9 minus 5 somehow if I take this value here I am taking this value here and then using this information here and this information here I can do this computation I will get the same value somehow. So, let us not worry about how do I change my equations that I will show you systematically do it, but basically you are saying that if I know this this and this I can compute something here then I take it down and then say now I know this and this and therefore, I can recompute this value here right. So, if I say that I have 9 minus 5 which gives me 4 and then I take 4 down here and now I say I know 4 here I know plus and I know what is the number here 2 then I can recompute this value here and somehow take this value now you can see that what I am using here is RL attributed definitions here. So, this value can then become 6 here only problem is value is not available to me still at this point value becomes available at the right most node right most bottom node right now somehow I need to carry it back. So, now if I say that I have both synthesized and inherited attribute if I just can make a copy here and then I can take this value back and this is precisely what I want to do. So, let me first take an example and then see what I am doing here. So, let us look at the rules here these rules nothing is changing because I have no left recursion here I just copied them as it is, but now what I am doing here is now I am saying that the new non terminal I have introduced corresponding to that I have an inherited attribute which says R inherited is T value I am also putting the right places for this. So, basically now I am saying that this node which is the new one which has been introduced this will now copy into its inherited attribute a value which is value of T value right. So, this value gets copied from the left subtree to the right subtree and then at this node now I say when R goes to plus T R then corresponding to this R I am now computing an attribute which is in terms of this, this and this. Now you can see that what I am doing here is that if I now look at this information if I want to compute a value here how do I compute this value I am looking at the operator in the left sibling and I am looking at a value of the parent and using this information. So, basically my left siblings here are this number this operator and this value this is all coming from my attributed definitions I can compute this value. So, if I now say R 1 inherited which is this R 1 gets a value which is R inherited plus T value now plus you have to take as an operator in this case it happens to be plus it could be anything. Now if I evaluate this what will happen now we will say that this value which was 9 here which I copied 9 minus 5 gives me 4 here and then if I look at this equation this equation says R 1 inherited is R inherited minus T value ok. So, in this case yeah so actually it is 9 minus 5. So, let me have both these rules. So, this was minus this was 9 5 this gives me 4 and now I say that I am looking at R inherited here this says I am taking this value and I am taking value from the left child and this gives me 2 and 4 and this gives me value 6 right only except issue remains that this value 6 is available here and not here I want E value to be 6 and not R inherited to be 6. So, how do I take this value up now I can actually do a very simple transformation because now I am saying that R is going to epsilon and R can have both inherited and synthesized attributes now I say that R synthesized is nothing but a copy of R inherited ok. So, if I do that what will happen then I will say that let me take this on can you see this part from the back you cannot why do you point it out let me draw this here this is all your trees right can you see this from this corner ok. So, now when I take this value first this value just gets copied here and now I say that I want to compute inherited attribute in terms of this and this this attribute is coming from parent this attribute is coming from the left sibling and therefore, I get a value which is 4 here and then I say that now I am computing a value which is coming from parent and a value which is coming from the sibling and I get a value which is 9 minus 5 what is the equation I was using here 2 ok. So, this should be 2 here so this gives me 6 ok. Now I say that R synthesized is nothing but a copy of R inherited ok. So, if I do that then I can say that this was value of R i and now R s here becomes R i and what will be the value of R s 6 right and now I can say this R synthesized is a copy of this R synthesized. So, this gives me R 1 s which becomes 6 and then I can use the same rule here which says R synthesized is R 1 synthesized which is 6 and then I can say E val is R synthesized which is 6 and that is what I wanted ok. So, this is what we do here that we say that whenever I do this at silent reduction then I am saying R synthesized is nothing but a copy of R inherited and here I say that R synthesized is a copy of R 1 synthesized and the same rule I will use here which says R synthesized is a copy of R 1 synthesized and E val is nothing but R s ok. Now when I finish parsing this and simultaneously I evaluate all the attribute equations what will be the E val E val will be the correct value which is 6 ok and this is what I wanted right. Now you can see that what I have is I have taken a parser which only had S attributed definitions converted that into L attributed definitions. So, I can use now a top down parser this doable with top down parser how will I use the top down parser for this ok. You can see that all my attribute equations are in the right place. So, I can do the computation without violating the any dependencies ok and how will the parse tree look for this this is how the parse tree will look without the rules and if I now introduce nodes corresponding to all the rules this is how the nodes will look right. So, T goes to num followed by T val basically this is what you have to remember T goes to num followed by T val and just put rules at the right places. So, R goes to minus T this rule R 1 followed by this rule ok. So, this is what it is R goes to minus T R and this rule ok. So, this is how I put all these values and now if I evaluate all these in the depth first traversal order whenever I encounter a rule I just execute it what will be the last rule to be evaluated this will be the last rule to be evaluated and what will be the E val the right value whatever is the right value of this expression ok. So, you can see that if I am given synthesized attributes I need a method. So, I did not still give you a systematic method of converting all the asset attributed definitions into an ellitributed definition ok, but it is doable at least by this example we are able to see that we can do it ok. Now, let us look at a more ok. So, this is just giving you execution trace of the same thing ok this is how it is traversing. So, finally, I get value of synthesized attribute here and then I am just carrying it to the top ok, but this is really what happens ok. Just focus on this rule ok where you have a left recursion and you have synthesized definitions and what I want to do is I want to convert this into ellitributed definitions. So, when I put ellitributed definitions first thing that will happen is that ellitributed definitions will introduce now a new symbol and then I am saying that R first must carry R inherited must be a function of whatever is on the left hand side right. A synthesized in this case is nothing, but R synthesized and whenever you have a rule like this all we are saying is that R 1 is a function of whatever is G and followed by R here and then R must go to epsilon and when R goes to epsilon I am just copying inherited attribute into making a copy of that into synthesized attribute. So, that gives you a general scheme of taking S attributed definitions and converting them into ellitributed definitions ok. So, basically this is exactly what I used here that now if you see that what I have done here is I am saying that this R is going to have an inherited attribute which is a function of whatever is on the left hand side tree and this is nothing, but a copy rule and if I see this says R 1 inherited is a function of the parent and the left sibling this is what I have computed here and then whenever I have this rule this says that synthesized attribute is nothing, but a copy of the inherited attribute. So, systematically I can take S attributed definitions and convert them into ellitributed definitions and once I convert them into ellitributed definitions then I know that I can use a top down parser make sense this clear questions anything G of ojo me namin whether this function is commutative or not is that what you are saying you have to be slightly careful in writing those arguments no no no careful removing left recursion does not give us ellitributed definitions removing left recursion is a precondition for using a top down parser. What we are saying here is that synthesized attribute can be converted into ellitributed definitions in this manner where we say that since I am constructing a tree starting in a bottom up traversal manner that means left hand side of the parse tree will be computed first before I compute the right hand side of the parse tree I just use that logic and say that anything to be computed in the right hand side must be a function of either the parent or the left hand side, but these two things go concurrently. So, now you can see that what I did in this example precisely this is what I did that in first case I was looking only at synthesized attribute where I was saying that a depends on the attributes of a 1 and y and this a depends upon attributes of x which I systematically converted into ellitributed definitions saying that the right hand side of the attribute of the right hand side of the tree depends upon the attribute of the left hand side or attribute of any node depends upon the left sibling and the parent node. So, now let us move on with implementation because now you also want to deal with saying that I have a top down I have a bottom up parser and I want to deal with inherited attributes. So, how do I deal with inherited attributes? So, let us keep this as the running example which is this one let me go back to the same grammar this one. Now, suppose let me reverse the problem and now I say that instead of a top down parser I want to use a bottom up parser. Now, first thing you are saying that in a bottom up parser I can deal with synthesized attribute if everything is S attributed then life is easy, but if something is inherited then I do not know what to do with it. So, that is where I am going to use the translation schemes. Now, how do I first convert an L attributed definition which has inherited attributes in to a synthesized attribute. So, let us take this one let me just pick up one of the rules here and do you remember that how do we evaluate all the synthesized attributes using a bottom up parser what did we do there? We created a value stack on which I was able to keep all the values this everyone remembers how we used the value stack. So, let us just pick up a rule from here. So, rule I am using here is let us say R goes to plus E and R and then there are two definitions on the right hand side. So, let me also write the embedded definitions here and embedded definitions here are in this case it is R 1 inherited is a function of R inherited plus E well followed by R followed by R synthesized is equal to R 1 synthesized and this I am calling as R 1 this is what I have and now I want to use a bottom up parser only problem with bottom up parser is going to be that I am dealing with inherited attributes and I do not know how to compute inherited attributes. So, can you think of a scheme to now convert all L attributed definitions into S attributed definitions right we are looking at two kind of transformation I want to convert S attributed definitions into L attributed definitions when I am using a top down parser and I want to convert all the L attributed definitions only into synthesized attributes if I am using a bottom up parser. So, what is the reverse transformation we just focus on the line I have written here. So, one way to look at this is that if I say that I have only synthesized attributes then what is the right place to compute all the synthesized attributes where do I put all the synthesized attribute computation at the end right. So, how do I take this attribute equation rather from this place. So, 1 2 3 4 and 5 symbols now this is already at the end. So, I do not worry about it, but this one is somewhere embedded how do I take it to the end without changing my computation order. So, again we will have to think of a general method we may deal with examples to understand it, but finally we have to come up with a general algorithm. See all the time we have been introducing these non terminals to remove left recursion we introduce a non terminal. So, let me play this trick now and say that I want to introduce new non terminals and we say that for corresponding to every embedded rule you introduce a new non terminal. And if I now suppose I do now a transformation and say that R goes to plus T and corresponding to this I introduce now a new non terminal M and then I say R 1 and then I have R synthesized equal to R 1 synthesized and then I say M goes to that side. So, at least if I forget about this rule am I dealing with the same language and now I now say that now M is going to have certain attributes because now it is a new non terminal a new non terminal can have inherited attributes it can have synthesized attributes, but we will deal with later deal with that suppose now I say that M goes to epsilon and this is where I introduce R 1 inherited is R 1 plus T 1 will it give me the same parse tree. So, what is the parse tree I will get from here I was getting R going to plus T this action R 1 and this action right. So, I was getting a parse tree which was of this form plus T let me call this as action 1 let me call this as action 2 I was getting action 1 and then R 1 and action 2. And now if I look at parse tree corresponding to this gives me R goes to plus T M R 1 action 2 this M goes to epsilon and action 1. If I just do a scan of all the leaf nodes is it going to give me the same strings yes no. So, all I need to do is whenever I have embedded rules introduce a marker and move rule to the right hand side. Now, if you look at this all the rules are on the right hand side if all the rules are on the right hand side can I use now a bottom up parser because everything looks like now a synthesized attribute. Yes no what are the two actions leading to. So, I have multiple symbols which can go to epsilon remember that actions will be different in each case. So, in general this is how it will work that whenever you have. So, this part we have done your bottom up evaluation of inherited attribute you want to just remove embedded action from the translation scheme. And how do I remove embedded action make transformation. So, that embedded action occurs only at the end of their production and replace each action by a distinct marker and this distinct marker is the non-terminal which says this marker goes to epsilon. So, it does not change my language and this is what happens that now if I say. So, this is an embedded action this was the first example we took as far as the example of translation scheme for concern where we said we want to take an in fix and convert that into a post fix. So, this is what we will do we will say that I am going to corresponding to this action I am putting a marker m corresponding to this action I am putting a marker n m and n both go to epsilon and the action corresponding to that occurs here. But I still need to do more I mean this is just not sufficient because I can have attributes now corresponding to not just all the non-terminals in the original grammar, but I can have now attribute corresponding to the new non-terminals I have introduced and each non-terminal can have both inherited at least one inherited and one synthesized attribute it can have more, but we can deal with at least one and then we will see how to generalize it. Now, if I look at this grammar can I use a bottom up parser for this. So, I started with a grammar where I had all these elitributed definitions see basically if you see placement why I mean we are dealing with the elitributed definitions we are saying that I need to place my attribute equation at the right place. So, that it does not violate any of the dependencies when I start evaluating. So, I have done a very simple syntactic transformation without changing the language all I am saying is that introduce some redundancies and then compute all the attribute equations into the new places I have created. So, basically corresponding to these non-terminals what will happen we will now have a place on the stack where I can compute it and shortly I am going to argue that actually you do not have any kind of inherited attribute in the system all attributes are always synthesized attribute inherited attributes are only a convenient way of writing attribute equations there is nothing like inherited attribute and if you are dealing only with synthesized attribute I can always use a bottom up parser. So, I will come to that I will come to that that is why I am saying that so far I have not introduced attributes corresponding to m n n. So, once I introduce attributes values of m n n then it will become clear, but right now if you see this example this is lot simpler where I am not I am just taking some action I am not computing anything then at least this will work about this you are convinced. So, once I introduce attributes corresponding to m n n even this question will be answered clear. So, at least first step what looks like is prime of a c that if somehow I can remove all the embedded actions and move them to the right hand right most position then I can get grammars by introduction of new non-terminals where all the actions occur only at the right most position and therefore, they are equivalent to or they look like synthesized attributes only and therefore, I can use a bottom up parser to evaluate this, but I still have to generalize it is this part clear to everyone. So, let us move on then and let us see that how do I deal with inherited attributes on the parser stack. So, what we are doing here is that when we deal with bottom up parser remember that this is what we did when we were having only synthesized attributes that if I have a rule which says a goes to x y then I already had the attributes of synthesized attributes of x and y on the stack and before reduction I computed value of a popped x and y and then pushed the a and in the value stack I pushed the synthesized attribute of a this is what I did. So, synthesized attribute of x can be inherited by y many times which are really copy rules. So, when I say that I have says that a goes to x y basically we are saying that now if I use only a attributed definitions how can value of y i be defined y i can be a function only of a i and x i and x s that is the only way I can compute y i there is no other argument which is required to compute y i. So, many times what happens is y i is a copy of x, but as I said I am only giving you examples I am building up so that I can come up with a general algorithm which will solve this problem for all grammars. So, here is an example first you remember this example types. So, now I had this d going to t l which said l inherited is t type, but at that point of time I just wrote this equation at the right most position, but now I am computing it in the because l was an inherited attribute and therefore I have to compute it only on the left of l. So, I will first say t followed by this action followed by l I am embedding actions in the right place now and here I am saying that t goes to n and t goes to real. So, there is no embedded action here I am computing this in the right most position and then I said l goes to l comma i d. So, I said l 1 inherited is l inherited then I have l 1 and here I was saying that I am making an entry in the at type and when I had l going to i d then I was saying that I am only making this entry in the parsed input this is the grammar I had. Now, let us do one thing let us try to parse this string and we actually try to observe a phenomena and see what happens and the string I am trying to parse is this one real p q r and I have to use a bottom up parser because that is the intent that I have elitibuted definitions, but I want to use a bottom up parser. Now, if I use a bottom up parser let us just deal with the stack there is nothing else which is really required what will be the first symbol I will see on the stack first I am going to. So, let us say that I have this value. So, this is my state stack this is my value stack and first I will get this name which says I have real here and the value stack will contain real and this real will get is basically nothing but type. So, t type is nothing but real and that value is available here then what will happen then I will push p on the stack. So, p will come here and corresponding to p what will be the symbol here look at the grammar here p is nothing but an id and therefore, this is nothing but an l and now when I do a reduction by this rule which says l goes to id what is it that I want to do. See remember that I have t here now what will happen is that I will first take p on the stack. So, let us see how it grows I will take p on the stack then I will make corresponding to this I will make an entry in the symbol table then I will push common the stack then I will push q on the stack and then corresponding to q I will make an entry in the past table and then I will say sorry I will not reduce that q. So, I will have l comma id and then when I reduce l comma id to l that point of time I will make an entry corresponding to q in the symbol table. And then I will push common the stack and I will push r on the stack and then I will say l goes to l comma id which is l comma r and that point of time I will make an entry corresponding to r in the symbol table. These are the three entries I was making in the symbol table. So, when this reduction takes place that this was id and l goes to id I want to take this action and what is the action here I want to make an entry in the symbol table saying that type of p is what is the type of p real now where is stack on real on the stack with respect to the grammar symbol. So, if I say this lexeme if I say stack this is my stack pointer this is top where is the value of the type available on the stack value stack top minus 1. So, can I say which rule which says l goes to id which is saying at type id and p l inherited instead of that can I write a rule that whenever I have this reduction I am saying at type and where is my id id is at the top. So, I say value at top and then I say type information. So, what is l inherited there l inherited is nothing but type information. So, there I say that this is value at top minus 1 basically I am looking for this information what is the type of p and that is on the stack I could find it at top minus 1. If I now go further and this has been reduced to l then I will push comma here and then I will push q here and I will have id here. Now, when I do this then this whole thing is going to get reduced to l. Now, when I have this rule which says l goes to l comma id what is it that ultimately I am trying to do see remember that all these rules this rule and this rule which is a copy rule this is not contributing anything this is just taking value in one part of the tree to another part of the tree. Ultimately these are the only two actions I am interested in I want to make these entries in the symbol table. So, now if I say that I am reducing by this rule can I say at the same time that whenever l goes to l comma id basically what I am trying to do is and where is value of type what is the offset for value of type. So, this is my top which contains lexeme this is top minus 1 top minus 2 and top minus 3. This is where the value of attribute is and once I do this reduction what will happen now that this will go this will go this will go this will go and it will become l and then I will again push comma on the stack and I will again push now id on the stack which is going to be r and id and I will again do this reduction and when I say now I want to make an entry corresponding to r. What is the rule I will use I will say that type of r is available at top minus 3 which is here. So, do I need to use any of this rule or this rule if I know the position of the type in the stack. So, two things you must remember here is that corresponding to this rule and this rule basically I am saying that lexeme is always at the top and type is either when I do the reduction by this rule type is a top minus 1 and when I do this reduction type is a top minus 3. It is always a fixed position on the stack. So, this is what happens that if I keep on doing this reduction every time a string is reduced to l t value is just below it on the stack. Every time I say that whole thing is getting reduced t value is just below this and therefore, now I can say that every time reduction to l is made use this information that it is in a known place and therefore, when I say l going to id is applied then we say that t type is nothing but at type id entries nothing but at type top and top minus 1 which is here and if I say l goes to l comma id is applied then this is basically saying that this is equivalent to at type top and top minus 3. So, I could always find this value in a fixed location on the stack I was fortunate this time it may not happen in general, but in this case it happened as far as this grammar was concerned and therefore, now if I replace all these actions by this how will my grammar look my grammar will look something like this. I do not have to have any inherited attributes I do not have to carry these values of l inherited being l 1 inherited and t type being l inherited and so on. I can just write these two rules and all those inherited attributes will just go away because they were anyway carrying information from one part of the tree to another part of the tree. So, I can use the bottom of parser you can see that I started with the grammar which was l attributed definitions and then I was always able to find attributes somewhere on the stack and I was able to then use it. Questions you do not ask me I am going to immediately give you a question which may be in the case form which are inherited from the parent. So, what about them now what attributes can you inherit from the parent can you inherit synthesized attribute or only inherited attribute they have answered your question. Actually if you start looking at carefully there is nothing like an inherited attribute in the system they are only synthesized attributes look at it this way. So, let me in general write something some rule and let us say that this is the first rule of my any grammar I have. So, suppose I have a rule which says a goes to x y and z and this happens to be the first rule of my grammar where is the start symbol and write in the beginning we said that what are the kind of definitions we will have we will say that as far as lexemes are concerned or the tokens are concerned they can only have synthesized attribute. Now, if I look at a what kind of attributes a can have what is inherited attribute of a and what is synthesized attribute of a what is inherited attribute of a cannot be defined is the start symbol it has no left sibling it has no parent. So, this is undefined what about synthesized attribute of a it can be defined as a function of let us say let me call this function of x s y s and now what about x inherited how can define how can I define x inherited what does it depend upon what does it depend upon a inherited, but a inherited is not defined it is undefined and what about it is left sibling does x have a left sibling no. So, this is also undefined what about x synthesized what does it depend upon what does x synthesized depend upon. So, there is going to be some rule corresponding to x somewhere and it will depend upon the symbols on the right hand side. So, x s can be defined now what about y inherited. So, let us try to compute y inherited. So, x is now a function corresponding to some symbols, but it can be defined using the rule of x what about y inherited what does it depend upon it can only depend upon inherited attribute of the parent which is undefined and then it can depend upon attributes of it is left left sibling, but x i is undefined. So, it can only be a function of x synthesized cannot be anything else what about y synthesized y synthesized is some function of it is symbols which will occur in the rule corresponding to y where y occurs on the left hand side and symbols on the right hand side. Similarly, I can argue about z inherited. So, can you see that do I need any inherited attributes in my system if I am dealing only with synthesized attributes then I can always find them in the stack I just need to know the right location like in this case I was able to know the right location saying that whenever this reduction takes place then the right reduction is finding the value in top minus 3 whenever this takes place right place is top minus 1 and I am done right. So, I do not have to worry about inherited attributes at all inherited attributes are a notation which is easier to express, but really is not required I can only deal with synthesized attributes if you are dealing with a let you do the definitions if you have cycles then that is a different issue and we will see how to deal with cycles. So, let us take a break here today and we will continue our discussion in the next class from this point on.