This book provides a comprehensive study of all the phases of compiler design and its functions. It aims to equip readers with a thorough understanding of the compiler construction tools and its process, encompassing lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimisation and code generation phases. It also discusses the functions of the symbol table and error handling concepts.
Compiler design is the compulsory course for M.Sc. (Computer Science & IT) and MCA students in most universities. It is designed to help the readers understand the compilation and debugging process of a compiler with suitable examples.
Although this book has been compiled and edited based on the M.Sc. (Computer Science) syllabus of Bharathidasan University, Tiruchirappalli, Tamil Nadu, India, it will be very useful for all computer science, IT and MCA students who wish to learn compiler design.
Contents –
1: INTRODUCTION TO COMPILERS
1.1 Definition of Compiler
1.2 Analysis —Synthesis Model of Compilation
1.3 Analysis of Source Program
1.4 The Phases of Compiler
1.5 Symbol Table
1.6 Error Handling
1.7 Cousins of the Compiler
1.8 Compiler Construction Tools
2: LEXICAL ANALYSER
2.1 Role of Lexical Analyser
2.2 Tokens, Patterns and Lexemes
2.3 Input Buffering
2.4 Specification of Tokens
2.5 Recognition of Tokens
2.6 Finite Automata
2.7 Conversion of Regular Expression to NFA
2.8 Conversion of NFA to DFA
3: SYNTAX ANALYSER
3.1 Role of Parser
3.2 Context-free Grammar
3.3 Parsing
3.3.1 Top-Down Parsing
(A) Recursive Descent Parsing
(B) Non-recursive Descent Parsers
3.3.2 Bottom-Up Parsing
(A) Shift Reduce Parser
(i) Operator-Precedence Parser
(ii) LR Parser
4: SEMANTIC ANALYSER
4.1 Types of Syntactic Errors
4.2 Attribute Grammar
4.3 Evaluation of S-attributed Definition
4.4 Evaluation of L-attributed Definition
CHAPTER 5: INTERMEDIATE CODE GENERATION
5.1 Intermediate Languages
5.2 Graphical Representation
5.3 SDT for Assignment Statement
5.4 SDT for Boolean Expression
5.5 SDT for Control Flow Statements
5.6 SDT for Case Statement
6: CODE OPTIMISATION
6.1 Types of Code Optimisation
6.1.1 Machine Independent Code Optimisation
6.1.2 Machine Dependent Code Optimisation
6.2 Optimisation of Basic Blocks
6.3 Flow Graph
7: CODE GENERATION
7.1 Issues in the Design of Code Generator
7.2 The Target Machine
7.3 Run-time Storage Management
7.4 A Simple Code Generator
7.5 Generating Code from DAG