An Eclipse plugin that contributes ANTLR ™ V3.2+ grammar and StringTemplate editors to the Eclipse platform.
Incremental ANTLR grammar builder using ANTLR 3.2
- Antlr Editor and Outline View -- syntax-assisted editor
- Antlr Grammar Formatter (Version 1.2+)
- Hybrid formatter - capable of formatting of all Antlr grammar and Java elements
- Antlr elements handled using custom formatter
- Java elements are handled using the JDT platform formatter
- Formatting of native code blocks can be disabled to allow formatting of just Antlr elements
- StringTemplate Editor -- syntax-assisted editor
- Grammar Builder -- incremental Lexer/Parser generator
- Grammar Launcher -- launch and run generated Lexer/Parser
- LauncherView -- view-based suite of launch configurations
- Visualization -- detailed visualization of actual execution paths
- AST View -- views of actual parser built AST, token stream and parse errors
AntlrDT and StringTemplate editors
Visualization View
Grammar AST View
- The syntax-directed editors are specific to ANTLR 3.2 and StringTemplate 3.2
- Static syntax analysis is performed using the reference ANTLRv3.g grammar with validation errors being reported by editor problem markers
- marker hovering is supported
- the Outline View depends on the grammar being parseable -- the tree will not be displayed or, rarely, be shown out-of-sync if the grammar is not reasonably valid
- The incremental Builder performs code gen on grammar save actions. Preference support is provided for disabling the builder and defining the grammar build path.
- Preference options are provided for
- auto-formatting of the generated code
- auto-import resolution
- auto-detection of the generation directory from grammar embedded package statements
- choice of output directory selection method on per-project basis
General Use
- The Grammar Editor is automatically associated with ANTLR 3.2 grammar files (".g" extension)
- The StringTemplate Editor is automatically associated with ANTLR 3.2 group files (".stg" extension preferred)
- The editors are available in any project - grammar files need not be on the project's build path.
- The Grammar Builder is enabled from the AntlrDT preference page
- The grammar build path can be modified from the project's AntlrDT property page
Formatter Use (for Version 1.2+)
Caution: while the formatter should not modify anything other than whitespace, be careful - ctrl-z will undo changes
- Invoke using standard platform format command (ctrl-shift-f)
- Formatting of selected blocks is not supported/untested
- Generally, all formatting is performed in one pass (one press of ctrl-shift-f); may require multiple presses to fully adjust indenting of native code
Visualization View Use
- Visualization is enabled from the Launch configuration main tab. The visualization view will open automatically, as needed.
- Hover over a node: shows node type dependent details
- Double-click on token related nodes: opens the input text file and highlights the actual content of the token
- Double-click on (most) rule related nodes: opens the grammar and highlights the corresponding rule element
- Configuration options:
Antlr ASTView Use
- Preliminaries:
- The grammar must be set with options { output=AST; }
- Likely to only work for Java code gen
- The grammar and code gen output directory, must be on the project build path and under the workspace root
- Superclass and any helper classes referenced from the generated code must be in the code gen output directory or otherwise on the project build path - the AST is build using a full live execution of the parser
- Operation:
- To build an AST, the corresponding grammar must be in the active editor
- If the AST View is not linked to the active editor, press the Load button to force focus
- Choose a start rule for parsing; defaults to the first listed rule
- Choose a source file to be parsed, and press the Build button
- In the Token Stream and Errors lists, a double-click will open, select and reveal the corresponding portion of the source file.
Please report any problems getting Eclipse to recognize and run the AntlrDT plugins to .
To install, just download and unzip the plugin jars to the "<eclipse_home>/dropins" directory. See, Supported dropins formats
- Version 1.2.0
- Eclipse 3.5.1 on Java 6+ VM
- Eclipse DLTK 1.0.1 Core Framework (current Galileo release)
- Eclipse Zest Visualization Toolkit 1.1.1 (current Galileo release)
- Version 0.9.2
- Eclipse 3.4 on Java 5+ VM
- Eclipse DLTK 0.95.2 (standard Ganymede release)
- Eclipse GEF/Zest Visualization Toolkit 1.0 (standard Ganymede release)