You are previewing Compilers: Principles and Practice.
O'Reilly logo
Compilers: Principles and Practice

Book Description

Compilers: Principles and Practice explains the phases and implementation of compilers and interpreters, using a large number of real-life examples. It includes examples from modern software practices such as Linux, GNU Compiler Collection (GCC) and Perl. This book has been class-tested and tuned to the requirements of undergraduate computer engineering courses across universities in India.

Table of Contents

  1. Cover
  2. Title Page
  3. Contents
  4. Dedication
  5. List of Figures
  6. List of Tables
  7. List of Algorithms
  8. Preface
  9. Chapter 1 Introduction
    1. 1.1 Languages
    2. 1.2 Translation Process
    3. 1.3 Translation Schemes
    4. 1.4 Theoretical Viewpoint
    5. 1.5 Phases of a Compiler
    6. 1.6 A More Detailed Look at Phases of a Compiler
    7. 1.7 A Real-life Compiler – gcc
    8. 1.8 What Do We Mean by “Meaning”?
    9. Looking Forward
    10. Historical Notes
    11. Exercises
    12. Web Resources
    13. Glossary
  10. Chapter 2 A Simple Translator
    1. 2.1 A Simple Language
    2. 2.2 Compiler for Simple
    3. 2.3 A Virtual Machine for Simple
    4. Looking Forward
    5. Exercises
    6. Web Resources
    7. Glossary
  11. Chapter 3 Lexical Analyzer
    1. 3.1 Scanner
    2. 3.2 Symbol Tables and a Scanner
    3. 3.3 Compiler Writing Tools
    4. 3.4 Error Handling in a Scanner
    5. Exercises
    6. Web Resources
    7. Glossary
  12. Chapter 4 Syntax Analyzer
    1. 4.1 Top-down and Bottom-up Parsing
    2. 4.2 Top-down Parsing
    3. 4.3 Bottom-up Parsing
    4. 4.4 Yacc – A Parser Generator
    5. 4.5 Other Parser Generators
    6. 4.6 Grammar for miniC
    7. 4.7 Symbol Table and Parser
    8. 4.8 Real-life – GCC: GNU Compiler Collection
    9. Exercises
    10. Web Resources
    11. Further reading
    12. Glossary
  13. Chapter 5 Syntax-directed Translation
    1. 5.1 Implicit Stacking in RDP
    2. 5.2 Synchronized Semantic Stacks
    3. 5.3 Action Symbols
    4. 5.4 Attribute Grammars
    5. 5.5 Symbol Table Handling
    6. 5.6 Intermediate Representation Output for miniC
    7. Exercises
    8. Web Resources
    9. Further Reading
    10. Glossary
  14. Chapter 6 Type Checking
    1. 6.1 Data Types and Type Checking
    2. 6.2 Type Expressions and Type Constructors
    3. 6.3 Type Equivalence
    4. 6.4 Type Names, Declarations and Recursive Types
    5. 6.5 Type Inference
    6. 6.6 Type Conversion and Coercion
    7. 6.7 Overloading of Operators and Functions
    8. 6.8 Example: Type Checking in an Interpreter
    9. Exercises
    10. Web Resources
    11. Further Reading
    12. Glossary
  15. Chapter 7 Run-Time Environment
    1. 7.1 Run-Time Storage Allocation
    2. 7.2 Operating System
    3. 7.3 Libraries
    4. 7.4 System Environmental Variables
    5. 7.5 Invocation Command-line Parameters
    6. Exercises
    7. Web Resources
    8. Further Reading
    9. Glossary
  16. Chapter 8 Intermediate Code
    1. 8.1 Building a Parse Tree
    2. 8.2 Polish Notation
    3. 8.3 N-tuple Notation
    4. 8.4 Abstract Syntax Tree
    5. 8.5 Abstract or Virtual Machine Code
    6. 8.6 Threaded Code
    7. 8.7 SECD and WAM
    8. 8.8 Grammar and IR Generation for miniC
    9. 8.9 Real-life: Intermediate Codes of GNU gcc
    10. Exercises
    11. Further Reading
    12. Glossary
  17. Chapter 9 Code Generation and Machine-dependent Optimization
    1. 9.1 Our Concerns in Code Generation
    2. 9.2 The Target Language
    3. 9.3 Data Structures
    4. 9.4 Control Constructs
    5. 9.5 Procedures and Function Calls
    6. 9.6 The Target Operating Environment
    7. 9.7 Code Optimization
    8. 9.8 Machine-dependent Optimization
    9. 9.9 Converting the 4-tuple and RPN into Assembly Code
    10. Exercises
    11. Further Reading
    12. Glossary
  18. Chapter 10 Code Optimization
    1. 10.1 Basic Blocks
    2. 10.2 Value Numbering Scheme
    3. 10.3 Peep-hole Optimization
    4. 10.4 Structural Optimization
    5. 10.5 Global Data-flow Analysis
    6. 10.6 Super-optimizers
    7. 10.7 Epilogue
    8. Exercises
    9. Further Reading
    10. Glossary
  19. Chapter 11 Overview of Processing of Some Languages
    1. 11.1 Java
    2. 11.2 Perl
    3. 11.3 PROLOG
    4. 11.4 FORTH
    5. Exercises
    6. Web Resources
  20. Chapter 12 Project: Compiler for a miniC
    1. 12.1 MiniC Language
    2. 12.2 Architecture of miniC Compiler
    3. 12.3 MiniC Grammar for yacc
    4. 12.4 Target Language
    5. 12.5 Symbol Table
    6. 12.6 Scanner
    7. 12.7 Parser
    8. 12.8 Code Generation
    9. 12.9 Testing
    10. 12.10 Use of gdb to Debug the FPU Operations
    11. 12.11 Difference Between AT&T and Intel Assembly Syntax
    12. Exercises
    13. Further Reading and Web Resources
  21. Appendix A Formal Languages and Automata
    1. A.1 Essential Mathematical Background
    2. A.2 Formal Language Theory Review
    3. A.3 Grammars
    4. A.4 Regular Languages, Regular Expressions and Finite-state Machine
    5. A.5 Context-free Languages, CFG and Push-down Automata
    6. Exercises
    7. Glossary
  22. Appendix B Assemblers and Macro Processors
    1. B.1 Assembly Languages
    2. B.2 Assemblers
    3. B.3 Macro Processors
    4. Exercises
  23. Appendix C Linkers and Loaders
    1. C.1 Linkers
    2. C.2 A Typical Linking Loader
    3. C.3 In Linux World
    4. C.4 Loaders
  24. Appendix D Worked-out Problems
    1. D.1 Problems for Chapter 4: Parsers
    2. D.2 Problems for Chapter 5: Syntax-directed Translation
    3. D.3 Problems for Chapter 6: Type Checking
    4. D.4 Problems for Chapter 7: Run-Time Environment
  25. Bibliography
  26. Acknowledgements
  27. Copyright