Course Code : CS0301 Course Title : Compiler Design Semester : V Course Time : July Dec 2011 DAY SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF CSE COURSE PLAN SECTION A B C D E Hour Timing Hour Timing Hour Timing Hour Timing Hour Timing 1 1 8.45-9.35 3 10.35-11.25 5 1.30-2.20 2 4 11.25-12.15 2,6 9.35-10.25, 2.20-3.10 6 2.20-3.10 2 9.35-10.25 3 2 9.35-10.25 5 1.30-2.20 2 9.35-10.25 3 10.35-11.25 3,5 4 1 8.45-9.35, 1 8.45-9.35 8.45-9.35, 5 1,3 4 11.25-12.15 4 11.25-12.15 10.35-11.25 10.35-11.25, 1.30-2.20 Location : S.R.M.E.C Faculty Details SEC NAME OFFICE OFFICE HOUR MAIL ID A Mrs. Jeya 8 th Floor Mon - Fri jeya@ktr.srmuniv.ac.in B Mr. C. Jothi kumar 7 th Floor Mon Fri jothikumar@ktr.srmuniv.ac.in C New Staff 2 Mon Fri D Mr. M. Rajasekaran 7 th Floor Mon Fri rajasekaranm@ktr.srmuniv.ac.in E Mr. M. Raja 7 th Floor Mon - Fri rajam@ktr.srmuniv.ac.in Required Text Books: 1. Alfred V. Aho, Ravi Sethi & Jeffrey. D. Ullman, Compilers Principles, Techniques & Tools,Pearson Education, third edition, 2007. 2. D.M.Dhamdhere, "System Programming and Operating Systems", 2nd Edition., Tata Mcgraw Hill,1995
Web resources http://lambda.uta.edu/cse5317/notes/notes.html www.cs.bilkent.edu.tr/~ilyas/courses/cs416/ Prerequisite : CS0202 Principles of Programming Languages Objectives CS0204 Theory of Computation 1. To study the concepts of Assembler, Macro Processor, Loader and Linker 2. To learn about the various phases of compiler and syntax analysis 3. To learn the various parsing techniques 4. To learn the semantic analysis, translation of statements 5. To learn about Generating and Optimizing codes Assessment Test Schedule Cycle Test I : 10 Marks Surprise Test : 5 Marks Cycle Test II : 10 Marks Model Exam : 20 Marks Attendance : 5 Marks S.No. DATE TEST TOPICS DURATION 1 Cycle Test - I Unit I & II 2 periods 2 Cycle Test - II Unit III & IV 2 periods 3 Model Exam All 5 units 3 Hrs Outcomes Students who have successfully completed this course will have full understanding of the following concepts Course outcome Program outcome To learn An ability to understand the basic functioning of various system software
* The various system software concepts and tools * The design aspects of a typical Compiler * To develop a comprehensive compiler for a given language To analyze and be able to design a compiler To implement various parsing, conversion, optimization and generation algorithms for the design of a compiler Detailed Session Plan ASSEMBLER,MACRO,LOADER & LINKER Assembler: Overview of the assembly process - Design of two pass assembler- Single pass assembler - Macros : Macro definition and usage- schematics for macro expansion - Design of a Macro pre- processor - Design of a Macro assembler ; Introduction to Loaders and Linkers. Sessio n No. Topics to be covered Time (min) Ref Teaching Method Testing Method 1 Introduction to System Software: Assemblers, Macro, Loader, Linker, Editor, Compiler etc. 2 Assemblers, overview of assembly process, Mnemonic codes / practical 3 Design of two pass assembler / practical 4 Single pass asssembler 5 Macro, Definition, expansion, usage / practical 6 Macro Processor Design, Examples of Macros, 7 Design of macro preprocessor, macro assembler, 8 Loaders, introduction, process of loading Relocatable loader 50 1,3 BB / practical 9 Linkers, introduction, process of linking 50 1,3 BB / practical
INTRODUCTION TO COMPILERS Compiler: Introduction - Analysis of the source program - phases of a compiler - Compiler construction tools- Lexical analysis - Role of the lexical analyzer - Specification of tokens Recognition of tokens -Lexical analyzer generators- Design aspects of Lexical Analyzer. 10 Introduction to Compiling, Phases of Compiler Discussion 11 Illustration of compiling process by statement example Illustration by examples 12 Compiler construction tools Test 13 Lexical analysis, Strings, operations on strings,tokens, lexemes, 14 Lexical analyzer generator, design aspects 15 Grammers and Languages, Types of grammers 16 Finite State Automata, DFA,NDFA, conversion Problem solving, surprise test 17 Specification of tokens, Regular grammer to DFA Problem solving, surprise test 18 SYNTAX ANALYSIS PARSING Syntax Analysis: Role of the parser - Context free grammars - Top-down parsing: shift reducepredictive parsing; Bottom-up parsing: Operator precedence, LR parsers (SLR, Canonical LR,LALR) - Parser generators- Design aspects of Parser Introduction to Parsing, Top down and Bottom up 19 Context Free Grammers, Ambiguity in grammars, examples 20 Shift Reduce Parsing 21 Operator Precedence Parsing, Precedence Matrix and Precedence functions Surprise Test 22 Problems in Top down parsing: Left
Recursion, Backtracking 23 FIRST and FOLLOW procedures 24 Predictive parsing, Parsing table construction 25 Simple LR Parsing, LR(0) items, parsing table generation Test Brain storming 26 Canonical LR, LookAhead LR parsing, Test Brain storming 27 Parser generators, design aspects Test Brain storming SEMANTIC ANALYSIS TRANSLATION & RUNTIME STORAGE Syntax-directed translation: Syntax-directed definitions - S-attributed definition - L-attributed definition -Top-down and bottom-up translation- Type checking - Type systems -Specification of a type checker; Run time environment - Source language issues -Storage organization Storage allocation strategies - Access to non-local names - Parameter passing - Symbol tables- Design aspects of Syntax Directed Translation 28 Syntax-directed translation: Syntax-directed definitions, synthesized and inherited attributes 29 S-attributed definition - L-attributed definition 30 Top-down and bottom-up translation- Type checking 31 32 33 Type systems -Specification of a type checker Run time environment -Source language issues, activation record Storage organization Storage allocation strategies,, 34 Access to non-local names - Parameter passing 35 Symbol tables- data structures used 36 Design aspects of Syntax Directed Translation
CODE GENERATION & OPTIMIZATION Intermediate code generation: Intermediate languages - Declaration - Statement - Boolean expression - Procedure calls - Code optimization : Introduction - Sources of optimization - Introduction to data flow analysis- Code generator : Issues in the design of a code generator- the target machine- A simple code generator- Design aspects of Code Optimizer. 37 Intermediate Codes- Syntax tree,quadruple,triple,3address code,prefix,postfix 38 Translation of assignment statements 39 Translation of Boolean expressions, Backpatching 40 Translation of Declaration, procedure calls 41 Code Optimization- Local optimization techniques Redundant code, constant folding, dead code, basic blocks 42 Loop optimization Frequency reduction, Strength reduction, index variable elimination 43 Data flow analysis, peephole optimization 44 Code Generator issues, target machine 45 A simple Code generator, design aspects BB Black Board PP Power Point