SlideShare a Scribd company logo
1 of 1
ITM UNIVERSITY                         REVIEW DATE: 5th Jan’12
              School/ Department: Department of CSE                    Tutorial Sheet No.5
              Subject Name      :Principles of Compiler Design         Issue Date:    Pages:
              Subject Code      : CSL 306
                                                                       Faculty :     Semester:
              Unit/Title: LR Parsers                                   Niharika      6th
                                                                       Garg

Q1. Explain in detail LR Parsers.

Q2. Explain the algorithm for the construction of SLR parsing table.

Q3. Construct SLR parser table for grammar:
      E’ E
      E E + T/T
      T T * F/F
      F (E)/id
      Is the Grammar ambiguous? Give reasons.

Q4.Write LR Parsing algorithm? Construct LR parsing table for the grammar:
      E E+T
      E T
      T T * F
      T F
      f (E)
      T id

Q5. Following is an LL(1) grammar for regular expression over alphabet {a,b} with +
standing for union operator (1) and E for symbol €.
       E TE’
       E’+E/€
       TFT’
       T’ T/€
       F PF’
       F’ *F’/€
       P (E)/a/b/€
   (a) Compute FIRST and FOLLOW for each non-terminal of above grammar.
   (b) Show that grammar is LL (1).
   (c) Construct the predictive parsing table for grammar.
   (d) Construct a recursive descent parser for the grammar.

More Related Content

Similar to Tut 5

Ch3_Syntax Analysis.pptx
Ch3_Syntax Analysis.pptxCh3_Syntax Analysis.pptx
Ch3_Syntax Analysis.pptxTameneTamire
 
Lec4slides
Lec4slidesLec4slides
Lec4slidesshawiz
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Examshishamrizvi
 
Linked List Problems
Linked List ProblemsLinked List Problems
Linked List ProblemsSriram Raj
 
SET Software Engineering Thailand Meeting: Functional Programming with Scala ...
SET Software Engineering Thailand Meeting: Functional Programming with Scala ...SET Software Engineering Thailand Meeting: Functional Programming with Scala ...
SET Software Engineering Thailand Meeting: Functional Programming with Scala ...Prof. Dr. Roland Petrasch
 

Similar to Tut 5 (8)

Ch3_Syntax Analysis.pptx
Ch3_Syntax Analysis.pptxCh3_Syntax Analysis.pptx
Ch3_Syntax Analysis.pptx
 
PARCC-ELA
PARCC-ELAPARCC-ELA
PARCC-ELA
 
Lec4slides
Lec4slidesLec4slides
Lec4slides
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
 
Linked List Problems
Linked List ProblemsLinked List Problems
Linked List Problems
 
SET Software Engineering Thailand Meeting: Functional Programming with Scala ...
SET Software Engineering Thailand Meeting: Functional Programming with Scala ...SET Software Engineering Thailand Meeting: Functional Programming with Scala ...
SET Software Engineering Thailand Meeting: Functional Programming with Scala ...
 
Syllabus
SyllabusSyllabus
Syllabus
 
F# for Scala developers
F# for Scala developersF# for Scala developers
F# for Scala developers
 

Tut 5

  • 1. ITM UNIVERSITY REVIEW DATE: 5th Jan’12 School/ Department: Department of CSE Tutorial Sheet No.5 Subject Name :Principles of Compiler Design Issue Date: Pages: Subject Code : CSL 306 Faculty : Semester: Unit/Title: LR Parsers Niharika 6th Garg Q1. Explain in detail LR Parsers. Q2. Explain the algorithm for the construction of SLR parsing table. Q3. Construct SLR parser table for grammar: E’ E E E + T/T T T * F/F F (E)/id Is the Grammar ambiguous? Give reasons. Q4.Write LR Parsing algorithm? Construct LR parsing table for the grammar: E E+T E T T T * F T F f (E) T id Q5. Following is an LL(1) grammar for regular expression over alphabet {a,b} with + standing for union operator (1) and E for symbol €. E TE’ E’+E/€ TFT’ T’ T/€ F PF’ F’ *F’/€ P (E)/a/b/€ (a) Compute FIRST and FOLLOW for each non-terminal of above grammar. (b) Show that grammar is LL (1). (c) Construct the predictive parsing table for grammar. (d) Construct a recursive descent parser for the grammar.