CD Cycle Test 2
CD Cycle Test 2
NO:
REG.NO:
8131- PAVENDAR BHARATHIDASAN COLLEGE OF ENGINEERING AND TECHNOLOGY,
8131- PAVENDAR BHARATHIDASAN COLLEGE OF ENGINEERING AND TECHNOLOGY, MATHUR-TIRUCHIRAPPALLI-620024
MATHUR-TIRUCHIRAPPALLI-620024 B.E/B.TECH –CYCLE TEST II- MAR 2018
B.E/B.TECH –CYCLE TEST II- MAR 2018 SIXTH SEMESTER
SIXTH SEMESTER COMMON TO CSE/ IT
COMMON TO CSE/ IT CS6660 / COMPILER DESIGN
CS6660 / COMPILER DESIGN TIME: 3 HOURS MAXIMUM MARKS: 100
TIME: 3 HOURS MAXIMUM MARKS: 100 ANSWER ALL QUESTION
ANSWER ALL QUESTION PART A- (10*2=20 MARKS)
PART A- (10*2=20 MARKS) 1. Define parser.
1. Define parser. 2. Mention the basic issues in parsing.
2. Mention the basic issues in parsing. 3. Define a context free grammar.
3. Define a context free grammar. 4. Define ambiguous grammar.
4. Define ambiguous grammar. 5. What are the problems with top down parsing?
5. What are the problems with top down parsing? 6. Write short notes on YACC.
6. Write short notes on YACC. 7. Define LR(0) items.
7. Define LR(0) items. 8. What is meant by Dead Code?
8. What is meant by Dead Code? 9. What are the properties of optimizing compiler
9. What are the properties of optimizing compiler 10. Define live variable.
10. Define live variable.
PART B – (5*13=65 MARKS)
PART B – (5*13=65 MARKS) 11. a) Explain recursive decent parsing with example?(13)
11. a) Explain recursive decent parsing with example?(13) (OR) (OR)
b) What is an ambiguous grammar? Is the following grammar ambiguous? Prove b) What is an ambiguous grammar? Is the following grammar ambiguous? Prove
E-> E+E|E*E|(E)|id.(13) E-> E+E|E*E|(E)|id.(13)
12. a) What is a shift-reduce parser? Explain in detail the conflicts that may occur 12. a) What is a shift-reduce parser? Explain in detail the conflicts that may occur
during shift- reduce parsing.(13) (OR) during shift- reduce parsing.(13) (OR)
b) Construct stack implementation of shift reduce parsing for the grammar b) Construct stack implementation of shift reduce parsing for the grammar
S -> (L)|a,L -> L,S|S. To check whether the sentence (a,(a,a)).(13) S -> (L)|a,L -> L,S|S. To check whether the sentence (a,(a,a)).(13)
13. a) Construct parsing table for the grammar and find moves made by predictive parser on 13. a) Construct parsing table for the grammar and find moves made by predictive parser on
input 1d+id*id and find FIRST and FOLLOW. input 1d+id*id and find FIRST and FOLLOW.
E->E+T/T,T->T*F/F,F->(E)/id (13) (OR) E->E+T/T,T->T*F/F,F->(E)/id (13) (OR)
b) Construct SLR parsing Table for the following grammar. (13) b)Construct SLR parsing Table for the following grammar: (13)
E→E+T|T,T→T*F|F,F→(E)|id. E→E+T|T,T→T*F|F,F→(E)|id.
14. a) Let G be the grammar S->aB/bA,A->a/aS/bAA,B->b/bS/aBB. For the string 14. a) Let G be the grammar S->aB/bA,A->a/aS/bAA,B->b/bS/aBB. For the string
aaabbabbba i)Left most deviation ii)Right most deviation iii)deviation tree(13) (OR) aaabbabbba i)Left most deviation ii)Right most deviation iii)deviation tree(13) (OR)
b) Explain the principle sources of optimization in detail. (13) b) Explain the principle sources of optimization in detail. (13)
15. a) Explain DAG representation of basic blocks? What are the advantages of DAG 15. a) Explain DAG representation of basic blocks? What are the advantages of DAG
representation? Give example.(13) (OR) representation? Give example.(13) (OR)
b) Find the LALR for the given grammar and parse the sentence bdc. (13) b) Find the LALR for the given grammar and parse the sentence bdc. (13)
S->Aa/bAc/dc/bda, A->d S->Aa/bAc/dc/bda, A->d
PART C(1*15=15 MARKS) PART C(1*15=15 MARKS)
16. a) Construct Predictive Parsing table for the following grammar: S ->(L)/a, L -> L, S/S 16. a) Construct Predictive Parsing table for the following grammar: S ->(L)/a, L -> L, S/S
and check whether the following sentences belong to that grammar or not.(15) and check whether the following sentences belong to that grammar or not.(15)
i) (a,a) (i) ( a,a)
ii) (a, (a ,a)) (ii) (a, (a ,a))
iii) (a, ((a , a), (a , a)) ) (iii) (a, ((a , a), (a , a)) )