SVECW-IT-A SECTION
COMPILER DESIGN ASSIGNMENT-II(UNIT-II)
SET-I
1.
a) Compute First and Follow for the grammar
E
→E+T/T, T →T*F/F, F→(E)/id
b)
Eliminate Left Recursion for the grammar
E
→E+T/T, T→T*F/F, F→(E)/id.
2.
a) Convert the following grammar into LL(1) grammar and construct the
LL(1)
Parsing
table:
E→E
+ T | T, T→T * F | F, F → (E)/id
b)
Convert the following grammar into LL(1) grammar and construct the
LL(1)
Parsing
table:
R→R
“|’R|RR|R*|(R)|a|b
3.
a) Convert the following grammar into LL(1) grammar and construct the
LL(1) Parsing
table:
bexpr
→ bexpr or bterm | bterm, bterm → bterm and bfactor | bfactor
bfactor
→ not bfactor | ( bexpr) | true | false
b)
Write the differences between top down parsers and bottom up parsers.
4.
a)Convert the following grammar into LL(1) grammar and construct the
LL(1) Parsing table:
S
→iEtS | iEtSeS, T→b
b)
What is left recursion and left factoring? Eliminate left recursion
for the following grammar
E→
E + E / num
5. a) Construct SLR parsing table for the grammar E→ E+T/T, T→ T*F/F, F→ (E)/id.
b) Write the differences between LL parsers and LR parsers.
SET-II
1.
a) Consider following grammar
S→(
L ) | a , L →L, S | S
Find
parse trees for the sentences i) (a, (a,a)) ii) (a, (a,a), (a,a))
b)Explain
about Top down parsing techniques.
2.
a) Show that the following grammar is LL(1)
S
-> AaAb | BbBa , A -> ε, B -> ε
b)
Explain in brief about the model of Non recursive predictive parser?
3.
a) Explain FIRST and FOLLOW Rules [4M]
b)
Construct recursive descent parser for the following grammar
E→TE′
, E′→+TE′│€ , T→FT′ , T′→* FT′ │€ ,
F→ (E) │id
4.
a) Write the algorithm for Constructing the predictive Parser.
b)
Show that the following grammar is LL(1)
S→aAB│bA│€
A→aAb│€ B→bB│€
5. a) Construct CLR Parsing table for the grammar S→L=R|R, L→*R|id,R→L
b) Explain in brief about Operator Precedence parsing.
SEI-III
1.
a) Explain in detail the difficulties in top down parsing
b)
Find FIRST & FOLLOW from the following grammar
S→aAB│bA│€
A→aAb│€ B→bB│€
2.
a) What is left recursion? Eliminate left recursion from the
following grammar.
A→Ba│Aa│c
B→Bb│Ab│d
b)
Explain error recovery strategies in predictive parsing?
3. a)S→Aa|b, A→Ac|Aad|bd|€ check the given grammar LL(1) or not
b) Write first and follow rulres
4.a) explain Error recovery in predictive parser with relevant example.
b) Discuss the short notes on Ambiguity.
5. a) Construct the LALR parsing table for the following grammar:
S→Aa | bAc | dc|bda, A→d
b) Write an algorithm to find LR(0) items.