Limited-time offer! Save up to 50% Off | Solutions starting at \$6 each

# Question 3. S. → AB. B. → cD. D → aACD | є. A. → Ca | є

Added on - 18 Sep 2019

Showing pages 1 to 2 of 4 pages
Question 31.S→ ABB→ cDD → 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 entrythis grammar is not LL(1) grammar.
2.Also using the definition of LL(1) grammar it can be seen thatFirst(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 parsetree will be drawn till there is no error.MatchedStackInputActionsS\$AB\$bacbacUse theproduction ruleSAB fromparsing table andpush in stackNow the parsingtable contains twoproduction rulesfor M[A,b] so thiswill be an errorand 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  