COMPILER DESIGN G. Appasami, M.Sc., M.C.A., M.Phil., M.Tech., (Ph.D.) Assistant Professor Department of Computer Science and Engineering Dr. Paul’s Engineering Collage Pauls Nagar, Villupuram Tamilnadu, India SARUMATHI PUBLICATIONS Villupuram, Tamilnadu, India
First Edition: July 2015 Second Edition: April 2016 Published By SARUMATHI PUBLICATIONS © All rights reserved. No part of this publication can be reproduced or stored in any form or by means of photocopy, recording or otherwise without the prior written permission of the author. Price Rs. 101/- Copies can be had from SARUMATHI PUBLICATIONS Villupuram, Tamilnadu, India. Sarumathi.firstname.lastname@example.org Printed at Meenam Offset Pondicherry – 605001, India
CS6660 COMPILER DESIGN LTPC 3003 UNIT I INTRODUCTION TO COMPILERS 5 Translators-Compilation and Interpretation-Language processors -The Phases of CompilerErrors Encountered in Different Phases-The Grouping of Phases-Compiler Construction Tools - Programming Language basics. UNIT II LEXICAL ANALYSIS 9 Need and Role of Lexical Analyzer-Lexical Errors-Expressing Tokens by Regular Expressions- Converting Regular Expression to DFA- Minimization of DFA-Language for Specifying Lexical Analyzers-LEX-Design of Lexical Analyzer for a sample Language. UNIT III SYNTAX ANALYSIS 10 Need and Role of the Parser-Context Free Grammars -Top Down Parsing -General Strategies- Recursive Descent Parser Predictive Parser-LL(1) Parser-Shift Reduce ParserLR Parser-LR (0) Item-Construction of SLR Parsing Table -Introduction to LALR Parser Error Handling and Recovery in Syntax Analyzer-YACC-Design of a syntax Analyzer for a Sample Language . UNIT IV SYNTAX DIRECTED TRANSLATION & RUN TIME ENVIRONMENT 12 Syntax directed Definitions-Construction of Syntax Tree-Bottom-up Evaluation of SAttribute Definitions- Design of predictive translator - Type Systems-Specification of a simple type checker- Equivalence of Type Expressions-Type Conversions. RUN-TIME ENVIRONMENT: Source Language Issues-Storage Organization-Storage Allocation- Parameter Passing-Symbol Tables-Dynamic Storage Allocation-Storage Allocation in FORTAN. UNIT V CODE OPTIMIZATION AND CODE GENERATION 9 Principal Sources of Optimization-DAG- Optimization of Basic Blocks-Global Data Flow Analysis- Efficient Data Flow Algorithms-Issues in Design of a Code Generator - A Simple Code Generator Algorithm. TOTAL: 45 PERIODS TEXTBOOK: 1. Alfred V Aho, Monica S. Lam, Ravi Sethi and Jeffrey D Ullman, “Compilers – Principles, Techniques and Tools”, 2nd Edition, Pearson Education, 2007. REFERENCES: 1. Randy Allen, Ken Kennedy, “Optimizing Compilers for Modern Architectures: A Dependence-based Approach”, Morgan Kaufmann Publishers, 2002. 2. Steven S. Muchnick, “Advanced Compiler Design and Implementation, “Morgan Kaufmann Publishers - Elsevier Science, India, Indian Reprint 2003. 3. Keith D Cooper and Linda Torczon, “Engineering a Compiler”, Morgan Kaufmann Publishers Elsevier Science, 2004. 4. Charles N. Fischer, Richard. J. LeBlanc, “Crafting a Compiler with C”, Pearson Education, 2008.
Acknowledgement I am very much grateful to the management of paul’s educational trust, Respected principal Dr. Y. R. M. Rao, M.E., Ph.D., cherished Dean Dr. E. Mariappane, M.E., Ph.D., and helpful Head of the department Mr. M. G. Lavakumar M.E., (Ph.D.). I thank my colleagues and friends for their cooperation and their support in my career venture. I thank my parents and family members for their valuable support in completion of the book successfully. I express my special thanks to SARUMATHI PUBLICATIONS for their continued cooperation in shaping the work. Suggestions and comments to improve the text are very much solicitated. Mr. G. Appasami