+ Link For Assignments, GDBs & Online Quizzes Solution |
+ Link For Past Papers, Solved MCQs, Short Notes & More |
Assignment No. 02 |
Total Marks: 20
Due Date: 08/12/2014 |
|
Objective:
To learn and understand basic concepts of Parse Trees, Top Down Parsers, Predictive Parsing, First and Follow Sets in building a Lexical analyzer. Instructions: It should be clear that your assignment will not get any credit (zero marks will be awarded) if:
For any query about the assignment, contact at cs606@vu.edu.pk |
||
Question No 1: Marks 10 Consider the following grammar; you are required to write left most derivation of the string “aebb”.
Question No 2: Marks 10 Consider the following grammar for arithmetic expressions:
A à id X X àA Y |ε Y à- X | + X | / X | * X
Show the first set for the non-terminals X and Y in the grammar.
|
||
BEST OF LUCK |
Tags:
+ 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)Question 2 ka First and follow set ka solution hai kisi k pas
May it could be helpful for 2nd question..
Apply following rules:
Applying rules 1 and 2 is obvious. Applying rules 3 and 4 for FIRST(Y1 Y2 … Yk) can be done as follows:
Add all the non-ε symbols of FIRST(Y1) to FIRST(Y1 Y2 … Yk). If ε ∈ FIRST(Y1), add all the non-ε symbols of FIRST(Y2). If ε ∈ FIRST(Y1) and ε ∈ FIRST(Y2), add all the non-ε symbols of FIRST(Y3), and so on. Finally, add ε to FIRST(Y1 Y2 … Yk) if ε ∈ FIRST(Yi), for all 1 ≤ i ≤ k.
Example:
Consider the following grammar.
E → E + T | T
T → T * F | F
F → (E) | id
Grammar after removing left recursion:
E → TX
X → +TX | ε
T → FY
Y → *FY | ε
F → (E) | id
For the above grammar, following the above rules, the FIRST sets could be computed as follows:
FIRST(E) = FIRST(T) = FIRST(F) = {(, id}
FIRST(X) = {+, ε}
FIRST(Y) = {*, ε}
sorry,abhi kuch keh nahi sakti..
thanks for sharing old file..
mujhay b kuch aesa hi lag rha hai..but...
can you explain 1st ques from old solution file?
if S ―> aS | Ab
then how it can be?
First (S) = {a, b, c, d , e}
sorry mujy b nahi pta kesy aya . ma to bus compare kr k ans bta raha hon .
Upload kr dia hai assignment . Ab Allah kher kry kia bnta hai
ok.
can you explain 1st ques from old solution file?
if S ―> aS | Ab
then how it can be?
First (S) = {a, b, c, d , e}
مَلیکا ایمان appi.
S ―> aS | Ab
A ―> XYZ |ε
Yh islay hy Q ky A ky andr XYZ hy Ju yh show kr rhy hain
a,b tu S ky apny hu Gy Hain aur c,d,e XYZ ky hu gy hain wo
isLy hoWy HaiN q ky S ky andr A nonterminal Show raha hy aur
A ky andr XYZ show hu rahy hn
dear..explain some logic ..k ye alphabetics kis logic k through or kyun aa rhay hein??
simple si bat hy Appi ju Terminal hain wo 1st sets bny gy
then iska First just {a,b} hona chahiaye na k {a,b,c,d,e}..
© 2021 Created by + M.Tariq Malik.
Powered by
Promote Us | Report an Issue | Privacy Policy | Terms of Service
We have been working very hard since 2009 to facilitate in learning Read More. We can't keep up without your support. Donate.
We are user-generated contents site. All product, videos, pictures & others contents on site don't seem to be beneath our Copyrights & belong to their respected owners & freely available on public domains. We believe in Our Policy & do according to them. If Any content is offensive in your Copyrights then please email at m.tariqmalik@gmail.com Page with copyright detail & We will happy to remove it immediately.
Management: Admins ::: Moderators
Awards Badges List | Moderators Group
All Members | Featured Members | Top Reputation Members | Angels Members | Intellectual Members | Criteria for Selection
Become a Team Member | Safety Guidelines for New | Site FAQ & Rules | Safety Matters | Online Safety | Rules For Blog Post