COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine...

41
J.B. INSTITUTE OF ENGINEERING AND TECHNOLOGY (UGC AUTONOMOUS) Bhaskar Nagar, Moinabad Mandal, R.R. District, Hyderabad -500075 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING COURSE MATERIAL UNIT-1 Academic Year 2019-20 B.Tech CSE III-II Sem Sec-B COMPILER DESIGN Mr. D.HIMAGIRI

Transcript of COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine...

Page 1: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation

J.B. INSTITUTE OF ENGINEERING AND TECHNOLOGY (UGC AUTONOMOUS)

Bhaskar Nagar, Moinabad Mandal, R.R. District, Hyderabad -500075

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

COURSE MATERIAL

UNIT-1

Academic Year 2019-20 B.Tech CSE III-II Sem Sec-B

COMPILER DESIGN

Mr. D.HIMAGIRI

Page 2: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation

Course Syllabus:

J.B.INSTITUTE OF ENGINEERING & TECHNOLOGY UGC AUTONOMOUS

B.Tech. CSE L T-P-D C

III Year – II Semester 4 1-0-0 4

COMPILER DESIGN

(Common to CSE, ECM)

UNIT – I:

Overview of Compilation:

Phases of Compilation – Lexical Analysis, Regular Grammar and regular

expression for common programming language features, pass and Phases of

translation, interpretation, bootstrapping, data structures in compilation – LEX

lexical analyzer generator.

UNIT – II:

Top down Parsing: Context free grammars, Top down parsing – Backtracking,

LL (1), recursive descent parsing, Predictive parsing, Preprocessing steps

required for predictive parsing.

Bottom up parsing: Shift Reduce parsing, SLR,CLR and LALR parsing, Error

recovery in parsing , handling ambiguous grammar, YACC – automatic parser

generator.

UNIT – III:

Semantic analysis: Intermediate forms of source Programs – abstract syntax

tree, polish notation and three address codes. Attributed grammars, Syntax

directed translation, Conversion of popular Programming languages language

Constructs into Intermediate code forms, Type checker.

UNIT – IV

Symbol Tables: Symbol table format, organization for block structures

languages, hashing, tree structures representation of scope information. Block

structures and non block structure storage allocation: static, Runtime stack

and heap storage allocation, storage allocation for arrays, strings and records.

Code optimization: Consideration for Optimization, Scope of Optimization,

local optimization, loop optimization, frequency reduction, folding, DAG

representation.

UNIT – V:

Data flow analysis: Flow graph, data flow equation, global optimization,

redundant sub expression elimination, Induction variable elements, Live

variable analysis, Copy propagation.

Page 3: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation

Object code generation: Object code forms, machine dependent code

optimization, register allocation and assignment generic code generation

algorithms, DAG for register allocation.

TEXT BOOKS :

1. Principles of compiler design -A.V. Aho . J.D.Ullman; Pearson Education.

2. Modern Compiler Implementation in C- Andrew N. Appel, Cambridge

University Press.

REFERENCES BOOKS:

1. lex &yacc – John R. Levine, Tony Mason, Doug Brown, O’reilly

2. Modern Compiler Design- Dick Grune, Henry E. Bal, Cariel T. H. Jacobs,

Wiley dreamtech.

3. Engineering a Compiler-Cooper & Linda, Elsevier.

Page 4: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 5: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 6: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 7: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 8: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 9: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 10: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 11: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 12: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 13: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 14: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 15: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 16: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 17: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 18: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 19: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 20: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 21: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 22: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 23: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 24: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 25: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 26: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 27: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 28: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 29: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 30: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 31: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 32: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 33: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 34: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 35: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 36: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 37: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 38: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 39: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation
Page 40: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation

COMPILER DESIGN IMPORTANT QUESTIONS:UNIT-1

SHORT QUESTIONS:

S. No.

Questions

Bloom’s

Taxonomy Level

1. Define Complier briefly? Understand

2. Explain the cousins of compiler? Understand

3. Define the two main parts of compilation? What they perform? Understand

4. How many phases does analysis consists? Understand

5. Define and explain the Loader? Remember

6. Explain about preprocessor? Remember

7. State the general phases of a compiler? Understand

8. State the rules, and define regular expression? Remember

9. Explain a lexeme and Define regular sets? Remember

10. Explain the issues of lexical analyzer? Understand

11. State some compiler construction tools? Understand

12. Define the term Symbol table? Understand

13. Define the term Interpreter? Remember

14. Define the term Tokens in lexical analysis phase? Understand

15. Explain about error Handler? Understand

16. Define a translator and types of translator? Understand

17. Construct NFA for (a/b)* and convert into DFA? Remember

18. Define bootstrap and cross compiler? Understand

19. Define pass and phase? Understand

20. Analyze the output of syntax analysis phase? What are the three general types of parsers for grammars?

Remember

21. List the different strategies that a parser can employ to recover from a syntactic error?

Understand

22. Explain the goals of error handler in a parser? Understand

23. List different types of compiler? Remember

24. Define the term Tokens in lexical analysis phase? Understand

25. Explain about error Handler? Understand

Page 41: COURSE MATERIAL UNIT-1 · 2020-01-24 · Object code generation: Object code forms, machine dependent code optimization, register allocation and assignment generic code generation

LONG QUESTIONS:

S. No.

Questions

Bloom’s

Taxonomy

Level

1. Define compiler? State various phases of a compiler and explain them in detail.

Understand

2. Explain the various phases of a compiler in detail. Also Write down the output for the following expression after each phase a: =b*c-d.

Apply

3. Describe how various phases could be combined as a pass in a compiler? Also briefly explain Compiler construction tools.

Remember

4. For the following expression

Position:=initial+ rate*60 Write down the output after each phase

Apply

5. Explain the role Lexical Analyzer and issues of Lexical Analyzer. Remember

6. Differentiate the pass and phase in compiler construction? Remember

7. Explain single pass and multi pass compiler? with example? Understand

8. Define bootstrapping concept in brief? Understand

9. Explain the general format of a LEX program with example? Understand