 Hello everyone, I am Mrs. Sunitha Dore. Topic covered here is error recovery in operator precedence passing. In previous video, we considered operator precedence grammar, how to handle unary operator and precedence function. In this video, we are going to consider an error recovery in operator precedence passing. Passing outcome, at the end of the session, students will be able to identify the syntactic error and handle errors during reduction and shift reduce error. There are two points in the parsing process at which an operator precedence passer can discover syntactic error. First, no relation holds between the terminal on the top of the stack and the next input symbol. And second, a handle is found, but there is no production with this handle as right side. Error recovery, each empty entry is filled with a pointer to an error routine and decide the pop handle looks like which right hand side and tries to recover from that situation. The operator precedence passing algorithm reduce handles composed of terminus only. However, while non-terminus are treated anonymously, they still have places held for them on the parsing stack. In type 2 above about a handle matching a production right side, the terminus are the same and the position occupied by the non-terminus are the same. For errors of type 2 as there is no production to reduce by no semantic action are taken instead a diagnostic message is printed. To determine what the diagnostic should say, the routine handling case 2 must decide what production the right side being pop looks like. Example, suppose ABC is pop and there is no production right side consisting of ABC together with zero or more non-terminus. Then we might consider if deletion of one of A, B and C yields a legal right side. For example, if there were a right side capital E, C, capital E, we might issue the diagnostic illegal B online. It might also consider changing or inserting a terminal thus if A, B, capital E, D, C were a right side, we issue the diagnostic missing D online. We may also find that there is a right side with the proper sequence of terminus but there is a wrong pattern of non-terminal. If ABC is pop of the stack with no intervening W surrounding non-terminus and ABC is not right side but A, capital E, B, C is we might issue a diagnostic missing E online. In general, the difficulty of determining appropriate diagnostic when no legal right side is found depends on whether there are a finite or infinite number of possible strings. Any such string B1, B2 up to BK must have has equal precedence as relation holding between the adjacent symbols. So B1 has equal precedence as B2, has equal precedence as and so on up to has equal precedence as BK. If the operator precedence table tell us that there are only a finite number of sequences of terminus related by has equal precedence relation then we can handle these strings on a case by case basis. It is easy to determine all the strings that could be pop from the stack. These are evident in the directed graph whose nodes represent the terminus with an edge from A to B if and only if A has equal precedence as B. Then the possible strings are the levels of the nodes along the path in this graph. Path consisting of a single nodes are also possible. However in order for a path B1, B2 up to BK to be poppable on some input there must be a symbol A such that A yields precedence to B1 and there must be a symbol C which is possibly dollar such that BK takes precedence over C called BK as final only then could a reduction be called for and the B1, B2 up to BK be the sequence of symbols pop. If the graph has a path from an initial to final node containing a cycle then there are an infinity of strings that might be pop otherwise there are only a finite number. Here the grammar e derives e plus e or e minus e or e into e or e division e or e exponentiation e or in parenthesis e or unary minus e or id and the operator precedence relation table for this grammar. In the graph there is only one edge because the only pair related by has equal precedence as is the left parenthesis and the right parenthesis. All but right parenthesis are initial and all but left parenthesis are final thus the only path from an initial to a final node are the paths plus minus multiplication, division, id and the exponentiation of length 1 and each path from of length 2. There are but a finite number and each corresponds to the terminal of some productions right side in the grammar thus the error checker for reduction need only check that the proper set of non-terminal markers appear among the terminal strings being reduced. Specifically the checker does the following e plus minus multiplication division or the exponentiation is reduced then there should be the non-terminal on both side. If not then issue the diagnostic missing operand. If d is reduced it checks is there any non-terminal to the right or the left if there is then it can warn missing operand. If left parenthesis right parenthesis is reduced it check that there is a non-terminal between the parenthesis if not it can say no expression between parenthesis also it must check that no non-terminals appears on either side of parenthesis if non-terminal occurs then it issue the same diagnostic missing operand. When consulting the precedence matrix to decide whether to shift or reduce we may find that no relation holds between the top stack and the first input symbol. So, to recover we must modify stack or input or both. We may change the symbol insert the symbol onto the input or the stack or delete the symbols from the input or stack. If we insert or change we must be careful that we do not get into infinite loop. Example consider the precedence matrix in this table we show the rows and the columns of the matrix that have one or more blank entries and we have filled in this blank with the names of the error handling routines. Even is called when the whole expression is missing. So, in this case insert id onto the input and issue diagnostic missing operand. E2 is called when expression begins with the right parenthesis. So, delete right parenthesis from the input and issue diagnostic unbalanced right parenthesis. Consider the same example E3 is called when id or right parenthesis is followed by id or left parenthesis. It means there is no operator so insert plus onto the input and issue diagnostic missing operator. E4 is called when the expression ends with a left parenthesis. So, in this case pop left parenthesis from the stack and issue diagnostic missing right parenthesis. So, till now we consider an error recovery in operator precedence passing. Now pause this video and reflect on this question for a minute or two minute and write your response. Once you return the answer to this question then you can restart playing this video. The question is identify the errors in the following operator precedence relation table. I hope all of you have completed this activity. Here even is called when the whole expression is missing it means there is no input. So, insert id onto the input and issue diagnostic missing operand. E3 is called when the id or the right parenthesis is followed by id or left parenthesis. That means there is no operator so insert plus onto the input and issue diagnostic missing operator. This is the reference used for preparing this presentation. Thank you.