 Hello everyone, I am Mrs. Sunita Dole. Topic covered here is follow set. In previous video, we consider how to compute first set for a given grammar to construct the passing table and now in this video we are going to consider how to compute follow set which is also used to construct the passing table. Learning outcome. At the end of the session, students will be able to compute the follow set for a given grammar. We know that the construction of the predictive passing table requires two functions first and the follow set. The set of tokens yielded by the follow function can also be used as a synchronizing tokens during panic mode error recovery. For non-terminal capital A, follow of capital A is to be the set of terminals small a that can appear immediately to the right of capital A in some sentential form. If capital A can be the rightmost symbol in some sentential form, then add dollar in follow of capital A. To compute the follow of capital A for all non-terminal capital A, apply following rule until nothing can be added to any follow set. Rule number one, place dollar in the follow of capital S where capital S is the start symbol and dollar is the input right end marker. Rule number two, if there is a production capital A derives alpha capital B beta, then everything in the first of beta except for the epsilon is placed in the follow of capital B. Rule number three, if there is a production capital A derives alpha capital B or production capital E derives alpha capital B beta where first of beta contains epsilon, then everything in the follow of capital E is in follow of capital B. Consider the first grammar with the production for arithmetic expression, capital E derives capital T E dash, capital E dash derives plus capital T E dash or epsilon, capital T derives capital F T dash, capital T dash derives star capital F T dash or epsilon and capital F derives in parenthesis capital E or I D. First set for this grammar is given on this PPD. We put dollar in the follow of capital E by rule one for the follow set. By rule two applied to the production capital F derives in parenthesis capital E, the right parenthesis is also in the follow of capital E. By rule three applied to the production capital E derives capital T E dash, dollar and the right parenthesis are in the follow of capital E dash. Hence the follow of capital E equals to follow of capital E dash equals to right parenthesis and dollar. Since in capital E derives capital T E dash, E dash derives epsilon hence by rule two everything other than epsilon in the first of capital E dash must be placed in the follow of capital T. Hence follow of capital T is plus right parenthesis and dollar. By rule three applied to production capital T derives capital F T dash plus right parenthesis and the dollar are in the follow of capital T dash. Hence the follow of capital T equals to follow of capital T dash equals to plus right parenthesis and the dollar. Since in capital T dash derives star capital F T dash, capital T dash derives epsilon hence by rule two everything other than epsilon in first of capital T dash must be placed in the follow of capital F. So by rule three applied to the production capital T dash derives star capital F T dash as the first of capital T dash derives epsilon, follow of capital T dash will be in the follow of capital F. Hence the follow of capital F equals to plus multiplication, right parenthesis and the dollar. Here the second grammar for dangling if with the production given on the slide. So the productions are capital S derives small i capital E small t capital S S dash or small a that is on the right side of the production small i means if capital E means expression small t means then and the capital S means statement while S dash means statement dash. So capital S derives if expression then statement as statement dash or small e capital S dash derives small e capital S or epsilon that is capital S dash derives a statement or epsilon and capital E derives small b. First set for this grammar is already computed in the previous video and is given on this slide. We put dollar in the follow of capital S by rule one for follow set. Since in capital S derives small i capital E small t capital S S dash capital S dash derives epsilon hence by rule two everything other than epsilon in the first of capital S dash must be placed in the follow of capital S. Hence the follow of capital S is small e comma dollar by rule three applied to the production capital S derives small i capital E small t capital S S dash small e and the dollar are also in the follow of capital S dash. Hence the follow of capital S is equal to follow of capital S dash is equal to small e comma dollar. To compute the follow of capital E consider the production capital S derives small i capital E small t capital S S dash. Now by applying the rule two first of small t will be in the follow of capital E. Hence the follow of capital E is equal to small t. Consider the third grammar with the production capital S derives capital A small a capital A small b or capital B small b capital B small a then capital E derives epsilon and capital B derives epsilon. First set for this grammar which is computed in the previous video is given on the slide. We put dollar in the follow of capital S by rule one for the follow set. Hence the follow of capital S is dollar. To compute follow of capital A consider the production capital S derives capital A small a capital A small b. By applying rule two first of small a and the first of small b will be in the follow of capital A. Hence the follow of capital A is equal to small a and the small b. Similarly follow of capital B is small a and small b. Till now we consider how to compute follow set for non-terminal. Now pause this video and reflect on this question for a minute or two minutes and write your response. Once you return the answer to this question then you can restart playing this video. The question is compute follow set for the following grammar capital S derives capital C C capital C derives small c capital C or small d. I hope all of you have completed this activity. So the question was compute follow set for the following grammar. First set for this grammar is given on the slide which is already computed in the previous video. So first of capital S equals to small c, small d and first of capital C is small c, small d. We put dollar in the follow of capital S by rule one for the follow set. Hence the follow of capital S is dollar. In production capital S derives capital C C. Follow of first capital C contains first of second capital C except epsilon by rule 2 where the first of second capital C is small c, small d. Hence the follow of first capital C equals to small c, small d. Also using rule 3 follow of capital S will be in the follow of second capital C as second capital C is the right most non-terminal on the right side of the production. Hence the follow of capital C equals to small c, small d, dollar. This is the reference used for preparing this presentation. Thank you.