Question 3. S. → AB. B. → cD. D → aACD | є. A. → Ca | є
Added on -2019-09-18
| 4 pages
| 530 words
| 477 views
Trusted by 2+ million users, 1000+ happy students everyday
Showing pages 1 to 2 of 4 pages
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
Found this document preview useful?
You are reading a preview Upload your documents to download or Become a Desklib member to get accesss