DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Subject Name: CS2352 Principles of Compiler Design Year/Sem : III/VI

Similar documents
SYED AMMAL ENGINEERING COLLEGE (An ISO 9001:2008 Certified Institution) Dr. E.M. Abdullah Campus, Ramanathapuram

KINGS COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING ACADEMIC YEAR / EVEN SEMESTER

Gujarat Technological University Sankalchand Patel College of Engineering, Visnagar B.E. Semester VII (CE) July-Nov Compiler Design (170701)

VALLIAMMAI ENGINEERING COLLEGE

Question Bank. 10CS63:Compiler Design

PRINCIPLES OF COMPILER DESIGN

DEPARTMENT OF INFORMATION TECHNOLOGY / COMPUTER SCIENCE AND ENGINEERING UNIT -1-INTRODUCTION TO COMPILERS 2 MARK QUESTIONS

VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur

INSTITUTE OF AERONAUTICAL ENGINEERING

INSTITUTE OF AERONAUTICAL ENGINEERING (AUTONOMOUS)

Compiler Design Aug 1996

2068 (I) Attempt all questions.

1. Explain the input buffer scheme for scanning the source program. How the use of sentinels can improve its performance? Describe in detail.

VIVA QUESTIONS WITH ANSWERS

About the Authors... iii Introduction... xvii. Chapter 1: System Software... 1

The analysis part breaks up the source program into constituent pieces and creates an intermediate representation of the source program.

Section A. A grammar that produces more than one parse tree for some sentences is said to be ambiguous.

GUJARAT TECHNOLOGICAL UNIVERSITY

1. (a) What are the closure properties of Regular sets? Explain. (b) Briefly explain the logical phases of a compiler model. [8+8]

CS 2210 Sample Midterm. 1. Determine if each of the following claims is true (T) or false (F).

LECTURE NOTES ON COMPILER DESIGN P a g e 2

QUESTIONS RELATED TO UNIT I, II And III

VETRI VINAYAHA COLLEGE OF ENGINEERING AND TECHNOLOGY

SYLLABUS UNIT - I UNIT - II UNIT - III UNIT - IV CHAPTER - 1 : INTRODUCTION CHAPTER - 4 : SYNTAX AX-DIRECTED TRANSLATION TION CHAPTER - 7 : STORA

VALLIAMMAI ENGINEERING COLLEGE

PSD3A Principles of Compiler Design Unit : I-V. PSD3A- Principles of Compiler Design

4. An interpreter is a program that


Roll No. :... Invigilator's Signature :. CS/B.Tech(CSE)/SEM-7/CS-701/ LANGUAGE PROCESSOR. Time Allotted : 3 Hours Full Marks : 70

CST-402(T): Language Processors

Syntax Analysis Part I

G.PULLAIH COLLEGE OF ENGINEERING & TECHNOLOGY

CS6660-COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS PART A

SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF CSE COURSE PLAN

UNIT I INTRODUCTION TO COMPILING

Compiler Design Overview. Compiler Design 1

Syntax Analysis. Chapter 4

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Compiler Design

QUESTION BANK CHAPTER 1 : OVERVIEW OF SYSTEM SOFTWARE. CHAPTER 2: Overview of Language Processors. CHAPTER 3: Assemblers

Life Cycle of Source Program - Compiler Design

SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY

SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTER SCIENCE AND ENGINEERING COURSE PLAN

EDAN65: Compilers, Lecture 06 A LR parsing. Görel Hedin Revised:

CS606- compiler instruction Solved MCQS From Midterm Papers

UNIT-III BOTTOM-UP PARSING

University of Technology Department of Computer Sciences. Final Examination st Term. Subject:Compilers Design

CSE P 501 Compilers. LR Parsing Hal Perkins Spring UW CSE P 501 Spring 2018 D-1

3. Syntax Analysis. Andrea Polini. Formal Languages and Compilers Master in Computer Science University of Camerino

Let us construct the LR(1) items for the grammar given below to construct the LALR parsing table.

Torben./Egidius Mogensen. Introduction. to Compiler Design. ^ Springer

Context-free grammars

Formal Languages and Compilers Lecture VII Part 3: Syntactic A

CS5363 Final Review. cs5363 1

UNIT III & IV. Bottom up parsing

General Overview of Compiler

Compiler Construction: Parsing

CSE 401 Compilers. LR Parsing Hal Perkins Autumn /10/ Hal Perkins & UW CSE D-1

Downloaded from Page 1. LR Parsing

PART 3 - SYNTAX ANALYSIS. F. Wotawa TU Graz) Compiler Construction Summer term / 309

R13 SET Discuss how producer-consumer problem and Dining philosopher s problem are solved using concurrency in ADA.


CJT^jL rafting Cm ompiler

1. The output of lexical analyser is a) A set of RE b) Syntax Tree c) Set of Tokens d) String Character

LR Parsing Techniques

CS 4201 Compilers 2014/2015 Handout: Lab 1

Group B Assignment 9. Code generation using DAG. Title of Assignment: Problem Definition: Code generation using DAG / labeled tree.

COMPILER DESIGN LEXICAL ANALYSIS, PARSING

COMPILER DESIGN. For COMPUTER SCIENCE

Front End. Hwansoo Han

NARESHKUMAR.R, AP\CSE, MAHALAKSHMI ENGINEERING COLLEGE, TRICHY Page 1

Bottom-up parsing. Bottom-Up Parsing. Recall. Goal: For a grammar G, withstartsymbols, any string α such that S α is called a sentential form

Principles of Programming Languages [PLP-2015] Detailed Syllabus

ECE251 Midterm practice questions, Fall 2010

Parsing. Handle, viable prefix, items, closures, goto s LR(k): SLR(1), LR(1), LALR(1)

UNIT IV INTERMEDIATE CODE GENERATION

MODULE 14 SLR PARSER LR(0) ITEMS

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILING

SEM / YEAR : VI / III CS2352 PRINCIPLES OF COMPLIERS DESIGN UNIT I - LEXICAL ANALYSIS PART - A

Final Term Papers 2013

TABLE OF CONTENTS S.No DATE TOPIC PAGE No UNIT I LEXICAL ANALYSIS 1 Introduction to Compiling-Compilers 6 2 Analysis of the source program 7 3 The

BIRLA INSTITUTE OF TECHNOLOGY AND SCIENCE, Pilani Pilani Campus Instruction Division

Compilerconstructie. najaar Rudy van Vliet kamer 140 Snellius, tel rvvliet(at)liacs(dot)nl. college 3, vrijdag 22 september 2017

Appendix A The DL Language

Compiler Code Generation COMP360

List of Figures. About the Authors. Acknowledgments

BSCS Fall Mid Term Examination December 2012

Parsing. Rupesh Nasre. CS3300 Compiler Design IIT Madras July 2018

Compiler Design. Computer Science & Information Technology (CS) Rank under AIR 100

EXAM. CS331 Compiler Design Spring Please read all instructions, including these, carefully

Concepts Introduced in Chapter 4

1. INTRODUCTION TO LANGUAGE PROCESSING The Language Processing System can be represented as shown figure below.

Syntax Analysis. Amitabha Sanyal. ( as) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay

Lecture 8: Deterministic Bottom-Up Parsing

CS131: Programming Languages and Compilers. Spring 2017

Context-Free Grammar. Concepts Introduced in Chapter 2. Parse Trees. Example Grammar and Derivation

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Computer Science and Engineering

A simple syntax-directed

Principle of Compilers Lecture IV Part 4: Syntactic Analysis. Alessandro Artale

CS308 Compiler Principles Syntax Analyzer Li Jiang

Lecture 7: Deterministic Bottom-Up Parsing

Transcription:

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Subject Name: CS2352 Principles of Compiler Design Year/Sem : III/VI UNIT I - LEXICAL ANALYSIS 1. What is the role of Lexical Analyzer? [NOV 2014] 2. Write regular expression to describe a language consist of strings made of even numbers a and b. [NOV 2014] 3. State any two reasons as to why phases of compiler should be grouped. [MAY 2014] 4. Why is buffering used in lexical analysis? What are the commonly used buffering methods? [MAY 2014] 5. How will you group the phases of compiler? [NOV 2013] 6. Write the regular expression for identifier and whitespace. [NOV 2013] 7. Define tokens, patterns and lexemes. [MAY 2013] 8. What is a Complier? [MAY 2013] 9. State some software tools that manipulate source program? 10. What are the cousins of compiler? 11. What are the main two parts of compilation? What are they performing? 12. What is a Structure editor? 13. What happens in Semantic analysis? 14. State some compiler construction tools? 15. What is a Loader? What does the loading process do? 16. What does the Link Editing does? 17. State some functions of Preprocessors 18. What is a preprocessor? 19. What is an assembler? 20. What is the need for separating the analysis phase into lexical analysis and parsing? 21. What are the issues of lexical analyzer? 22. What is a sentinel? What is its usage? 23. What is a regular expression? State the rules, which define regular expression? 24. What are the Error-recovery actions in a lexical analyzer? 25. What is cross compiler? Give an example. Part - B 1. a. Explain the need for grouping of phases of compiler. [NOV 2014] b. Explain a language for specifying the lexical analyzer. [NOV 2014] 2. a. Write short notes on Compiler Construction tools. [NOV 2014] b. Explain Specification and recognition of tokens. [NOV 2014] 3. a. Define the following terms : Compiler, Interpreter, Translator. [MAY 2014] b. Differentiate between lexeme, token and pattern. [MAY 2014] c. What are the issues in Lexical analysis? [MAY 2014] 4. Explain in detail the process of compilation. Illustrate the output of each phase of compilation of the input a=(b+c)*(b+c)*2. [MAY 2014]

5. a. Explain the different phases of a compiler in detail. [NOV 2013] b. Discuss the cousins of compiler. [NOV 2013] 6. a. Draw the DFA for the augmented regular expression (a b) * # directly using syntax tree. [NOV 2013] b. Discuss input buffering techniques in detail. [NOV 2013] 7. Explain in detail about the role of Lexical analyzer with the possible error recovery actions. [MAY 2013] 8. What are the phases of the compiler? Explain the phases in detail. Write down the output of each phase for the expression a:= b+c*50. [MAY 2013] 9. Explain the specification of tokens. 10. What are the cousins of a Compiler? Explain them in detail. 11. Describe how various phases could be combined as a pass in a compiler? 12. Briefly explain Compiler construction tools 13. For the following expression Position:=initial+ rate*60 Write down the output after each phase 14. Explain the role Lexical Analyzer and issues of Lexical Analyzer. 15. Explain tokens with its attributes. UNIT II - SYNTAX ANALYSIS & RUNTIME ENVIRONMENT 1. List out the various storage allocation strategies. [NOV 2014] 2. Write CF grammar to represent palindrome. [NOV 2014] 3. Define Lexeme. [MAY 2014] 4. Compare the features of DFA to NFA. [MAY 2014] Eliminate the left recursion from the following grammar A Ac/Aad/bd/ 5. Give Examples for Static check. [NOV 2013] 6. Eliminate the left recursion of the grammar. [NOV 2013] S Aa b A Ac Sd 7. What is meant by coercion? [MAY 2013] 8. What is the output of syntax analysis phase? What are the three general types of parsers for grammars? [MAY 2013] 9. What are the different strategies that a parser can employ to recover from a syntactic error? 10. What is phrase level error recovery? 11. What are the goals of error handler in a parser? 12. How will you define a context free grammar? 13. Define context free language. When will you say that two CFGs are equal? 14. Differentiate sentence and sentential form. 15. Give the definition for leftmost and canonical derivations. 16. What is a parse tree? 17. When will you call a grammar as the left recursive one? 18. What is an ambiguous grammar? Give an example. 19. Define left factoring. 20. What is parsing? 21. What is Top Down parsing? 22. What do you mean by Recursive Descent Parsing? 23. What is meant by Predictive parsing? 24. What do you mean by viable prefixes? 25. Define handle. What do you mean by handle pruning?

Part - B 1. a. Explain the specification of simple type checker. [NOV 2014] b. Explain runtime environment with suitable example. [NOV 2014] 2. Find the LALR for the given grammar and parse the sentence (a+b)*c [NOV 2014] E E+T T, T T*F F, F (E) id 3. Consider the following grammar [MAY 2014] S AS b A SA a Construct the SLR parse table for the grammar. Show the actions of the parser for the input string abab. 4. What is an ambiguous grammar? Is the following grammar ambiguous? Prove E E+E E * E (E) id. [MAY 2014] 5. Design an LALR parser for the following grammar and parse the input id = id. [NOV 2013] S L = R R L *R id R L 6. a. Discuss in detail about storage allocation strategies. [NOV 2013] b. Explain about various parameter passing methods in procedure calls. [NOV 2013] 7. a. Construct a predictive parser for the following grammar. [MAY 2013] S (L) a L L,S S b. List all LR (0) items for the following grammar [MAY 2013] S AS / b A SA / a 8. a. What are the different storage allocation strategies? Explain. [MAY 2013] b. Specify a type checker which can handle expressions, statements and functions. [MAY 2013] 9. a. What are preliminary steps that are to be carried out during parsing? Explain with suitable examples b. Explain the error recovery in predictive parsing. 10. What are the necessary conditions to be carried out before the construction of predictive parser? 11. i) Construct the predictive parser for the following grammar: S (L) a L L,S S. ii) Construct the behavior of the parser on the sentence (a, a) using the grammar specified above. 12. i) Give an algorithm for finding the FIRST and FOLLOW positions for a given non-terminal. ii) Consider the grammar, E TE E +TE T FT T *FT F (E) id. Construct a predictive parsing table for the grammar given above. Verify whether the input string id + id * id is accepted by the grammar or not. 13. Construct the predictive parser for the following grammar: S a (T) T T, S S Write down the necessary algorithms and define FIRST and FOLLOW. Show the behavior of the parser in the sentences, i. (a,(a,a))

ii. (((a,a),,(a),a) 14. i) What is an operator grammar? Draw the precedence function graph for the following table. a ( ), $ a > > > ( < < = < ) > > >, < < > > $ < < ii) Check whether the following grammar is SLR (1) or not. Explain your answer with reasons. S L = R S R L * R L id R L. 15. For the operators given below, calculate the operator-precedence relations and operator precedence function id, +, *, $ 16. Check whether the following grammar is a LL(1) grammar S iets ietses a E b Also define the FIRST and FOLLOW procedures. 17. Consider the grammar E E + E E * E (E) id Show the sequence of moves made by the shift-reduce parser on the input id 1 + id 2 * id 3 and determine whether the given string is accepted by the parser or not. 18. i) What is a shift-reduce parser? Explain in detail the conflicts that may occur during shiftreduce parsing. ii) For the grammar given below, calculate the operator precedence relation and the precedence functions E E + E E - E E * E E / E E E (E) -E id 19. i) Consider the grammar given below. E E + T E T T T * F T F F (E) F id Construct an LR parsing table for the above grammar. Give the moves of LR parser on id*id+id ii) Briefly explain error recovery in LR parsing. 20. Construct a canonical parsing table for the grammar given below S CC C cc d

UNIT III INTERMEDIATE CODE GENERATION 1. What are the types of intermediate languages? [NOV 2014] 2. Give syntax directed translation for case statement. [NOV 2014] 3. What is the significance of intermediate code? [MAY 2014] 4. Write the various three address code form of intermediate code. [MAY 2014] 5. Define Back patching. [NOV 2013] 6. Translate the arithmetic expression a * -(b+c) into syntax tree and postfix notation. [NOV 2013] 7. What are the various ways of representing intermediate languages? [MAY 2013] 8. What are the benefits of using machine-independent intermediate form? [MAY 2013] 9. How can you generate three-address code? 10. What is a syntax tree? Draw the syntax tree for the assignment statement 11. What is postfix notation? 12. What is the usage of syntax directed definition. 13. Why Three address code is named so? 14. Define three-address code. 15. State quadruple 16. What is called an abstract or syntax tree? 17. What are triples? 18. Draw the DAG for a := b * -c + b * -c 19. What is meant by declaration? 20. Define Boolean Expression. 21. How semantic rules are defined? 22. What are the two primary purposes of Boolean Expressions? 23. What do you mean by viable prefixes? 24. What is meant by Shot-Circuit or jumping code? 25. What are the methods of representing a syntax tree? 26. Explain the following functions: i) makelist(i) ii) merge(p 1,p 2 ) iii) backpatch(p,i) Part - B 1. Generate intermediate code for the following code segment along with the required syntax directed translation scheme. [NOV 2014] While (i<10) If(i % 2 == 0) Evensum = evensum + i; Else Oddsum = oddsum + i; 2. Generate intermediate code for the following code segment along with the required syntax directed translation scheme. [NOV 2014] s=s+a[i][j]; 3. How would you convert the following into intermediate code? Give a suitable example. a. Assignment Statements [MAY 2014] b. Case Statements 4. a. Write notes on back patching. [MAY 2014] b. Explain the sequence of stack allocation processes for a function call. [MAY 2014] 5. a. Write the translation scheme for flow of control statements. [NOV 2013] b. Explain and compare in detail the various implementation forms of three address code. 6. a. Write the grammar and translation scheme for procedure call statements. [NOV 2013] b. Draw the DAG for the following three address code. [NOV 2013] d = b * c e = a + b b = b * c a = e - d

7. How would you generate the intermediate code for the flow of control statements? Explain with examples. [MAY 2013] 8. What are the various ways of calling the procedures? Explain in detail. [MAY 2013] 9. What is the 3 address code? Mention its types. How would you implement the three address statements? Explain with suitable examples. 10. Explain how declaration is done in a procedure using syntax directed translation. 11. Brief Intermediate code generation for Basic block, Control Flow and Boolean Expressions. 12. Write about quadruple and triple with its structure. 13. Explain the data structure used for implementing Symbol Table. 14. Compare the various data structures used for Symbol Table construction. 15. Explain about Back patching using Boolean Expressions. 16. Explain about Back patching using Flow of Control statements. UNIT IV CODE GENERATION 1. Differentiate between basic block and flow graph. [NOV 2014] 2. Draw DAG to represent a[i] = b[i]; a[i]=&t; [NOV 2014] 3. Define symbol table. [MAY 2014] 4. Name the techniques in loop optimization. [MAY 2014] 5. What is the use of Next-use information? [NOV 2013] 6. List the fields in an activation record. [NOV 2013] 7. Define basic blocks and flow graphs. [MAY 2013] 8. Give any four applications of DAG. [MAY 2013] 9. What are basic blocks? 10. What is a flow graph? 11. Discuss back-end and front end? 12. Define relocatable object module. 13. What is meant by multi register operations? 14. What is meant by peephole optimization? 15. List the types of addressing modes:- 16. What is input to code generator? 17. How the use of registers is subdivided into 2 sub-problems? 18. How would you calculate the cost of an instruction? 19. What are the primary structure preserving transformations on basic blocks? 20. Give some examples for 3 address statements. 21. What are the characteristics of peephole optimization? 22. What is a recursive procedure? 23. What are the common methods for associating actual and formal parameters? 24. Define DAG. 25. What are the issues in the design of code generators? 26. What are the various forms of target programs? 27. What is register descriptor and address descriptor? Part - B 1. a. Explain register allocation and assignment with suitable example. [NOV 2014] b. Explain code generation phase with simple code generation algorithm. [NOV 2014] 2. Generate DAG representation of the following code and list out the applications of DAG representation. [NOV 2014] I = 1; while (i<=10) do Sum+ = a[i]; 3. Discuss the various issues in code generation with examples. [MAY 2014] 4. Define a Directed Acyclic Graph. Construct a DAG and write the sequence of instructions for the expression a + a * (b-c) + (b-c) * d [MAY 2014]

5. a. Discuss runtime storage management in detail. [NOV 2013] b. Write short notes on structure preserving transformation of basic blocks. [NOV 2013] 6. Construct DAG and three address code for the following C program. [NOV 2013] i = 1; s = 0; while (i < = 10) { s = s + a [i] [i] i = i + 1 } 7. a. Discuss briefly about simple code generation algorithm. [MAY 2013] b. For the flow graph shown below, write the three address statements and construct the DAG. [MAY 2013] (1) t1:=4 * i (2) t2 := a[t1] (3) t3 := 4 * i (4) t4 := b[t3] (5) t5 := t2 * t4 (6) t6 := prod + t5 (7) prod := t6 (8) t7 := I + 1 (9) i := t7 (10) if i<=20 goto (1) 8. Discuss labeling algorithm with an example. [MAY 2013] 9. Discuss about the run time storage management of a code generator. 10. Explain the simple code generator with a suitable example. 11. Explain about Transformations on Basic Blocks. 12. Discuss in detail about Basic Block and Flow graph. 13. Construct the Basic block for below given three address code t1 : = a * a t2 : = a * b t3 : = 2 * t2 t4 : = t1 + t3 t5 : = b * b t6 : = t4 + t5 14. Consider the following source code for dot product of two vectors a and b of length 20 begin prod :=0; i:=1; do begin prod :=prod+ a[i] * b[i]; i :=i+1; end while i <= 20 end Construct Three address code, Basic Block and Flow Graph. 15. Explain in the DAG representation of the basic block with example. Write down the algorithm for construction of DAG.

UNIT V CODE OPTIMIZATION 1. Represent the following in flow graph. [NOV 2014] I = 1; sum = 0; while(i<= 10){sum+ =i;i++;} 2. What is global data flow analysis? [NOV 2014] 3. What do you mean by Cross- Compiler? [MAY 2014] 4. How would you represent the dummy blocks with no statements indicated in global data flow analysis? [MAY 2014] 5. Define loop unrolling with example. [NOV 2013] 6. What is an Optimizing compiler? [NOV 2013] 7. What is constant folding? [MAY 2013] 8. What are the properties of optimizing compilers? [MAY 2013] 9. Explain the principle sources of optimization. 10. What are the patterns used for code optimization? 11. Define local optimization. 12. What is code motion? 13. Give the block diagram of organization of code optimizer. 14. What are the advantages of the organization of code optimizer? 15. Define Local transformation & Global Transformation. 16. Give examples for function preserving transformations. 17. What is meant by Common Sub expressions? 18. What is meant by Dead Code? 19. What are the techniques used for loop optimization? 20. What is meant by Reduction in strength? 21. What is meant by loop invariant computation? 22. Write short notes on activation tree. 23. Define data flow equations. 24. Define static scope rule and dynamic rule Part - B 1. a. Explain Principle sources of optimization. [NOV 2014] b. Illustrate optimization of basic blocks with an example. [NOV 2014] 2. Explain peephole optimization and various code improving Transformations. [NOV 2014] 3. Discuss in detail the process of optimization of basic blocks. Give an example.[may 2014] 4. What is data flow analysis? Explain data flow abstraction with examples. [MAY 2014] 5. a. Write in detail about loop optimization. [NOV 2013] b. Discuss the characteristics of peephole optimization. [NOV 2013] 6. Discuss in detail about global data flow analysis. [NOV 2013] 7. a. Explain the data-flow analysis of structured programs. [MAY 2013] b. Write global common sub expression elimination algorithm with example. [MAY 2013] 8. Discuss in detail about technique used for Loop optimization. [MAY 2013] 9. Explain about Optimization of Basic Block. 10. Explain in detail of Loops in Flow graph. 11. What is bootstrapping? Explain the approach to compiler development 12. Explain the various source language issues. 13. Write about Data Flow Analysis of structural programs. 14. Explain various code optimization techniques in detail. 15. Generate target code for the given program segments: main( ) { int i,j; i = 4; j = i + 5; }