SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTER SCIENCE AND ENGINEERING DEPARTMENT OF CSE COURSE PLAN Course Code : CS0301 Course Title : Compiler Design Semester : V Course Time : July Dec 2009 Day SECTION A B C D Hour Timing Hour Timing Hour Timing Hour Timing Monday - - 3,7 Tuesday 3,5 11.10 & 1.00 1.50 11.10 & 3.10 4.00 2 - - 2,4 9.20-10.10 Wednesday - - - - - 2,4 Thursday 2,4 2,4 5 1.30-2.20 - - 1,3 3 8.30-9.20 & 11.10 9.20-10.00 & 11.10 11.10 Friday 1 8.30-9.20 6 2.20-3.10 1 2.20-3.10 - - Location : Tech Park Faculty Details Sec. Name Office Office hour Mail id A Prof.S.S.Sridhar Hi-Tech Tuesday (V Floor) Thursday & Friday sssridhar@cse.srmuniv.ac.in B R. JebaKumar It park Monday, (VII Floor) Thursday & Friday rjebakumar@cse.srmuniv.ac.in C K.Senthil Kumar It park Monday,Tuesday (VII Floor) Thursday & Friday ksenthilkumar@cse.srmuniv.ac.in D R.Annie Uthra Hi-Tech Tuesday to (V Floor) Thursday annieuthra@cse.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 CS0204 Theory of Computation Objectives 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 Cycle I : 10 Marks Surprise I : 7 Marks Cycle II : 10 Marks Surprise II : 8 Marks Model Exam : 15 Marks Schedule S.No. DATE TEST TOPICS DURATION 1 Cycle - I Unit I & II 2 periods 2 Cycle - 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 * The various system software concepts and tools * The design aspects of a typical Compiler * To develop a comprehensive compiler for a given language An ability to understand the basic functioning of various system software 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. Sessi on No. 1 2 Topics to be covered Introduction to System Software: Assemblers, Macro, Loader, Linker, Editor, Compiler etc. Assemblers, overview of assembly process, Mnemonic codes Time (min) Ref Teaching Method ing Method 3 Design of two pass assembler 4 Single pass asssembler 5 Macro, Definition, expansion, usage 6 Macro Processor Design, Examples of Macros, 7 8 9 Design of macro preprocessor, macro assembler Loaders, introduction, process of loading Relocatable loader Linkers, introduction, process of linking 50 1,3 BB 50 1,3 BB, 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 Discussion Compiler 11 Illustration of compiling process by Illustration by examples statement example 12 Compiler construction tools 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, Problem solving, conversion surprise test 17 Specification of tokens, Regular grammer Problem solving, to DFA surprise test 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 18 Introduction to Parsing, Top down and Bottom up
19 20 21 22 23 24 25 26 27 Context Free Grammers, Ambiguity in grammars, examples Shift Reduce Parsing Operator Precedence Parsing, Precedence Matrix and Precedence functions Problems in Top down parsing: Left Recursion, Backtracking FIRST and FOLLOW procedures Predictive parsing, Parsing table construction Simple LR Parsing, LR(0) items, parsing table generation Canonical LR, LookAhead LR parsing, Parser generators, design aspects Surprise 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 29 30 31 32 33 Syntax-directed translation: Syntaxdirected definitions, synthesized and inherited attributes 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, 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 41 42 calls Code Optimization- Local optimization techniques Redundant code, constant folding, dead code, basic blocks 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