Home | Download | Wiki | About ANTLR | Feedback | Support |


Latest version is 2.7.7.
Download now! »

Download
» Home
» Download
» News
»Using ANTLR
» Documentation
» Wiki
» FAQ
» Articles
» Grammars
» File Sharing
» Code API
» Tech Support
» Bug Tracking
»About ANTLR
» What is ANTLR
» Why use ANTLR
» Showcase
» Testimonials
» Getting Started
» Software License
» ANTLR WebLogs
» ANTLR Workshops
»StringTemplate
»TML
»PCCTS
»Feedback
»Credits
»Contact


Support StringTemplate, ANTLR Project by making a donation! Terence often pays for things like the antlr.org server, conference travel, and this site design (that alone cost US$1000). Buy him a beer and pizza remotely ;)

Search



Article List

Add Article

Highlights

ANTLR v3 overview [ppt]
Terence Parr Fri May 11, 2007 13:31
A summary of v3 from ANTLR2005 workshop. Here is the lecture mp3 audio...

ANTLRWorks: An ANTLR Grammar Development Environment [DRAFT]
Jean Bovet and Terence Parr Mon Jul 9, 2007 17:15
A journal paper Jean and I wrote about ANTLRWorks and ANTLR's LL(*) parsing...


RSS Feed


ANTLR via Clojure
Brian Carper (Submitted by TJP) Sun Jul 18, 2010 07:34
Can you use ANTLR from Clojure? Sure. Would you want to? Maybe. Here's how to do it, start to finish.

Learning ANTLR
Bill Bejeck Fri Mar 5, 2010 19:31
A tutorial on getting started with ANTLR. Covers the basics of writing a simple grammar

ANTLR 3.x Video Tutorial
Scott Stanchfield Mon Dec 14, 2009 11:26
I've converted my ANTLR 2.x tutorial to ANTLR 3.x in the most lazy way possible - video!

Implementing parsers and state machines in Java
Terence Parr Fri Oct 2, 2009 15:39
Slides and video for my talk at 2009 JVM language summit. Topics: Generated method size in parsers, Why I need DFA in my parsers, Implementing DFA in Java, Predicated DFA edges, My kingdom for dynamic scoping, Exceptions for flow-control, Computed gotos for interpreter instruction dispatch.

Write Your Own Language With ANTLR 3 and the DLR
Dermot Hogan Tue Sep 2, 2008 10:47
Ever had trouble learning a computer language in the past? Well why not dump the C++ manuals and start writing your very own language to do exactly what you want? If this sounds impossibly difficult, or only suitable for Computer Science professors ? it was until very recently. But two new developments have made language writing (as opposed to reading) possible for mere mortals. The first is ANTLR3- a totally new version of the highly popular ANTLR2 parser system. And the second is Microsoft?s revolutionary Dynamic Language Runtime.

ANTLR 3.0
Mark Volkmann Mon Jun 2, 2008 12:18
A large article talking about how to use ANTLR 3.0.

The Reuse of Grammars with Embedded Semantic Actions
Terence Parr Thu Apr 3, 2008 10:33
My keynote paper for IEEE International Conference on Program Comprehension 2008

Abstract
Reusing syntax specifications without embedded arbitrary semantic actions is straightforward because the semantic analysis phases of new applications can feed off trees or other intermediate structures constructed by the pre-existing parser. The presence of arbitrary embedded semantic actions, however, makes reuse difficult with existing mechanisms such as grammar inheritance and modules. This short paper proposes a mechanism based upon prototype grammars that automatically pushes changes from prototypes to derived grammars even in the presence of semantic actions. The prototype mechanism alone would be unsuitable for creating a new grammar from multiple preexisting grammars. When combined with grammar composition, however, the prototype mechanism would improve grammar reuse because imported pre-existing grammars could be altered to suit each new application.

Create Domain-Specific Languages with ANTLR
Rod Coffin and Paul Holser Wed Nov 14, 2007 11:47


more ANTLR - Java, and comparisons to PLY and PyParsing
Andrew Dalke Sun Nov 4, 2007 14:23
There are several reasons to use ANTLR over one of the Python parsers like PLY and PyParsing. The GUI interface is very nice, it has a sophisticated understanding of how to define a grammar, it's top-down approach means the generated code is easier to understand, tree-grammars simplify some otherwise tedious parts of writing parsers, and the one I'll talk about now - it supports multiple output languages.

ANTLR rules
Andrew Dalke Fri Nov 2, 2007 10:05
Previously I showed how to use ANTLR to build a AST from a molecular formula then evaluate that AST to calculate the molecular weight. For complex grammars it's often useful to work with and transform parse trees, which I'll probably talk about when I get into developing a SMARTS

Fun With Compilers...Really
Larry O'Brien Thu Nov 1, 2007 11:02
Compilers and translators are not very commonly required to solve business needs, but not every data-source produces library-parsable XML, and the tools needed to transform structured-but-untagged data are the same ones that are used to emit code. And while the topic of parsing text is deep enough to warrant thick books, the types of input that a business developer is likely to face are usually easily tackled with modern tools. When a translation or code-generation problem arises in discussion, your pulse should quicken from excitement rather than fear.

Calculating molecular weight with ANTLR
Andrew Dalke Wed Oct 31, 2007 12:25
Parse molecular formulas (like "HC3COOH") and generate the molecular weight using ANTLR v3 and ANTLRWorks.

ANTLRWorks: An ANTLR Grammar Development Environment [DRAFT]
Jean Bovet and Terence Parr Mon Jul 9, 2007 17:15
A journal paper Jean and I wrote about ANTLRWorks and ANTLR's LL(*) parsing stuff.

A Perfectly Pragmatic Guide!
posted anonymously at O'Reilly Tue Jun 12, 2007 13:26
A book review of "The Definitive ANTLR Reference".

jboss interview with Antlr 3.0 author Terence Parr
Terence Parr Wed Jun 6, 2007 11:05
A fairly detailed interview.

State of the Art Expression Evaluation
Sebastien Ros Wed May 23, 2007 10:29
A tutorial on how to realize an expression evaluator in CSharp with ANTLR

Artima.com Interview with Terence Parr
Terence Parr Fri May 18, 2007 11:17


Semantic predicate hoisting [ppt]
Terence Parr Fri May 11, 2007 13:32
A description of how semantic predicates get hoisted into parsing decisions from ANTLR2005 workshop.

LL(*) parsing [ppt]
Terence Parr Fri May 11, 2007 13:32
A description of the parsing strategy ANTLR v3 uses from ANTLR2005 workshop.

ANTLR v3 overview [ppt]
Terence Parr Fri May 11, 2007 13:31
A summary of v3 from ANTLR2005 workshop. Here is the lecture mp3 audio (40M and cut off a bit).

CSharp to PL/SQL (with v3)
Aaron Feng Sun Apr 15, 2007 15:10
After reading the ANTLR v3 book, I decided to build a simple translator that will recognize C# like syntax and output PL/SQL.

The Language from the Dragon Book in ANTLR
Stephen A. Edwards Sat Feb 17, 2007 10:52
The second edition of the Dragon book1 describes the implementation of a compiler for a little imperative language. This compiler, described in Appendix A, is written entirely in Java with a handwritten lexical analyzer and recursive-des cent parser and produces three-address code. Here, I implement the same language using the ANTLR compiler generator tool.

Automated Translation of Java to Python
troy at gci dot net Thu Feb 15, 2007 10:53
I've written a tool to automatically translate Java source code to Python source code. The tool is useful, and it's already working for me as I intended. It's called java2python (clever, no?) and you can download it here.

Manual Tree Walking Is Better Than Tree Grammars
Andy Tripp Sun Feb 4, 2007 07:25
A comparison between using ANLTR treewalkers and walking an AST "by hand" when doing language translation.

Implementing a scripting language with Antlr
Alex Miller Tue Jan 16, 2007 15:50
Recently I implemented a small scripting language with Antlr and I thought it would make for a good mid-level example.

ANTLR Overview
Manuel Abadia Sun Jan 14, 2007 02:49
This article gives a global vision about all the classes and interfaces involved when creating lexers, parsers and tree parsers.

eclipse-magazin Volume 9 : Article on ANTLR ( in German)
Dominik Holenstein Thu Nov 23, 2006 12:07
This article is not available online (yet?). It features an introduction to the theory of parsing (Chomsky Hierarchy, LL-Parser, look-ahead etc.) including a short and simple tutorial (converting a csv file to a HTML table). ANTLR v2.7.6 is used and the Eclipse based ANTLR Studio plug-in developed by Prashant Deva.

Using ANTLR while creating IDEs
Prashant Deva Mon Sep 25, 2006 02:24
See how to use ANTLR while designing commercial quality IDEs and editors.

ANTLR Yggdrasil whitepaper/manual
Loring Craymer Tue Jul 25, 2006 13:33
ANTLR Yggdrasil is variant of ANTLR with strongly typed attributes. The development goal is to support rapid development of tree transformations and tree grammars.

ANTLR By Example
Jason Sankey Wed Jul 19, 2006 02:03
A five part tutorial showing how to parse a simple boolean expresion language. Shows the lexer, parser and tree parser. Based on a real-life application (the Pulse automated build server).

Building a constraints language with ANTLR
Julien Ponge Thu Jul 6, 2006 18:26
This article describes a constraints language implementation using ANTLR.

Manual Tree Manual
Michael Barnett Sun Jan 22, 2006 13:15
This document describes:

  1. How to write Antlr rules that construct trees of various shapes.
  2. How to write manual tree construction semantic actions. While the automatic tree construction of Antlr is usually what one wants to use, there are situations where one needs/wants to perform manual tree construction.
  3. How to write tree parser rules that explore the abstract syntax trees in a different order than the default left-to-right depth-first traversal.


Why I Don't Use StringTemplate For Language Translation
Andy Tripp Tue Jan 10, 2006 10:22
[Discussion here; look for subject "New article on StringTemplates and Treewalkers"] The case against AST treewalking and StringTemplate approaches for high-level language translation.

Debugging ANTLR grammars using ANTLR Studio
Prashant Deva Tue Jan 3, 2006 08:09
Debug grammar files with ease using ANTLR Studio.

Understanding ANTLR Grammar Files
Prashant Deva Thu Jun 23, 2005 15:32
Confused by all the different sections of an Antlr Grammar file. Take a look here and see how simple it all is.

Attribute Unification Proposal
Loring Craymer Tue May 17, 2005 01:50
An implementation model and syntax that integrates many of the attribute features discussed on the mailing list and elsewhere.

Humans Should Not Have To Grok XML
Terence Parr Thu Apr 21, 2005 10:13
XML makes a lousy human interface, but it's fine for data. ANT and RESIN and all you other xml-based config people please take note. Ugh. Heinous stuff.

Language Translation Using ANTLR and StringTemplate
Terence Parr Tue Feb 15, 2005 18:23
This article demonstrates how to translate a very simple C dialect, which I will call "C-" in honor of the grades I received in college, to three different languages, again using a single model and controller with multiple views. The targets are Java, Python, and bytecodes similar to the Jasmin Java bytecode assembler format. Merely swapping in a new template file generates completely different output without even recompiling the translator!

Translators Should Use Tree Grammars
Terence Parr Mon Nov 15, 2004 17:50
One of the most common questions programmers have when building a translator is, "what do I do with my AST now that I've built it?" Their first reaction is to use a visitor pattern that essentially does a depth-first-walk of the tree, executing an "action" method at each node. While easy to understand, this approach is not useful except for the simplest of translators. This small article illustrates the limitations of visitors and hints at the power of tree grammars.

Getting ANTLR to run on Cygwin and GCJ
Tom Verbeure Mon May 17, 2004 06:18
A recipe to get a working ANTLR system with Cygwin and GCJ.

Gu?a pr?ctica de ANTLR 2.7.2
Enrique Jos? Garc?a Cota Thu Jan 15, 2004 06:03
This is my end-of-studies project. It's a 450 pages book about ANTLR and compilers. It's in spanish. If you like ANTLR y entiendes espa?ol, you should have a look! You can download this other file: http://www.lsi.us.es/~troyano/documentos/guia-cap.zip if you want to have every chapter on a separated PDF file.

Syntax Directed TokenStream Rewriting
Terence Parr Sun Dec 14, 2003 15:00
There are many common situations where you want to tweak or augment a program or data file, but this has been hard since you have to add actions all over your grammar to spit the input back out. This article describes a very simple TokenStream buffer called TokenStreamRewriteEngine that makes it very easy to tweak files like SED on steroids. :)

Debugging and Testing Grammars With Parse Trees and Derivations
Terence Parr Sun Nov 30, 2003 20:54
Debugging big grammars is very difficult because the Human mind cannot easily trace the highly nested and recursive nature of parsing. This article describes a simple mechanism for getting parse trees / derivation sequences from your grammar for debugging and unit testing purposes; all without modifying ANTLR itself.

Enforcing Model-View Separation in Template Engines
Terence Parr Wed Nov 12, 2003 22:43
Formally defines output templates, template generational power, and business-logic/template separation rules. Both theoretically and empirically, shows strict separation of logic and display does not emasculate template generational power. Demonstrates StringTemplate at work solving some interesting HTML generation tasks.

Preserving Original Token Sequence In ASTs
Terence Parr Fri Sep 5, 2003 17:15
You want ASTs instead of parse trees for translation, but ASTs have the token order shuffled from the one-dimensional input sequence into a two-dimensional tree structure. Consequently, it is often hard to spit the original token sequence back out. You are required to build a tree walker that spits text back out. This article describes an experimental means of supporting easy x to x translation without modifying ANTLR itself. I provide modified token, token stream, tree node, and AST factory objects along with a simple grammar to demonstrate their use. This is damn cool stuff and will be standard equipment on ANTLR 3.

Selectively Matching XML Tag
Terence Parr Tue Jul 22, 2003 20:01
Title says it all :)

We Are Talking Really Big Lexical Lookahead Here
Terence Parr Tue Jul 22, 2003 20:00
This entry describes a tool that creates an HTML page echoing back the tag/value pairs obtained via an HTML <form> data entry page.

Practical Computer Language Recognition and Translation
Terence Parr Tue Jul 22, 2003 13:14
My next book, work in progress (haven't touched in a while), but you should read the "building translators by hand" chapter for sure if you are just getting started.

ANTLR: A Predicated-LL(k) Parser Generator
Terence Parr and Russell Quong Fri Jun 13, 2003 17:25
This article appeared in the Journal of Software Practice and Experience, Vol. 25(7), 789-810 (July 1995). It summarizes the features of ANTLR from the PCCTS 1.33 days and why they represent a major step forward in practical parsing technology. ANTLR's ease of use and strong language recognition capability has made it one of the most popular language tools around.

Compiler Construction with ANTLR and Java
Gary L. Schaps Fri Jun 13, 2003 17:23
A nice article by Gary about his experience using ANTLR to build a pattern language for an integrated circuit tester.

Symbolic Differentiation Part II
Terry Brugger Fri Jun 13, 2003 17:15
How to build the trees for the PolyParser.

Symbolic Differentiation Part I
Terry Brugger Fri Jun 13, 2003 17:14
This entry in the field guide presents the Tutorial from Terence's Book ported into ANTLR 2. It is written from my experience as a developer who was already familiar with Java and parsing. It assumes that you have a copy of Terence's Book, as I will refer directly to the pages therein.

ANTLR Meets Sed
Terence Parr Fri Jun 13, 2003 17:13
Making ANTLR filter/replace like UNIX sed tool.

Parsing Simple Data
Terence Parr Thu Jun 12, 2003 18:29
This leads you through the development of a simple parser for reading in name/age pairs.

Quick Start Guide
Terence Parr Thu Jun 12, 2003 18:25
Thisleads you through the development and execution of your first ANTLR parser and lexer.

1.33-to-2.20 Conversion Tips
Tom Nurkkala Thu Jun 12, 2003 18:05
I've been converting 1.33 grammars to 2.0 and thought I'd pass along the following tips that may help folks avoid some of the problems I've had doing it. I hope these tips help -- happy parsing!

Conversion of a C++ Parser from PCCTS to ANTLR
Jianguo Zuo, David Wigg, S. E. Black Thu Jun 12, 2003 17:59
These notes were produced by Jianguo Zuo who converted an original version (1995 1.2) of a C++ parser, cplusplus.g, file which ran under PCCTS 1.33 to run under ANTLR 2.7.1. This conversion was done as part of a project to produce output for another project. As all our embedded code was written in C++ the output from ANTLR was required in C++ so that our embedded code could remain in C++.

LL and LR Translator Need k>1 Lookahead
Terence Parr Thu Jun 12, 2003 11:05
Language translation is a harder and more important problem than language recognition. In particular, programmers implement translators not recognizers. Yet too often, translation is equated with the simpler task of syntactic parsing. This misconception coupled with computing limitations of past computers has led to the almost exclusive use of LR(1) and LL(1) in parser generators. We claim that use of k>1 lookahead can and should be available in practice, as it simplifies the translator development. We give several examples justifying our arguments.

Exactly 1800 Words on Languages and Parsing
Terence Parr Thu Jun 12, 2003 11:01
Excerpt from Language Translation Using PCCTS & C++ that provides parsing theory term definitions and illustrates the various parsing strategies.

Building Development Tools
Terence Parr with Greg Voss Tue Feb 11, 1997 12:00
A conversation with Greg Voss on building development tools.

ANTLR Workshop 97
Terence Parr Wed Jan 1, 1997 00:00
The 1997 ANTLR workshop Dr. T's Traveling Parsing Revival and Beer Tasting Festival held at Sun Microsystems.

Language Translation Using PCCTS and C++
Terence Parr Thu Aug 1, 1996 00:00
The book I did on PCCTS. More of a manual for older version of ANTLR (PCCTS), but has some useful sections. This book is out of print.

PCCTS Workshop 95
Terence Parr Sun Jan 1, 1995 00:00
The 1995 PCCTS workshop Dr. T's Traveling Parsing Revival and Beer Tasting Festival held at SGI I think.

An Overview of SORCERER: A Simple Tree-Parser Generator
Terence Parr Fri Apr 1, 1994 00:00
Describes SORCERER, the source to source translator generator I built to help solve my Fortran translation issues as a postdoctoral fellow. It evolved into ANTLR's tree parsers. :)

Adding Semantic and Syntactic Predicates to LL(k): pred-LL(k)
Terence Parr and Russell Quong Fri Apr 1, 1994 00:00
Discusses the definition of semantic and syntactic predicates for LL(k).

PCCTS Workshop 94
Terence Parr Sat Jan 1, 1994 00:00
The 1994 PCCTS workshop Dr. T's Traveling Parsing Revival and Beer Tasting Festival held at NeXT Computer.

Obtaining Practical Variants of LL(k) and LR(k) for k>1 by splitting the atomic k-Tuple
Terence Parr Thu Jul 1, 1993 10:00
Terence Parr's PhD Dissertation on Practical LL(k) and LR(k) for k>1 parsing that describes the theoretical principles behind the construction of ANTLR's parsers. Something dark and scary to read. According to Quinn Jackson, "This is probably one of the more readable theses I've come across, except maybe that of Dr. Francoise Balmas at University Paris-8."




Preserving Whitespace During Translation
Terence Parr
Whitespace is ignored and discarded for most parsing and translation operations, however, what about translations that are only slight perturbations of the input? This field guide entry demonstrates how you can preserve whitespace during a nontrivial (i.e., cannot easily be done with awk/sed) translation using ANTLR's token streams.