This entirely revised second edition of Engineering a Compiler is full of technical updates and new material covering the latest developments in compiler technology. In this comprehensive text you will learn important techniques for constructing a modern compiler. Leading educators and researchers Keith Cooper and Linda Torczon combine basic principles with pragmatic insights from their experience building state-of-the-art compilers. They will help you fully understand important techniques such as compilation of imperative and object-oriented languages, construction of static single assignment forms, instruction scheduling, and graph-coloring register allocation.

Key Features

  • In-depth treatment of algorithms and techniques used in the front end of a modern compiler
  • Focus on code optimization and code generation, the primary areas of recent research and development
  • Improvements in presentation including conceptual overviews for each chapter, summaries and review questions for sections, and prominent placement of definitions for new terms
  • Examples drawn from several different programming languages
  • Readership

    Primarily graduate, some undergraduate students in computer science; professional compiler writers, system software developers, architects and computer system designers

    Table of Contents

    CHAPTER 1 Overview of Compilation

    1.1 Introduction

    1.2 Compiler Structure

    1.3 Overview of Translation

    1.3.1 The Front End

    1.3.2 The Optimizer

    1.3.3 The Back End

    1.4 Summary and Perspective

    CHAPTER 2 Scanners

    2.1 Introduction

    2.2 Recognizing Words

    2.2.1 A Formalism for Recognizers

    2.2.2 Recognizing More Complex Words

    2.3 Regular Expressions

    2.3.1 Formalizing the Notation

    2.3.2 Examples

    2.3.3 Closure Properties of REs

    2.4 From Regular Expression to Scanner

    2.4.1 Nondeterministic Finite Automata

    2.4.2 Regular Expression to NFA: Thompson’s Construction

    2.4.3 NFA to DFA: The Subset Construction

    2.4.4 DFA to Minimal DFA: Hopcroft’s Algorithm

    2.4.5 Using a DFA as a Recognizer

    2.5 Implementing Scanners

    2.5.1 Table-Driven Scanners

    2.5.2 Direct-Coded Scanners

    2.5.3 Hand-coded Scanners

    2.5.4 Handling Keywords

    2.6 Advanced Topics

    2.6.1 DFA to Regular Expression

    2.6.2 Another Approach to DFA Minimization: Brzozowski’s Algorithm

    2.6.3 Closure-free Regular Expressions

    2.7 Chapter Summary and Perspective

    CHAPTER 3 Parsers

    3.1 Introduction

    3.2 Expressing Syntax

    3.2.1 Why Not Regular Expressions?

    3.2.2 Context-Free Grammars

    3.2.3 More Complex Examples

    3.2.4 Encoding Meaning into Structure

    3.2.5 Discovering a Derivation for an Input String

    3.3 Top-Down Parsing

    3.3.1 Transforming a Grammar for Top-Down Parsing

    3.3.2 Top-Down Recursive-Descent Parsers

    3.3.3 Table-Driven LL(1) Parsers

    3.4 Bottom-Up Parsing

    3.4.1 The LR(1) Parsing Algorithm

    3.4.2 Building LR(1) Tables

    3.4.3 Errors in the Table Construction

    3.5 Practical Issues

    3.5.1 Error Recovery

    3.5.2 Unary Operators

    3.5.3 Handl


    No. of pages:
    © 2011
    Morgan Kaufmann
    eBook ISBN:
    Print ISBN:
    Print ISBN:


    "Keith Cooper and Linda Torczon are leading compilers researchers who have also built several state-of-the-art compilers. This book adeptly spans both worlds, by explaining both time-tested techniques and new algorithms, and by providing practical advice on engineering and constructing a compiler. Engineering a Compiler is a rich survey and exposition of the important techniques necessary to build a modern compiler."--Jim Larus, Microsoft Research

    "The book is well written, and well supported with diagrams, tables, and illustrative examples. It is a suitable textbook for use in a compilers course at the undergraduate or graduate level, where the primary focus of the course is code optimization."--ACM’s Computing

    "This book is a wealth of useful information, prepared didactically, with many helpful hints, historical indications, and suggestions for further reading. It is a helpful working book for undergraduate and intermediate-level students, written by authors with an excellent professional and teaching background. An engineer will use the book as a general reference. For special topics, an ambitious reader will consult more recent publications in the subject area."--ACM’s Computing