O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Language Implementation Patterns

Book Description

Learn to build configuration file readers, data readers, model-driven code generators, source-to-source translators, source analyzers, and interpreters. You don't need a background in computer science--ANTLR creator Terence Parr demystifies language implementation by breaking it down into the most common design patterns. Pattern by pattern, you'll learn the key skills you need to implement your own computer languages.

Table of Contents

  1. Language Implementation Patterns
    1. Copyright
    2. For the Best Reading Experience...
    3. Table of Contents
    4. What Readers Are Saying About Language Implementation Patterns
    5. Acknowledgments
    6. Preface
      1. What to Expect from This Book
      2. How This Book Is Organized
      3. What You’ll Find in the Patterns
      4. Who Should Read This Book
      5. How to Read This Book
      6. Languages and Tools Used in This Book
    7. Part 1: Getting Started with Parsing
      1. Chapter 1: Language Applications Cracked Open
        1. The Big Picture
        2. A Tour of the Patterns
        3. Dissecting a Few Applications
        4. Choosing Patterns and Assembling Applications
      2. Chapter 2: Basic Parsing Patterns
        1. Identifying Phrase Structure
        2. Building Recursive-Descent Parsers
        3. Parser Construction Using a Grammar DSL
        4. Tokenizing Sentences
      3. Mapping Grammars to Recursive-Descent Recognizers
      4. LL(1) Recursive-Descent Lexer
      5. LL(1) Recursive-Descent Parser
      6. LL(k) Recursive-Descent Parser
        1. Up Next
      7. Chapter 3: Enhanced Parsing Patterns
        1. Parsing with Arbitrary Lookahead
        2. Parsing like a Pack Rat
        3. Directing the Parse with Semantic Information
      8. Backtracking Parser
      9. Memoizing Parser
      10. Predicated Parser
        1. Up Next
    8. Part 2: Analyzing Languages
      1. Chapter 4: Building Intermediate Form Trees
        1. Why We Build Trees
        2. Building Abstract Syntax Trees
        3. Quick Introduction to ANTLR
        4. Constructing ASTs with ANTLR Grammars
      2. Parse Tree
      3. Homogeneous AST
      4. Normalized Heterogeneous AST
      5. Irregular Heterogeneous AST
        1. Up Next
      6. Chapter 5: Walking and Rewriting Trees
        1. Walking Trees and Visitation Order
        2. Encapsulating Node Visitation Code
        3. Automatically Generating Visitors from Grammars
        4. Decoupling Tree Traversal from Pattern Matching
      7. Embedded Heterogeneous Tree Walker
      8. External Tree Visitor
      9. Tree Grammar
      10. Tree Pattern Matcher
        1. Up Next
      11. Chapter 6: Tracking and Identifying Program Symbols
        1. Collecting Information About Program Entities
        2. Grouping Symbols into Scopes
        3. Resolving Symbols
      12. Symbol Table for Monolithic Scope
      13. Symbol Table for Nested Scopes
        1. Up Next
      14. Chapter 7: Managing Symbol Tables for Data Aggregates
        1. Building Scope Trees for Structs
        2. Building Scope Trees for Classes
      15. Symbol Table for Data Aggregates
      16. Symbol Table for Classes
        1. Up Next
      17. Chapter 8: Enforcing Static Typing Rules
      18. Computing Static Expression Types
      19. Automatic Type Promotion
      20. Enforcing Static Type Safety
      21. Enforcing Polymorphic Type Safety
        1. Up Next
    9. Part 3: Building Interpreters
      1. Chapter 9: Building High-Level Interpreters
        1. Designing High-Level Interpreter Memory Systems
        2. Tracking Symbols in High-Level Interpreters
        3. Processing Instructions
      2. Syntax-Directed Interpreter
      3. Tree-Based Interpreter
        1. Up Next
      4. Chapter 10: Building Bytecode Interpreters
        1. Programming Bytecode Interpreters
        2. Defining an Assembly Language Syntax
        3. Bytecode Machine Architecture
        4. Where to Go from Here
      5. Bytecode Assembler
      6. Stack-Based Bytecode Interpreter
      7. Register-Based Bytecode Interpreter
        1. Up Next
    10. Part 4: Translating and Generating Languages
      1. Chapter 11: Translating Computer Languages
        1. Syntax-Directed Translation
        2. Rule-Based Translation
        3. Model-Driven Translation
        4. Constructing a Nested Output Model
      2. Syntax-Directed Translator
      3. Rule-Based Translator
      4. Target-Specific Generator Classes
        1. Up Next
      5. Chapter 12: Generating DSLs with Templates
        1. Getting Started with StringTemplate
        2. Characterizing StringTemplate
        3. Generating Templates from a Simple Input Model
        4. Reusing Templates with a Different Input Model
        5. Using a Tree Grammar to Create Templates
        6. Applying Templates to Lists of Data
        7. Building Retargetable Translators
        8. Up Next
      6. Chapter 13: Putting It All Together
        1. Finding Patterns in Protein Structures
        2. Using a Script to Build 3D Scenes
        3. Processing XML
        4. Reading Generic Configuration Files
        5. Tweaking Source Code
        6. Adding a New Type to Java
        7. Pretty Printing Source Code
        8. Compiling to Machine Code
    11. Bibliography
      1. You May Be Interested In…