ANTLR
Original author(s) | Terence Parr and others |
---|---|
Initial release | February 1992 |
Stable release | 3.3
/ November 29, 2010 |
Repository | |
Written in | Java |
Platform | Cross-platform |
License | BSD License |
Website | www |
In computer-based language recognition, ANother Tool for Language Recognition (ANTLR, pronounced Antler) is a parser generator that uses LL(*) parsing. ANTLR is the successor to the Purdue Compiler Construction Tool Set (PCCTS), first developed in 1989, and is under active development. Its maintainer is professor Terence Parr of the University of San Francisco.
ANTLR takes as input a grammar that specifies a language and generates as output source code for a recognizer for that language. At the moment, ANTLR supports generating code in the programming languages Ada95, ActionScript, C, C#, Java, JavaScript, Objective-C, Perl, Python, and Ruby. A language is specified using a context-free grammar which is expressed using Extended Backus Naur Form EBNF.
ANTLR allows generating parsers, lexers, tree parsers and combined lexer-parsers. Parsers can automatically generate abstract syntax trees which can be further processed with tree parsers. ANTLR provides a single consistent notation for specifying lexers, parsers and tree parsers. This is in contrast with other parser/lexer generators and adds greatly to the tool's ease of use.
By default ANTLR reads a grammar and generates a recognizer for the language defined by the grammar (i.e. a program that reads an input stream and generates an error if the input stream does not conform to the syntax specified by the grammar). If there are no syntax errors then the default action is to simply exit without printing any message. In order to do something useful with the language, actions can be attached to grammar elements in the grammar. These actions are written in the programming language in which the recognizer is being generated. When the recognizer is being generated, the actions are embedded in the source code of the recognizer at the appropriate points. Actions can be used to build and check symbol tables and to emit instructions in a target language, in the case of a compiler.
As well as lexers and parsers, ANTLR can be used to generate tree parsers. These are recognizers that process abstract syntax trees which can be automatically generated by parsers. These tree parsers are unique to ANTLR and greatly simplify the processing of abstract syntax trees.
ANTLR 3 is free software, published under a three-clause BSD License. Prior versions were released as public domain software.[1]
While ANTLR itself is free, however, the documentation necessary to use it is not. The ANTLR manual is a commercial book, The Definitive ANTLR Reference. Free documentation is limited to a handful of tutorials, code examples, and very basic API listings.
Several plugins have been developed for the Eclipse development environment to support the ANTLR grammar. There is ANTLR Studio, a proprietary product, as well as the ANTLR 2 and 3 plugins for Eclipse hosted on SourceForge.
See also
References
Bibliography
- Parr, Terence (May 17, 2007), The Definitive Antlr Reference: Building Domain-Specific Languages (1st ed.), Pragmatic Bookshelf, p. 376, ISBN 0978739256
- Parr, Terence (December, 2009), Language Implementation Patterns: Create Your Own Domain-Specific and General Programming Languages (1st ed.), Pragmatic Bookshelf, p. 374, ISBN 978-1-934356-45-6
{{citation}}
: Check date values in:|date=
(help)
External links
- Official website
- ANTLRWorks
- ANTLR Studio
- ANTLR For Delphi Target
- ANTLR tutorial at the University of Birmingham
- For background on the theory, see articles from the ANTLR pages, e.g. T. J. Parr, R. W. Quong, ANTLR: A Predicated-LL(k) Parser Generator, Software—Practice and Experience, Vol. 25(7), 789–810 (July 1995)