ANTLR plugin for Eclipse
This project leverages the
Eclipse platform
(v3.02 and v3.1) by adding support for the parser generator
ANTLR.
It provides the following plugins:
- org.antlr
- ANTLR 2.7.6 (official) library
- org.antlr.doc
- ANTLR 2.7.6 (official) documentation
- org.antlr.eclipse.core
- ANTLR project nature with builder
- org.antlr.eclipse.ui
- ANTLR-aware text editor (associated to files with extension '*.g')
Features
- Project nature:
- ANTLR grammar builder translates files into Java source and JSR-45 SMAPs
- Installs SMAPs into compiled generated classes
- Optionallly cleans compiler warnings from generated code
- "Antlers" icon represents ANTLR projects
- Problem markers for errors and warnings in grammar files
- ANTLR-aware multi-page text editor with syntax highlighting
- Editor overview page, showing ANTLR grammar (only terminals and
non-terminals are displayed) without actions and comments
- Outline view which shows sections of ANTLR grammar files
- Action in navigator context menu to compile ANTLR grammar files manually
- Action in navigator context menu to add/remove ANTLR project nature
to/from the currently selected project
- Editor context menu 'Goto Rule' to navigate to rule under cursor
(keyboard shortcut 'F3' or context menu)
- Annotation hover for errors (Screenshot)
- Text annotations for rules (first 10 lines of the rule's source code)
-> Screenshot
- Commenting and uncommenting text (Ctrl+/ and Ctrl+\)
- Content assist for rules (Ctrl+Space)
-> Screenshot
- Leverage customizable keybinding facility of Eclipse
- Preferences page for editor's syntax highlight
(Screenshot)
- Resource label decoration of ANTLR generated files with name of according
grammar file (Screenshot)
- Property page for grammar files which allows specification of ANTLR
command-line options Screenshot
- Property page for generated files which displays the related grammar file
(Screenshot)
- Breakpoints can be set in grammar files for debugging. (Note: A late change in Eclipse
3.1 broke support for adding breakpoints via the editor ruler. You can still add
breakpoints by choosing "Toggle Line Breakpoint" from the Run menu. In Eclipse
3.02, breakpoint setting works properly. We'll be fixing this as soon.)
- Automatically adds antlr.jar to your classpath when you toggle on the ANTLR nature.
Note that you may want to copy the antlr.jar to your project if you want to build
without eclipse.
Installation
Via Eclipse Update Manager
Online updates are available on
http://antlreclipse.sourceforge.net/updates/.
Define a site bookmark in Eclipse's Update Manager view as follows. (This description is for Eclipse 3.1; Eclipse 3.02 installation is similar, but the dialogs are slightly different)
- Choose Software Updates->Find and Install from the Help menu.
- Select Search for new features to install and press Next.
- Press New Remote Site...
- Enter "ANTLR Eclipse" (or whatever you would like) as the name, and "http://antlreclipse.sourceforge.net/updates/" for the URL.
- Press Finish
- Check the boxes next to the version you would like to install and press Next.
- Accept the license agreement and press Next.
- Press Finish.
Eclipse may ask if you want to restart. We recommend that you do.
The update site can also be downloaded from
SourceForge
and used locally. This is a good option for company-wide use.
Usage
To add/remove the ANTLR project nature to/from a project select a project in Eclipse's
navigator view and select from the context menu Toggle ANTLR project nature.
When you build your project, the ANTLR builder will be executed. If you have automatic build turned on,
ANTLR will be run against your grammar file whenever it has been modified.
You can set breakpoints in your grammar file by double-clicking in the ruler area (the same way you
set breakpoints for java debugging.) A few notes on debugging:
- Ruler breakpoint management doesn't work in Eclipse 3.1.0. You need to use the Run->Toggle Line Breakpoints option or upgrade to Eclipse 3.1.1.
- Sometimes you may want to debug the generated java source instead of the grammar. To do this, right-click the grammar file and uncheck the "Install JSR-45 SMAP" option.
- The editor will currently allow you to set breakpoings anywhere in your grammar. However, breakpoints will only be respected inside rules and action code.
Please use the sourceforge forums for antlreclipse comments, suggestions and bug reports.