The Definitive ANTLR Reference
Building Domain-Specific Languages
Publisher: Pragmatic Bookshelf
Released: May 2007
Pages: 376

ANTLR v3 is the most powerful, easy-to-use parser generator built to date, and represents the culmination of more than 15 years of research by Terence Parr. This book is the essential reference guide to using this completely rebuilt version of ANTLR, with its amazing new LL() parsing technology, tree construction facilities, StringTemplate code generation template engine, and sophisticated ANTLRWorks GUI development environment. Learn to use ANTLR directly from the author!

ANTLR is a parser generator-a program that generates code to translate a specified input language into a nice, tidy data structure. You might think that parser generators are only used to build compilers. But in fact, programmers usually use parser generators to build translators and interpreters for domain-specific languages such as proprietary data formats, common network protocols, text processing languages, and domain-specific programming languages.

Domain-specific languages are important to software development because they represent a more natural, high fidelity, robust, and maintainable means of encoding a problem than simply writing software in a general-purpose language. For example, NASA uses domain-specific command languages for space missions to improve reliability, reduce risk, reduce cost, and increase the speed of development. Even the first Apollo guidance control computer from the 1960s used a domain-specific language that supported vector computations.

This book is the definitive guide to using the completely rebuilt ANTLR v3 and describes all features in detail, including the amazing new LL(

) parsing technology, tree construction facilities, StringTemplate code generation template engine, and sophisticated ANTLRWorks GUI development environment. You'll learn all about ANTLR grammar syntax, resolving grammar ambiguities, parser fault tolerance and error reporting, embedding actions to interpret or translate languages, building intermediate-form trees, extracting information from trees, generating source code, and how to use the ANTLR Java API.
Product Details
About the Author
Recommended for You
Customer Reviews

REVIEW SNAPSHOT®

by PowerReviews
oreillyThe Definitive ANTLR Reference
 
5.0

(based on 1 review)

Ratings Distribution

  • 5 Stars

     

    (1)

  • 4 Stars

     

    (0)

  • 3 Stars

     

    (0)

  • 2 Stars

     

    (0)

  • 1 Stars

     

    (0)

Reviewed by 1 customer

Displaying review 1

Back to top

 
5.0

A Perfectly Pragmatic Guide!

By Anonymous

from Undisclosed

Comments about oreilly The Definitive ANTLR Reference:

If you have any interest in compiler design, building translators, building intelligent editors, code generation, understanding what goes into building your own computer language, or just how to use ANTLR v3 then you may want to get a copy of this book.

This book is all about ANTLR. ANTLR is a tool you can use to build compilers and interpreters for computer languages, but don't let that scare you off. With the increasing interest in domain specific languages, building intelligent editors, code generation, and model driven development books like this are becoming ever more important. Terence Parr has made the topic far more approachable than any other book I have read (or attempted to read) on the topic.

In the first few chapters the author walks readers through the phases of parser construction using language that is approachable and easy to understand. He explains the needed principles and demonstrates their application with well chosen examples.

This is followed by a quick tour of how one might use ANTLR. I love the approach taken in this chapter as it takes a small example and shows two different ways to approach the problem using ANTLR. This is coupled with explanations describing when you want to use one approach over another.

The middle section of the book goes into depth on the various aspects of ANTLR. This is the reference section. Don't expect to be able to read these chapters one after another in quick succession. There's just too much to take in all at once!

The text is littered with references both forward and back to other sections and topics of interest. You can tell the author has spent a lot of time working with compiler construction by the breadth and depth of information presented. I really liked the motivating examples he gives for certain ANTLR features such as the need to emit imaginary tokens when lexing python (see page 94 in chapter 4).

The first chapter of part three of the book delves into the depths of the parsing algorithm used in ANTLR since you will need to understand it when you run into parsing errors and need to make sense of them.

The remaining chapters are devoted to ways to deal with the problems you may run into when trying to parse various language constructs.

This book has left a very lasting impression on me. I can visualize what goes into an editor like eclipse more fully. I no longer feel that the topic of abstract syntax trees is above my head and I feel I am better equipped to tackle the dragon book. I also understand why lisp programmers say that lisp has no syntax (take a look at the serialized form of the AST from chapter 3 on page 62, it looks like a bunch of s-expressions!).

One more note: ANTLR itself is a domain specific language (DSL) and serves as a prime example of how a DSL can greatly increase the clarity of the solution to a problem if the solution is described in terms native to the problem domain. (I think that's what the folks in the lisp camp have been saying for a long time.) ANTLR helps show the value of having DSLs and this book shows how easy it can be to write one!

Displaying review 1

Back to top

 
Buy 2 Get 1 Free Free Shipping Guarantee
Buying Options