Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
ANTLR
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Usage== ANTLR takes as input a [[formal grammar|grammar]] that specifies a language and generates as output [[source code]] for a [[recognizer]] of that language. While Version 3 supported generating code in the [[programming language]]s [[Ada95]], [[ActionScript]], [[C (programming language)|C]], [[C Sharp (programming language)|C#]], [[Java (programming language)|Java]], [[JavaScript]], [[Objective-C]], [[Perl]], [[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]], and [[Standard ML]],<ref>[http://www.classes.cs.uchicago.edu/archive/2007/winter/22610-1/docs/lpt-manual.pdf SML/NJ Language Processing Tools: User Guide]</ref> Version 4 at present targets C#, C++, [[Dart (programming language)|Dart]],<ref name="github">{{cite web |title=Runtime Libraries and Code Generation Targets |url=https://github.com/antlr/antlr4/blob/master/doc/targets.md |website=github|date=6 January 2022 }}</ref><ref>{{Cite web | url=https://soft-gems.net/the-antlr4-c-runtime-reached-home | title=The ANTLR4 C++ runtime reached home – Soft Gems | date=16 November 2016 }}</ref> Java, JavaScript, [[Go (programming language)|Go]], [[PHP]], Python (2 and 3), and [[Swift (programming language)|Swift]]. A language is specified using a [[context-free grammar]] expressed using [[Extended Backus–Naur Form]] (EBNF).{{citation needed|date=March 2016}}<ref name=":0">{{Cite book|last=Parr|first=Terence|url=https://books.google.com/books?id=gA9QDwAAQBAJ|title=The Definitive ANTLR 4 Reference|date=2013-01-15|publisher=Pragmatic Bookshelf|isbn=978-1-68050-500-9|language=en}}</ref> ANTLR can generate [[lexical analysis|lexer]]s, [[parser]]s, [[Parse tree|tree parsers]], and combined [[Lexical analysis|lexer-parsers]]. Parsers can automatically generate [[parse tree]]s or [[abstract syntax tree]]s, which can be further processed with tree parsers. ANTLR provides a single consistent notation for specifying lexers, parsers, and tree parsers. 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, 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.{{citation needed|date=March 2016}}<ref name=":0" /> Other than 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 help processing abstract syntax trees.{{citation needed|date=March 2016}}<ref name=":0" />
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)