View Review Details


Book:   The Definitive ANTLR Reference
Subject:   A Perfectly Pragmatic Guide!
Date:   2007-06-11 20:07:44
From:   Anonymous Reader
Rating:  StarStarStarStarStar

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!


The Definitive ANTLR Reference