We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

Looking For Something at vustudents.ning.com? Click Here to Search

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More


Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion

How to Add New Discussion in Study Group ? Step By Step Guide Click Here.

Objective:

 

To learn and understand the concepts of LR(1) parsers, canonical collections and shift/reduce conflicts.

 

 

Lectures Covered: 22-30                                                     

 

 

Instructions:

 

Please read the following instructions carefully before submitting assignment:

 

  • You will submit your assignment before or on due date on VU-LMS.
  • Assignment should be completed by your own efforts it should not be copied from internet, handouts or books.
  • You should submit your solution in Word File only via assignment interface at VU-LMS.
  • Assignment sent via Email will not be replied and accepted/graded in any case.
  • If the submitted assignment does not open or file is corrupt, it will not be graded.

 

 

Question No 1:                                                                                                                          Marks 20

 

Consider the following context free grammar:

 

S  →  Sa

S  →  bS

S  →   c

 

(a) Write the canonical collections of LR(1) items for the given context free grammar:

[4 marks]

 

(b) Identify all conflicting items from solution of part a, and the types of the conflicts. [4 marks]

 

(c) Could the original grammar be converted into an LALR(1) parser that parses all input correctly by resolving conflicts, in the way that YACC and similar parser generators allow? If so, how should they be resolved? In either case, please explain briefly. [4 marks]

 

(d) Rewrite the grammar in an equivalent form that is suitable for LL parsing and minimizes the use of stack space. [4 marks]

 

(e) Rewrite the grammar in an equivalent form that is directly suitable for LR parsing (i.e., does not result in conflicts) and minimizes the use of stack space. [4 marks]

 

 

+ How to Follow the New Added Discussions at Your Mail Address?

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?


See Your Saved Posts Timeline

Views: 2446

.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)

Attachments:

Replies to This Discussion

Aameen.

muazz D part bhe guide kr do khch smj nhe aa rha

thanks

Assignment No.3

CS (Compiler Construction)

(a) Write the canonical collections of LR(1) items for the given context free grammar:

[4 marks]

 

Solution:

The canonical collection of LR(1) items is:

I0: S  →  .Sa

     S  →  .bS

     S  →   .c

 

I1: S → S. a

      S → b. S

 

I2: S → S a.

 

I3: S → b S.

      S → c.

(b) Identify all conflicting items from solution of part a, and the types of the conflicts.

 [4 marks]

 

There are two types of conflicting items

  1. Shift/Reduce
  2. Reduce/Reduce

I found conflicting item in I1 which is shift/ reduce and the second conflicting item is in I3 which is reduce /reduce.
 

 

(c) Could the original grammar be converted into an LALR(1) parser that parses all input correctly by resolving conflicts, in the way that YACC and similar parser generators allow? If so, how should they be resolved? In either case, please explain briefly. [4 marks]

Solution:

 

(d) Rewrite the grammar in an equivalent form that is suitable for LL parsing and minimizes the use of stack space.

Solution:

 

 

(e) Rewrite the grammar in an equivalent form that is directly suitable for LR parsing (i.e., does not result in conflicts) and minimizes the use of stack space.

Solution:




Consider the grammar 
S → aABe 
A → Abc | b 
B →d 
The sentence abbcdecan be reduced to S: 
abbcde 
aAbcde 
aAde 
aABe 

S



Aslam-O-Alikum. Kindly uplaod d part pleaseeeeeeeeeeeeeeeeeeeeeeeeee

S aABe aAde aAbcde abbcde

S  →  bSa 

S  →  bca 

part d 

RSS

Latest Activity

خنساء replied to +!!!StRaNGeR!!! +'s discussion وہم
56 minutes ago
خنساء liked +!!!StRaNGeR!!! +'s discussion وہم
56 minutes ago
+ Տehɑr Ƙհɑղ + replied to zohaib iftikhar's discussion ...*QUESTION SERIES...AAJ KA SAWAL NO.8(Intelligents)...*
1 hour ago
zohaib iftikhar replied to zohaib iftikhar's discussion ...*QUESTION SERIES...AAJ KA SAWAL NO.8(Intelligents)...*
2 hours ago
zohaib iftikhar replied to zohaib iftikhar's discussion ...* QUESTION SERIES...*AAJ KA SAWAL NO.9 (For Intelligents)...*
2 hours ago
+ Տehɑr Ƙհɑղ + replied to zohaib iftikhar's discussion ...*QUESTION SERIES...AAJ KA SAWAL NO.8(Intelligents)...*
2 hours ago
Isha Chuhdary replied to zohaib iftikhar's discussion ...* QUESTION SERIES...*AAJ KA SAWAL NO.9 (For Intelligents)...*
2 hours ago
zohaib iftikhar replied to zohaib iftikhar's discussion ...* QUESTION SERIES...*AAJ KA SAWAL NO.9 (For Intelligents)...*
3 hours ago
zohaib iftikhar liked zohaib iftikhar's discussion ...* QUESTION SERIES...*AAJ KA SAWAL NO.9 (For Intelligents)...*
3 hours ago
zohaib iftikhar posted discussions
3 hours ago
zohaib iftikhar replied to zohaib iftikhar's discussion ...* QUESTION SERIES...*AAJ KA SAWAL NO.1 (FOR BRILLIANTS)
3 hours ago
zohaib iftikhar liked zohaib iftikhar's discussion ...* QUESTION SERIES...*AAJ KA SAWAL NO.1 (FOR BRILLIANTS)
3 hours ago

© 2020   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service

.