 Hello everyone, I am Mrs. Sunita Do, topic covered here is LL1 grammar and error recovery in predictive passing. In previous video, we consider how to construct the predictive passing table for given grammar using first and the follow set. In this video, we are going to cover what do you mean by LL1 grammar and how to recover from error in predictive passing. At the end of the session, students will be able to identify LL1 grammar and recover from error in predictive passing. What do you mean by LL1 grammar? Consider the grammar for arithmetic expression with the productions 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 id. First end the follow set for this grammar and the passing table. Here the passing table has no multiply defined entries, hence this grammar is LL1. A grammar whose passing table has no multiply defined entries is said to be LL1. The first L in the LL1 stands for scanning the input from left to right, the second L for producing a leftmost derivation and the one for using one input symbol of look ahead at E step to make passing action decision. Second example, consider the grammar for dangling with the production capital S derives small i capital E small t capital S s dash or small a then capital S dash derives small e capital S or epsilon and capital E derives small b. First end the follow set for this grammar and the passing table. Here the passing table has multiply defined entries, hence this grammar is not LL1. The entry for M of capital S dash comma small e contains both capital S dash derives small e capital S and capital S dash derives epsilon, since the follow of capital S dash equals to small e comma dollar. This grammar is ambiguous and the ambiguity is manifested by a choice in what production to use when and E that is else is seen. We can resolve the ambiguity if we choose the capital S dash derives small e capital S. This choice corresponds to associating S with the closest previous then. A grammar G is LL1 if and only if whenever capital A denies alpha or beta are two distinct productions of G then the following conditions hold. Condition 1 for no terminal small a do both alpha and the beta derive the string beginning with small a that is first of alpha intersection first of beta equals to phi. Condition 2 at most one of the alpha and the beta can derive the empty string. Condition 3 if the beta derives epsilon in 0 or more steps then alpha does not derive any string beginning with a terminal in the follow of capital A that is first of alpha intersection follow of capital A equals to phi. Consider the example of the LL1 grammar consider the grammar capital S derives capital A small a capital A small b or capital B small b capital B small a then capital A derives epsilon and capital B derives epsilon. First and the follow set for this grammar here first of capital A small a capital A small b that is small a intersection first of capital B small b capital B small a that is small b equals to phi. The condition of LL1 grammar is satisfied and even the passing table for this grammar does not contain multiply defined entries as this grammar is LL1. Consider second example of the LL1 grammar consider the grammar capital S derives small i capital E small t capital S S dash or small a capital S dash derives small e capital S or epsilon and capital E derives small b first and follow set. Now here first of small i capital E small t capital S S dash that is small i intersection first of small e that is small e equals to phi then first of small e capital S that is small e intersection first of epsilon that is epsilon equals to phi first of small e capital S intersection follow of capital S dash should be phi but the first of small e capital S that is small e intersection follow of capital S dash that is small e and the dollar equals to small e which is not equals to phi. So, the condition of the LL1 grammar are not satisfied and even the passing table for this grammar contain multiply defined entries hence this grammar is not LL1 till now we consider what we mean by LL1 grammar. 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 check the following grammar for LL1 capital S derives capital CC capital C derives small c capital C or small d. I hope all of you have completed this activity. So, the question was check the grammar for LL1 consider the grammar first and the follow set. First of small c capital C that is small c intersection first of small d that is small d equals to phi. The condition of LL1 grammar is satisfied and also the passing table does not have multiply defined entries hence this grammar is LL1. The stack of a non-recursive predictive parser makes explicit terminals and a non-terminals that parser matches with the remainder of the input and error is detected during the predictive parsing when the terminal on the top of the stack does not match the next input symbol and when the non-terminal capital E is on the top of the stack small e is the next input symbol and the passing table entry m of capital E small e is empty. There are two error recovery techniques panic mode recovery and phrase level recovery. Consider the first technique that is the panic mode recovery. Panic mode recovery is based on the idea of skipping the symbols on the input until a token in the selected set of synchronizing tokens appear. In panic mode recovery we use the follow symbols as a synchronizing tokens and use sync in the predictive parsing table to indicate the synchronizing token obtained from the follow set of the non-terminal rules. Rule 1 if the parser looks up entry m of capital E small e and find it blank then the input symbol small e is skipped. Rule 2 if the entry is synced then the non-terminal on the top of the stack is popped in an attempt to resume parsing. Rule number 3 if a token on the top of the stack does not match the input symbol then we pop the token from the stack. Error recovery example consider the grammar for the arithmetic expression first and the follow set and the parsing table with sync entry to indicate that synchronizing tokens are obtained from the follow set of the non-terminals. On the error nearest input write parenthesis id star plus id the parser and the error recovery mechanism is shown in the table. In this table in row number 1 first input symbol is write parenthesis. So, this is error in the input hence skip this symbol. In the second row the input is id and the stack contains capital E. So, in the parsing table capital E in the row and id in the column the entry is capital E derives capital TE dash. So, enter E dash onto E dash T onto the stack as shown in the row number 3. In this way continue scanning input checking the stack contain and checking it in the parsing table. So, we will get the row number 17 where we can see that the error nearest input is successfully accepted by the parser. Second error recovery mechanism that is the phrase level recovery. So, this phrase level recovery is implemented by filling in blank entries in the predictive parsing table with pointers to the error routine. These routine may change insert or delete symbols on the input and issue appropriate error messages. This is the reference used for preparing this presentation. Thank you.