 You remember the discussion we had at the end of the previous class, we went to the steps of construction of SLR Parsons, we started with the expression drama so we did full table for it. And then I gave you this grammar and asked you to construct SLR Parsons How many of you have constructed this? Raise your hands, raise your hands higher please. And the bottom of the rest, all those who have not done this, please once again raise your hands. In this case it cannot be undecided, either you have done it or you have not done it. That still doesn't fit into the picture because there are still people who have not done it. So what is the reason? You will not understand the SLR Parsons or there is no time to do it. So if SLR Parsons is not clear, there is no point going ahead from this point on. So is SLR Parsons construction of SLR Parsons clear or not? Yes, no. Silences, they won't give me feedback, they won't respond to the questions that I got to answer from this and I cannot be just teaching to the board, I am teaching to you. So is construction of SLR Parsons clear to everyone? Sir, can you explain the reduction step? If there is a production, I follow alpha dot, then for all the symbols and for follow-up in that, in that too I can't read. So how did you come up with that, how did you put the entry in the parser table? How did I put entry in the parser table? So the question is that when we had this rule for reduction, how did I make an entry in the parser table? So suppose I had some item, I am not worried about what this item was, some item where I have a production of this form or I have an lr0 item of this form. Now this item is same, so once again I will conceptually try to explain you that this is saying that in this particular item or suppose I had another item where I had an lr0 item of this form. Now what is saying is that whatever I expected to see I have seen that and I am now ready for reduction. The question is that what are the symbols on which I can do reduction? So let's again look at the stack and I am in some state say S1, then I have id on this and I am in some state S2 and then I see certain symbols and then I do reduction. That is going to be the state of my parser. So when I say that I am in this state for example and I am ready for reduction by id using this particular rule id will get reduced to F. So this state must be let's say this state is j prime. Now what are the steps which I will take in the process of reduction? What will happen to my stack after reduction? So before reduction this is the state of the parser I have and after reduction what will be the state of the parser? I have some S1, I have F here and then let me say the input symbol remains the same but there is going to be some state which is going to be push state. So let's not worry about what the state would be that we will be coming later but if this configuration has to be a valid configuration in my sentential forms in my grammar then what should this symbol be? Follow of F. Follow of F. So this is precisely what I did. I said that in my parser table the state corresponding to or the row corresponding to j prime which is this state for all symbols which are in so if these are the symbols terminal symbols A1, A2, An I say let me determine what are the symbols which are in follow of F. And for all those symbols I am making 93 which is saying F goes to. So what are this A2 and Ak? So I am assuming here that follow of F is consisting of A2 and Ak. This is just an assumption I am giving some arbitrary sentence. So that we will have a follow set. So I am saying only on those symbols you want to do this reduction. Otherwise if you try to do reduction I will reach a sentential form which is in that. Apart from reduction we had shift and we had go. And only one state had accept state. So let us go back to this example. Now some of it I had already worked out. I had worked out these states 0, 1 and 2 and I asked you to complete this which most of you have not done and you have not done it. Believe me this is not something which is a valid configuration because if you always try to read just in time which is saying that my exam is on 20 first then I will do some study on 20th and everything will work out fine. It does not happen there. I mean you may be in for a good show. So please when I give an assignment there is a purpose. The reason I gave you this assignment and not for submission was. If I had put some weight I am sure you would have done it and you would have been submitting it now. But saying that this does not have a credit and you just have to do this exercise and then you are not doing it. It does not happen. So what I am going to do now is I am going to give you 5 minutes and I want everyone now to take a sheet out of this. Please unspec this and now this will be ready. And it has to be ready. Please go ahead. So please for you I wish you had done it and I will not have to basically 5 minutes. Some of you are not even getting that to. Please note what was not clear. Why it took so long? What was the problem? Constructing the follow set was the problem. Constructing the table was the problem. So again I looked at the question I had in the beginning of the class. Is it that you did not understand it or is it that you did not practice it? What is the problem? What is the problem? Unless it is a problem I do not know how to solve it. Because I do not even know what the problem is. Because I can just move on and I can continue then what is the point of doing all that like thing. Either you are not practicing or you are not understanding. Do it once again. How many of you feel that it should be done all over again? Because if this problem is limited to few people then I can sort of spend extra time with them in doing it. If it is not a problem of the whole class then I can spend time with few of you to have this problem. Everyone feels that it has not been followed then I need to do it again. Do it with this example. Do it with this example. So that is a good idea. Now the plan is taking the old example and then going through it. Let us say this is a grammar. It will also give you sort of a idea of saying how we were understanding of the past tables. So let us take this example. But please at this point of time you do not understand something with the last questions. So what is the first step we had? In the grammar when I start constructing our class there is one important thing that I do. I need to open the grammar. What does augmentation mean? Augmentation means that I add a rule and say that as time goes by the next time is the new start. And the first thing I therefore need to do is once I have augmented this grammar I will start constructing sets of can we have silence please? If you have a problem you either discuss with me or if you discuss with your neighbors then that does not matter to you. So if you have an issue, ask the question. So the first thing we need to do is start constructing all the sets of LRZO items. And the first set of LRZO items is always going to be which I want I0 is going to be a closure of this LRZO. So this is the first production which I added here and when I take closure of this what this says is that if I have seen so now I am again trying to explain you conceptually that I have not seen anything but I am expecting to see a derivation of L. Now when I say I am expecting to see a derivation of L then a derivation of S then what I have are two productions of S. So what will happen here is that I will now say that I am expecting to see either derivation like this or I am expecting to see a derivation like this. Now same thing happens here that I possibly applied this rule and say that I am expecting to see something which is derived from L. So therefore there are two rules here and I say that I am expecting to see either this derivation or I am expecting to see this derivation. And similarly with R I will say that there is only one production of R and therefore I am expecting to see this derivation. And since I have already taken closure of dot L I do not have to write anything more to this. So this is the first set I construct which is coming from the closure of the first LR0 item I have in my grammar which is S prime going to dot S. Now what I have to do is I have to take this thread and say that what are the symbols on which or what are the grammar symbols both terminal and non-terminal on which I can do a transition from I0. So let's look at each of these symbols and create a new state by transiting of that symbol. So if I look at the first symbol first symbol I see is that I can do a transition on S. So if I do a transition on S that says that if I am in state I0 and I do a transition on S that takes me to a new state and a new state corresponds to a viral prefix S. That is where it goes. Now is there any other rule any other LR0 item on which I can do a transition on S. All of them if I try to do a transition on S are going to give me another set first. So nothing gets added and nothing of this type. That I can do a transition on L in I0 so I now say I compute to go to I0 and L and that will call this set as I2. Now what are the rules or what are the LR0 items here on which I can do a transition here. So clearly I can do this condition anything else I can add here. So if I look at this particular LR0 item here also I can do a transition on L. So now I will say that R goes to L0. Now if I try to take closure because this is a terminal symbol there is not going to be any rule corresponding to this therefore I cannot add anything more to this. So that is the problem. Now I say let me again go back to I0 and say what are the other symbols on which I can do a transition. Another symbol I can do a transition on R. So if I try to do a transition on R and let me call it as I2.3 this gives me S going to R0. Anything else I can add here? Nothing. And if I say now that if I will go to all I0 and I do a transition on S start and let me call this as I4. What does this give me? S going to start of R. And now if I take closure of this then I am going to look at all the productions of R here but the production of R here is saying that R going to dot L which comes from here this is not the production of R and now if I say L because of this recursively I will have to take all the rules of L and therefore I say there are only two rules corresponding to L which says that L goes to star R and L goes to IV and I have to dot in the reference position and this I have already given a name to this this is I4. So I could have done this transition what about ID? So I can also do a transition on ID and I say that if I say go to of I0 and ID that is going to give me an item which is L going to ID dot and let me call this as I5 it is not going to give me anything more so again I do now a transition L but L has already been done in this state so I have exhausted I0 so on I0 I cannot do any more transitions on I0 by transiting on various number symbols I can either go to 1, 2, 3, 4, 5 so I have exhausted I0 I move on to I1 can I do transition on any symbol on I1? Nothing what about I2? I can do a transition on this state as a symbol so let me say that on go to of I2 and equal if I do a transition and I call it I6 this gives me S going to L equal dot R and now I have to take a closure that means I look at all the productions of R and R gives me dot L and because of this L I take one more round of modules and I say L goes to R and L goes to ID okay I cannot do any transition on this state okay on this item when I say L goes R goes to L dot there is nothing else I can do only a reduction okay and if I move on from this I2 is gone I3 I cannot do a transition what about I4? I can do a transition on this so now I can compute go to of I4 on R and this computation gives me L going to star R only symbols R is on the right of dot and if I now take closure nothing else comes okay so I stop now if I try to do go to of I4 so let me call this as I7 now if I try to compute go to of I4 on L what does that give me R going to L dot R going to L dot R going to L dot where is that I2 why does it become I2 something interesting I do why is it I2 inside equivalence when you say whether two sets are equal or not you have to compare all the elements it's not a subset all the full set okay so if I do this this is going to give me R going to L dot does this exist anywhere does not let me call it as I8 and then I can do a transition on star so if I now do a go to of I4 on star what does that give me that is I4 okay so nothing new gets added I just add that this is I4 and if I now say that go to of I4 on ID what is that I5 so that gives me I5 so you can see that I am already sort of close to convergence I am not adding any more states to this I5 I cannot do any transition what about I6 so in I6 if I do a transition on R so let's say go to of I6 and a transition on R what does that give me so let's go to as that we can do that already no so that is going to be S going to L equal R dot and let me call this as I9 okay now you can see that there is no other rule on which I can do a transition on R this is only R0 I can get added there is nothing on the right of top so closure does not give me any more I have finished here now if I say I compute for the remaining items when I say I am not trying to compute go to of I6 on L what does that give me that gives me R going to L dot and what is that I8 this I8 and if I now say in I6 I do a transition on R so if I say go to of I6 on star what does that give me very good and then if I do a transition on I6 on ID can I say go to of I6 on ID in that must be already present somewhere I5 I6 is exhausted I cannot do transition here I cannot do transition here I cannot add any more space okay how to construct the pass table what is it that we need to do we need to have all the symbols and all the states and we can say so what are the terminal symbols I have ID star and equal so I have ID equal star and all of the top courses special symbol any other terminal symbol I have here okay so this is really going to be the action part and what is the go-to part go-to part is going to be any other terminal I have here that's it okay and how many states do I have ten states index from 0 to 9 these are the states I have okay so this is really my go-to part of the table and this is the action part sorry s prime s prime is not taken here there is no need because this reduction is only giving me an accept state I cannot do a transition on s prime is there any state in which I can do a transition on s prime that is unique start symbol it doesn't occur anywhere on the right hand side so I cannot do a transition okay so you can clearly see that in state 1 if I see dollar then I accept so state 1 dollar is is the what are the rules we have for construction of the parts table the rules for construction work that if I am in some state and I do a transition on a terminal symbol and I go to a new state then the empty is going to be shift and then go to the new state okay so for example here if I see this in 0 if I see start I am going to 4 and therefore what I do here I will say shift and go to 4 okay so in 0 if I say start this is empty corresponding to shift 4 okay and if I am in 0 and I see id then I say shift and go to state 5 okay so in id I will say shift 5 okay and in 0 if I see s then I will go to state 1 so that gives me an empty then go to part which is 1 and if I am in state 0 and I see l that takes me to 2 and if I am in state 0 and I see r then I go to state 3 okay in state 1 in state 0 is there any reduction which is possible is there any rule in which dot is in the right post position so row 0 will not have any reduced action right row corresponding to this is going to have only one empty and that empty is going to be accept state on the symbol which is in follow of s prime which is dollar so that is what I have put there accept okay now before you can make reduced entries you also need to compute the follow set okay now I am not going to do that computation for you you just try to do that computation I have shown you for one let's go to this particular state so when I try to construct the row 2 or row number 3 of this table this days if I see equal okay so in i2 so look at i2 equal i2 equal will take me to state 6 right so if I am in i2 and I see equal and go to state 6 okay but now this 2 has also a reduction empty okay when I try to do reduction empty I have to know what are the follow symbols of r and corresponding to 2 and the symbols that are in follow set of r I will say reduced by this rule and let's say this rule if I start something from here this is 1, 2, 3, 4 and so this is row number 6 right if I say this is 1, 2, 3, 4, 5 and 6 I will do this reduction by rule number 6 on symbols which are in follow of r now let's find out what are the symbols in follow of r okay so what is the symbol which is in follow of r look at the number I tell you so if I say S prime goes to S okay and r goes to L okay then L goes to ID okay so you have to get these strings where somewhere you can have a symbol which is on right of r some sentential form okay and equal is definitely one of those because you can see that if I have L here then corresponding to this I can say L goes to star r I can replace this and then equal will be in follow of r therefore in state 2 I will do a reduction by this rule and let's say that this rule I am calling is what is this rule I am going to add up I am reducing by this rule okay and now I have a problem and what is the problem I have multiple entries in my pass table and there is a shift reduce quantity okay now beyond this point you go ahead and construct rest of the entries okay at least if you have understood how to get all the LR0 items then reduction entries is going to be a similar exercise to what we did okay but if I want to move forward okay I get into this place and say that I have a shift reduce quantity okay now when I say I have a shift reduce quantity what does that mean what that means is that either my language is ambiguous and therefore I am not able to construct an LR parser for that or I say that this method is not powerful enough so is not in the class this grammar is not in the class SLR okay so let's try to figure out that what is going on okay so let me keep this item for you okay let's take a string in this let the string be ID equal to ID now first let's find out whether this is a valid string in the language I have okay so I can start derivation from here which says S prime goes to where S goes to L assign R and then go to ID here so ID can come there is no position and R can go to L and L can go to ID so there is a valid string in the language I have right now suppose I try to do a shift reduce parsing on this okay what will happen in shift reduce parser to begin with my what will be in this position okay so what is in this position what will possibly happen I will do a shift I will do a shift okay now once I have reached here what is it that I can do with ID the only thing I can do with ID is I can convert this into L okay so I do a reduce action there and a reduce action gives me a configuration of shift reduce parser which is this you can see that L sign ID is valid sentential form in the language I have okay now from this point onwards what happens is now we have reached actually this situation I am in this state here I am saying that if I am in this state I can either shift or I can reduce okay now suppose I take option of reducing here okay because equal is in for of L equal is in for of R and therefore L is a handle and I can do this reduction and that is going to give me a configuration which is instead of reduce I have taken a shift action because these are the options I have okay so let me simultaneously take the shift action and let me erase this part okay so if I now shift this gives me a form which is ID equal to L okay now when I say that I have done a reduction here what is the next thing I can do now you can see that here R is the right hand side of the production but if I do this reduction that takes me to S and from S it goes to S prime okay and that will lead to an error in a state so only thing I can do there is after this particular thing I can only do a shift but interesting thing is no matter what you do we are going to get to a wrong state wrong state means it is going to say that your input is in there yeah sir you could reduce this in the starting only when the I8 we are not in this in the state I8 in the state I8 sir if it is a subset of I2 then we can say so what does it mean it is a subset of I2 last time we discussed they can name one of the techniques because they have to be equal so all the states when I say I have a set of LR view items I2 is a set of LR view items I2 and I8 are not the same set of LR view items these are different sets so what then sir this means there is contact come so that is what is coming out that you have a conflict there yeah so we do not need to go we can just induce it over there oh so you are saying that from here I can conclude that I go without constructing tables that I have I should produce conflict yes so that does not give me anything we I8 are not able to pass this grammar through this method now I think you are jumping because when you say it is not possible it is also possible that your grammar has not been written properly and therefore if I change the form of the grammar then it is passable with SLR right so I am saying that two possibilities one possibility is that the grammar is in a form which is not in SLR or we say grammar as such does not matter the grammar form you write for this language that means you will never be able to pass with SLR this form of the grammar this form of the grammar right so what I am arguing here is I am saying that there is when I do a reduce action here I am actually doing a wrong reduce action I should have done a shift because this is not a grammar which is ambiguous this is an ambiguous language and that is what I am trying to show here and therefore I am saying that SLR passing method is a problem and not the form of the grammar if I say my language is an ambiguous then I can have some LR parser for this and therefore we are saying language is ambiguous but SLR parser is not powerful enough if I say language parser is ambiguous then it does not matter what LR passing technique you have it will not work this point here so what happens here is that instead of reduce if I had done shift I would have continued and I would have reached the start symbol so what is the problem I am going to continue with the resumes now look at all possible sentential forms and see that is there a possibility of some sentential form in this language which starts from R and you come up with a sentential form which is derived from S' and which starts in R from the beginning followed by equal although I d assigned I d is a valid string but this is giving me a sentential form which is saying that somewhere therefore R equal L should be valid sentential form with this parsing method what I have got so do I have a valid sentential form like R equal L in this language then I derive our R equal L starting with R that means the problem is the matter because this review section is wrong because it is leading to an indirect sentential form whereas shift will take me to all the right sentential forms and I know that this grammar is this particular matter when I say reduction is happening that is giving me wrong sentential form if I have taken a shift that would have worked so that means in this state this review section should not have happened when I say that I am reducing here I am reducing here this reduction should not have been there because this reduction takes me to a state which is giving me a non sentential form or invalid sentential form if I somehow can eliminate this review section from here and my job is done right so let's take a break here today and in the next class we will do it from this point onwards and we will try to see that how do we make it work out as I said this is the least powerful allowed parsing method we have