logo

Desklib - Online Library for Study Material with Solved Assignments, Essays, Dissertation

4 Pages530 Words469 Views
   

Added on  2019-09-18

About This Document

Desklib is an online library for study material with solved assignments, essays, dissertation, and more. Get access to a wide range of study materials for various subjects and courses.

Desklib - Online Library for Study Material with Solved Assignments, Essays, Dissertation

   Added on 2019-09-18

ShareRelated Documents
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.
Desklib - Online Library for Study Material with Solved Assignments, Essays, Dissertation_1
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
Desklib - Online Library for Study Material with Solved Assignments, Essays, Dissertation_2

End of preview

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

Related Documents
Compiler Construction: Context-Free Grammars and Top-Down Parsing
|2
|750
|282

Compiler Construction | Assignment
|3
|1049
|585

Concepts of Programming Language
|15
|1712
|339