Docsity

Previous year question paper, Exams of Compiler Design

Partial preview of the text

Download Previous year question paper and more Exams Compiler Design in PDF only on Docsity!

Total Pages : 3 46165 BT-6/M-24 COMPILER PESIGN Paper—PC-CS-3024 Time : Three Hours] [Maximum Marks - 75 Note : Attempt five questions in all, Selecting one question from each unit. UNIT-I What are different phases of Compiler and also write the role of these phases in compiler? (15) What do you mean by compiler construction tools and explain Parser generator, lexical Analyzer and Scanner generator in detail? (15) UNIT-I (a) What do you mean by ambiguity in Context free grammar and write the steps to remove the ambiguity in CFG by taking & 4ppropriate example? (b) Explain TOP down patsing by taking an appropriate example. (15) 46165/1150/KD/1122 24 (pro. 11/6 ee ee 4, What do you mean by LALR parser? Design a % LALR (1) Parsing table from the following Grammar? S=— AA As aA he a UNTTAI Explain the following allocation in detail : (0) Static Allocation, (>) Heap Allocation, (ce) Stack Allocation, by tukiag on appropriate example. (1S) What is role of Directed Acyelic Graph (DAG) in Compiler Design’? Also write an algorithm for construction of Directed Acyelic Graph in Compiler Design with an example : TO=-a+b - Expression | Ti =T0+¢ - Expression 2 d=T0+ TI — Expression 3. us) UNIT-1V Whar do yew mean by Optimization and explain machine iidependent and machine dependent optimization in detall dy taking an example? (1s) 4616811 50KD'1122 2 P it with the help of an mel in deta! (a) Explain pale ee simization of basic block, loop and (bo) Explain the oration with the help of an example peephole optim (1s) 4616/1 F0KRD1I22 i 4, What is LALR(1) parsing ? Draw DFA and parsing table for the following equation : §---- AA A----aA A---73b. 15 UNIT-IIT 5. (a) What is heap allocation and stack allocation? Prove it by taking an appropriate example. 10 (b) What are different issue is designing of code generator? 5 6. What is DAG and write its algorithm ? For the following statements : lL Sh=4*i 2. §2:=a(Sl] 3. S3:=4"i 4. $4:=b[S3] 5. S5:=S2*54 6. S6:=prod*S5 7. S7:=i+l i:=S7 if i<=20 goto 1 15 46165/1,100/KD/970 2 7. UNIT-IV What are different source of optimization ? Explain the following optimization in detail with example : (a) Machine independent optimization. (b) Loop optimization. (c) Peephole optimization. 15 What is Global data flow analysis ? Explain Storage organization, static storage management and heap storage management with the help of example. 15 Unit I 3. Answer the following questions in brief : @) (b) (c) 4. (a) (b) (b) L-46165 What is the role of a parser in compilation process ? What does ambiguity in a context free grammar mean ? How do you represent an abstract syntax tree 2 Why are Recursive Descent and LL parsers known as top-down parsers ? How is left recursion eliminated ? What is shift-reduced parsing ? Describe how LR parsers use the shift-reduce technique 2 Unit It Is attribute granimar a special case of context free “grammar 2 Justify. Explain synthesized attributes using an appropriate example. Distinguish between Stack allocation and Heap Allocation. ropecr ; : Describe in brief the principle ways of organizing and accessing symbol tables. What is the significance of generating intermediate code ? Give examples of any two intermediate codes used in compilers. Fe Unit IV What are the types of code optimization ? Describe the ways in which code optimization can be done. Also give suitable example to show how loop optimization can be carried out ? Give brief answers of the following questions : (a) How is global data flow analysis used to perform” optimization ? (b) How does Runtime environment manage runtime memory requirements ? (c) Describe any hvo common error-recovery strategies ° that can be implemented in a parser to deal with errors in the code. (b) Define context free grammar and its relationship with parsing using a suitable example. When is a grammar said to be ambiguous? 4. What are the different types of Top-down parsing techniques? Bring out the distinction between shift-reduce parsing and recursive descent parsing. UNIT-II 5. Why is three-address code preferred in compilers? What do you mean by the quadruple and triple representation of three- address code? Explain using suitable examples. 6. Answer the following in brief in the context of symbol table : (a) What is the information contained in a symbol table? (b) Describe the commonly used data structures to create symbol tables. (c) How is the symbol table manipulated at various phases of compilation? UNIT-IV 7. Answer the following questions in brief : (a) Distinguish between Machine dependent and Machine independent optimization. (b) What are the various constructs in a program that act as basic blocks? 46165//KD/663 2 (c) How does heap allocation manage run time storage requirement? How does peephole optimization transform source code into an optimized code? Also describe the kind of optimizations that can be performed in a loop. 7. (b) What is top-down parsing? Write and explain the steps to parse id + id * id using top-down parsing. 7% (a) Construct a recursive decent parser starting with the following grammar : S-> +$S|-SS |a. 1% (b) What is canonical LR parser? Explain using suitable examples. 7% UNIT-H1 (a) How intermediate code is generated for declarative statement? Explain using suitable examples. 7 (b) What is meant by backpatching for Boolean expressions? Explain using suitable examples. 7” Design and explain a target machine model using suitable examples. 15 UNIT-IV Explain the procedure for optimization of basic blocks in detail using suitable examples. 15 (a) What are the various source language issues? Explain using suitable examples. MM (b) Write short note on Heap Storage Management. 7!