small medium large xlarge

Language Implementation Patterns: Create Your Own Domain-Specific and General Programming Languages


Cover image for Language Implementation Patterns

Language Implementation Patterns

Create Your Own Domain-Specific and General Programming Languages


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.

Customer Reviews

Throw away your compiler theory book! Terence Parr shows how to write
practical parsers, translators, interpreters, and other language
applications using modern tools and design patterns. Whether you’re
designing your own DSL or mining existing code for bugs or gems,
you’ll find example code and suggested patterns in this clearly
written book about all aspects of parsing technology.

- Guido van Rossum

Creator of the Python language

My Dragon book is getting jealous!

- Dan Bornstein

Designer, Dalvik Virtual Machine for the Android platform

This is a book of design patterns that will, frankly, get you right where you need to be.

- J. Stephen Riley Silber

This text is excellent. The exposition plus the examples makes otherwise complex ideas very clear and accessible. Well done!

- Tom Nurkkala

Associate Professor, Computer Science and Engineering, Taylor University

I like Terence’s writing style. He makes the parsing/translation stuff accessible for non-pro developers like me.

- Dominik Holenstein

See All Reviews

Choose Your Format(s)

  • $24.00 In Stock
  • Ebooks are DRM free.

  • Ebook delivery options.

About this Title

Pages: 378
Published: 2009-12-28
Release: P5.0 (2014-09-16)
ISBN: 978-1-93435-645-6

Knowing how to create domain-specific languages (DSLs) can give you a huge productivity boost. Instead of writing code in a general-purpose programming language, you can first build a custom language tailored to make you efficient in a particular domain.

The key is understanding the common patterns found across language implementations. Language Implementation Patterns identifies and condenses the most common design patterns, providing sample implementations of each.

The pattern implementations use Java, but the patterns themselves are completely general. Some of the implementations use the well-known ANTLR parser generator, so readers will find this book an excellent source of ANTLR examples as well. But this book will benefit anyone interested in implementing languages, regardless of their tool of choice. Other language implementation books focus on compilers, which you rarely need in your daily life. Instead, Language Design Patterns shows you patterns you can use for all kinds of language applications.

You’ll learn to create configuration file readers, data readers, model-driven code generators, source-to-source translators, source analyzers, and interpreters. Each chapter groups related design patterns and, in each pattern, you’ll get hands-on experience by building a complete sample implementation. By the time you finish the book, you’ll know how to solve most common language implementation problems.

Contents & Extracts

Full Table of Contents


  • Getting Started with Parsing
    • Language Applications Cracked Open
    • Basic Parsing Patterns
    • Enhanced Parsing Patterns
  • Analyzing Languages
    • Building Intermediate Form Trees excerpt
    • Walking and Rewriting Trees
    • Tracking and Identifying Program Symbols
    • Managing Symbol Tables for Data Aggregates
    • Enforcing Static Typing Rules excerpt
  • Building Interpreters
    • Building High-Level Interpreters
    • Building Bytecode Interpreters
  • Translating and Generating Languages
    • Translating Computer Languages
    • Generating DSLs with Templates
    • Putting it all Together


Terence Parr is a professor of computer science and graduate program director at the University of San Francisco, where he continues to work on his ANTLR parser generator ( and template engine ( Terence has consulted for and held various technical positions at companies such as IBM, Lockheed Missiles and Space, NeXT, and Renault Automation. Terence holds a Ph.D. in computer engineering from Purdue University and was a postdoctoral fellow at the Army High-Performance Computing Research Center at the University of Minnesota, where he built parallelizing FORTRAN source-to-source translators. He is the author of The Definitive ANTLR Reference.