The Definitive ANTLR 4 Reference (Pragmatic Bookshelf)

PragmaticBookshelf
Build your own languages with ANTLR v4, using ANTLR’s new advanced parsing technology. In this book, you’ll learn how ANTLR automatically builds a data structure representing the input (parse tree) and generates code that can walk the tree (visitor). You can use that combination to implement data readers, language interpreters, and translators.

Terence Parr @parrt

edited by Susannah Davidson Pfalzer

Build your own languages with ANTLR v4, using ANTLR’s new advanced parsing technology. In this book, you’ll learn how ANTLR automatically builds a data structure representing the input (parse tree) and generates code that can walk the tree (visitor). You can use that combination to implement data readers, language interpreters, and translators.

You’ll start by learning how to identify grammar patterns in language reference manuals and then slowly start building increasingly complex grammars. Next, you’ll build applications based upon those grammars by walking the automatically generated parse trees. Then you’ll tackle some nasty language problems by parsing files containing more than one language (such as XML, Java, and Javadoc). You’ll also see how to take absolute control over parsing by embedding Java actions into the grammar.

You’ll learn directly from well-known parsing expert Terence Parr, the ANTLR creator and project lead. You’ll master ANTLR grammar construction and learn how to build language tools using the built-in parse tree visitor mechanism. The book teaches using real-world examples and shows you how to use ANTLR to build such things as a data file reader, a JSON to XML translator, an R parser, and a Java class→interface extractor. This book is your ticket to becoming a parsing guru!


“ANTLR is an exceptionally powerful and flexible tool for parsing formal languages. At Twitter, we use it exclusively for query parsing in our search engine. Our grammars are clean and concise and the generated code is efficient and stable. This book is our go-to reference for ANTLR v4—engaging writing, clear descriptions and practical examples all in one place.”

–Samuel Luckenbill – Senior Manager of Search Infrastructure – Twitter, Inc.


  • Full details: Search
  • View this book’s portal and details on how to post errata and suggestions here.

Don’t forget you can get 35% off with your Devtalk discount! Just use the coupon code “devtalk.com" at checkout :+1:

Latest Threads About This Book Top

worc4021
Hi @parrt! I’ve been working my way through the antlr4 reference book and having a great time at it. I’ve done all my exercises with th...
New
dtonhofer
@parrt In the context of Chapter 4.3, the grammar Java.g4, meant to parse Java 6 compilation units, no longer passes ANTLR (currently 4....
New
TysonMN
On page 162, it says… Consider the parse tree on the left for input [1^2] in the following diagram: …and on the left is the “Good syn...
New
iPaul
page 37 ANTLRInputStream input = new ANTLRInputStream(is); as of ANTLR 4 .8 should be: CharStream stream = CharStreams.fromStream(i...
New
PragmaticBookshelf
Build your own languages with ANTLR v4, using ANTLR’s new advanced parsing technology. In this book, you’ll learn how ANTLR automatically...
New

Most Active This Week Top

Most Active This Month Top

Most Active This Year Top

worc4021
Hi @parrt! I’ve been working my way through the antlr4 reference book and having a great time at it. I’ve done all my exercises with th...
New

Most Active Last Three Years Top

dtonhofer
@parrt In the context of Chapter 4.3, the grammar Java.g4, meant to parse Java 6 compilation units, no longer passes ANTLR (currently 4....
New

Most Active Over Three Years Top

PragmaticBookshelf
Build your own languages with ANTLR v4, using ANTLR’s new advanced parsing technology. In this book, you’ll learn how ANTLR automatically...
New
iPaul
page 37 ANTLRInputStream input = new ANTLRInputStream(is); as of ANTLR 4 .8 should be: CharStream stream = CharStreams.fromStream(i...
New
TysonMN
On page 162, it says… Consider the parse tree on the left for input [1^2] in the following diagram: …and on the left is the “Good syn...
New

Get money off!

The Pragmatic Bookshelf

35% off any eBook

Simply use coupon code "devtalk.com" at checkout. See full details here.