 Hello everyone, I am Mrs. Sunitha Doh topic covered here is operator precedence passing precedence function. In previous video we consider operator precedence grammar which is a kind of shift reduce passing method. In this video we are going to consider how to handle the unary operator and precedence function learning outcomes at the end of the session students will be able to handle the unary operator and find the precedence function for given operator precedence relation. Let logical negation to be a unary prefix operator which is not binary then with the help of the operator precedence relation we make theta ill precedence to logical negation for any operator theta whether it is unary or binary. Logical negation takes precedence over theta if logical negation has higher precedence than theta. Logical negation ill precedence to theta if logical negation has lower precedence than theta. Example, if logical negation has higher precedence than ampersand and ampersand is left associative then group the expression e ampersand logical negation e ampersand e as left parenthesis e ampersand left parenthesis logical negation e complete both the parenthesis ampersand e by above rule. Operator precedence passing cannot handle the minus sign that is both unary prefix and binary prefix. Because if we give unary and binary minus the same precedence then we will fail to pass the string like id into minus id correctly. The best approach to solve this problem let the lexical analyzer handle this problem. The lexical analyzer will return two different token for the unary minus and the binary minus. The lexical analyzer will need a look ahead to distinguish the binary minus from the unary minus. Compilers using the operator precedence passer need not store the table of precedence relation. The table can be encoded by the two precedence function f and g that map terminal symbols to integer. We attain the function f and g for the symbol a and b f of a less than g of b whenever a ill precedence to b f of a is equal to g of b whenever a has the same precedence as b and f of a greater than g of b whenever a takes precedence over b. Another algorithm constructing precedence function input and operator precedence matrix output precedence function representing the input matrix or an indication that none exist. Method step one create symbol f a and g a for each a that is a terminal or dollar. Step two partition the created symbols into as many group as possible in such a way that if a has the same precedence as b then f a and g b are in the same group. We may have to put the symbols in the same group even if they are not related by has the same precedence as relation. For example if a has the same precedence as b and c has the same precedence as b then f a and f c must be in the same group since they are both in the same group as g b. Step three create a directed graph whose nodes are in the groups for each symbol if a yield precedence to b then place an edge from the group of g b to the group of f a. If a take precedence over b then place an edge from the group of f a to that of the g b and h or the path from f a to g b means f a must exceed g of b a path from g b to f a means g of b must exceed f of a. Step four if the constructed graph has a cycle then no precedence function exist when there are no cycles then collect the length of longest path from the group of f a and g b respectively. Consider the example e derives e plus e e into e or id and the operator precedence relation table. Consider the nodes for the function f and g of every symbol id plus multiplication and dollar. Consider first row of the operator precedence relation table there is no relation between f id and g id hence there will be no arc between f id and g id. The relation between f id and g plus is take precedence over. So, there will be an arc from the f id to g plus. The relation between f id and g star is take precedence over. So, there will be an arc from f id to g star. The relation between f id and the g dollar is take precedence over. So, there will be an arc from f id to g dollar. Now, consider the second row of the operator precedence table. The relation between F plus and the GID is ill precedence 2. So, there will be an arc from GID to F plus. The relation between F plus and the G plus is take precedence over. So, there will be an arc from F plus to G plus. The relation between F plus and G star is ill precedence 2. So, there will be an arc from G star to F plus. The relation between F plus and G dollar is take precedence over. So, there will be an arc from the F plus to G dollar. Now, consider the third row in operator precedence relation table. The relation between F star and GID is ill precedence 2. So, there will be an arc from the GID to F star. The relation between F star and G plus is take precedence over. So, there will be an arc from the F star to G plus. The relation between F star and G star is take precedence over. So, there will be an arc from the F star to G star. The relation between F star and the G dollar is take precedence over. So, there will be an arc from the F star to G dollar. Consider the fourth row in the operator precedence relation table. The relation between F dollar and GID is ill precedence 2. So, there will be an arc from GID to F dollar. The relation between F dollar and G plus is ill precedence 2. So, there will be an arc from the G plus to F dollar. The relation between F dollar and G star is ill precedence 2. So, there will be an arc from the G star to F dollar. The relation there is no relation between F dollar and G dollar. Hence, no arc will be there between F dollar and the G dollar. Now, consider how to obtain the entries in the matrix. The length of the longest path from FID to F dollar is shown here. So, the entry for F on ID in the matrix is 4. The length of the longest path from the GID to F dollar is from GID to F star, from F star to G star, from G star to F plus, from F plus to G plus and from G plus to F dollar. So, the entry for G on ID in the matrix is 5. The length of the longest path from the F plus to F dollar is shown on this slide. So, the entry for G on ID in the matrix is 2. The length of the longest path from the G plus to F dollar is from G plus to F dollar. Hence, the entry for G on ID in the matrix is 1. The length of the longest path from F star to F dollar is given in the figure on this slide. Therefore, the entry for G on ID in the matrix is 4. The length of the longest path from G star to F dollar is from G star to F plus, from F plus to G plus and from G plus to F dollar. So, here the entry for G on ID is 3. There is no relation between F dollar and G dollar. Hence, the entry for F on dollar in the matrix is 0. Also, the entry for G on the dollar in the matrix is 0. Till now, we consider how to handle unary operator and constructing the constructing precedence function algorithm. Now, pause this video and reflect on this question for a minute or 2 minute and write your response. Once you have written the answer to this question, then you can restart playing this video. The question is, find the precedence function for the following operator precedence relation. I hope all of you have completed this activity. Consider the node for the function F and G of every symbol ID plus star and the dollar. Now, the first row in the operator precedence relation table and according to the entry in each cell enter the arc in the graph. Similarly, second row, third row, fourth row. Also, the entries in the matrix are given on this slide. This is the reference used for preparing this presentation. Thank you.