# Parsing Grammar Analysis

4 Pages530 Words469 Views
|
|
|
Question 31.S → AB B → cD D → aACD | є A → Ca | є C → b | є2.FIRST SETSFIRST(A) = { a, b, є }FIRST(B) = { c }FIRST(C) = { b, є }FIRST(D) = { a, є }FIRST(S) = { a, b, c }FIRST(a) = { a }FIRST(b) = { b }FIRST(c) = { c }FOLLOW SETSFOLLOW(A) = { \$, a, b, c }FOLLOW(B) = { \$ }FOLLOW(C) = { \$, a }FOLLOW(D) = { \$ }FOLLOW(S) = { \$ }3.The given grammar is not LL(1).There are two ways to check for this:1. It can be checked by either making the parsing table and the parsing table is givenas :Non terminalsTerminalsabc\$AA → є, A→CaA → є, A→CaA → єA → єBB→cDCC→ єC→ єC→ єDD→aACDD→ єSS→ABS→ABS→ABAs the parsing table contains more than one production rule in one table entry this grammar is not LL(1) grammar.
2.Also using the definition of LL(1) grammar it can be seen that First(Ca) ∩ First(є) ≠ Ø and alsoFirst(A) ∩ Follow(A) ≠ Ø ,so this grammar is not LL(1) grammar.4.To show the parse tree step by step the parsing will be first show and then the parse tree will be drawn till there is no error.MatchedStackInputActionsS\$AB\$bacbacUse the production rule SAB from parsing table and push in stackNow the parsing table contains twoproduction rules for M[A,b] so thiswill be an error and parsing stopsThe Parse tree will be :Question 41.Expr = E, Term = T, Factor = F, num = n, ident = i, ExprList = ELE → T | EE’E’ → +T | -TT → F | TF’F’ → *F | /F

## End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents

### Support

#### +1 306 205-2269

Chat with our experts. we are online and ready to help.