This project has not seen commits/updates for several years now. It is no longer maintained.
- ANTLR 4.x (see also official ANTLR website or ANTLR source code)
- Advanced Syntax Highlighting (even for target language)
- Automatic Code Generation (on save)
- Manual Code Generation (through External Tools menu)
- Code Formatter (Ctrl+Shift+F)
- Syntax Diagrams as HTML
- Live Parse Tree evaluation
- Advanced Rule Navigation between files (F3 or Ctrl+Click over a rule)
- Quick fixes
This is brand new version of the old ANTLR IDE. The new IDE supports ANTLR 4.x and it was created to run on Eclipse 4.x
The old ANTLR IDE isn't supported anymore. When I wrote it, I was young and didn't know what was doing ;)
Don't get me wrong, the old version did a very good work from user point of view, it just I'm not proud of the code base because is kind of complex and had a poor quality.
The main reason of complexity of the old IDE was in Dynamic Language ToolKit (DLTK) dependency. The DLTK project didn't evolve so much over the last few years and doing something in DLTK is very very complex and require a lot of work.
Now, the new IDE was built on XText. XText is great for building DSL with Eclipse IDE support, so if you are not familiar with XText go and see it.
See link to ANTLR tools for a comparison of ANTLR4IDE with other development tools for ANTLR.
- Eclipse 4.4 Luna Xtext Complete SDK(Needs to be version 2.7.3)
- Eclipse Faceted Project Framework (Tested with 3.4.0) Eclipse Faceted
- Project Framework JDT Enablement(Tested with 3.4.0) ANTLR 4 SDK A
- A copy of the antlr-4.x-complete.jar (4.5 at the time of writing)
- Install Eclipse (4.4 Luna)
- Download it from https://www.eclipse.org/downloads/
- Install XText 2.7.3
- Go to
Help > Install New Software...
- Enter
http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/
in theWork With
textbox - Hit Enter and wait for the list to load (this will take a few moments)
- Expand the
Xtext
node and checkXtext Complete SDK
(ensure the version is 2.7.3x) - Click
Next
, agree to the EULA, and click finish - Let the installer finish and restart Eclipse
- Go to
- Install Faceted Project Framework
- Go to
Help > Install New Software...
- Enter
http://download.eclipse.org/releases/luna
in theWork With
textbox - Hit Enter and wait for the list to load (this will take a few moments)
- In the filter text box enter
Facet
- Select
Eclipse Faceted Project Framework
andEclipse Faceted Project Framework JDT Enablement
- Click
Next
, agree to the EULA, and click finish - Let the installer finish and restart Eclipse
- Go to
- Install ANTLR 4 IDE
- Go to
Help > Eclipse Marketplace...
- Search for
antlr
- Choose
ANTLR 4 IDE
(make sure it's ANTLR 4 IDE not ANTLR IDE) - Click Install
- Let the installer finish clicking ok if it prompts and restart Eclipse
- Go to
- Obtain a copy of antlr-4.x-complete.jar
- Download the file from here
- Save it somewhere you'll remember
- Go to
File > New Project > Project
- Expand the
General Tab
and selectANTLR 4 Project
(if you don't see this see step 4 of setup) - Click
Next
, give the project a name and clickFinish
- Once the project is complete right click the project and click
Properties
- Go to
Project Facets
and clickConvert to faceted form...
(if you don't see this see step 3 of setup) - Check the
Java
project facet and clickApply
(if you don't see this see step 3 of setup) - Click
OK
, let the solution rebuild, open the properties again - Go to
Java Build Path
, click theSource
tab - Click
Add Folder...
and checkProject > target > generated-sources > antlr4
, clickOK
- Click the
Libraries
tab Add External JARs...
, find your copy ofantlr-4.x-complete.jar
, clickOpen
- Go to
ANTLR 4 > Tool
, clickApply
if a pop-up appears - Check
Enable project specific settings
- Click
Add
, find your copy ofantlr-4.x-complete.jar
, clickOpen
- Check
4.x
- Click
Apply
, clickYes
to rebuild, clickOK
to exit the properties
The new IDE is very simple to use all the files with a *.g4
extension will be opened by the ANTLR 4 Editor. So, just open a *.g4
file and play with it.
See grammars examples at https://github.com/antlr/grammars-v4
Code is automatically generated on save if the grammar is valid. You can turn off this feature by going to: Window > Preferences > ANTLR 4 > Tool
and uncheck the "Tool is activated" option. From there you can configure a couple more of options.
You can find the generated code in the target/generated-sources/antlr4
(same directory as antlr4-maven-plugin)
You can fire a code generation action by selecting a *.g4
file from the Package Explorer, right click: Run As > ANTLR 4
.
A default ANTLR 4 launch configuration will be created. You can modify the generated launch configuration by going to: Run > External Tools > External Tools Configurations...
from there you will see the launch configuration and how to set or override code generation options
To open the Syntax Diagram view go to: Window > Show View > Other
search and select: Syntax Diagram
- Create a new ANTLR Project following the steps above
- Create a new class with the code below
- Run
- In the console write
Hello there
and Ctrl + z to send EOF to the input stream
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.tree.*;
public class HelloRunner
{
public static void main( String[] args) throws Exception
{
ANTLRInputStream input = new ANTLRInputStream( System.in);
HelloLexer lexer = new HelloLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
HelloParser parser = new HelloParser(tokens);
ParseTree tree = parser.r(); // begin parsing at rule 'r'
System.out.println(tree.toStringTree(parser)); // print LISP-style tree
}
-
Build with Maven 3.x
-
Fork and clone the repository from github
-
Download and install Maven 3.x
-
Open a shell console and type:
cd antlr4ide
-
Build the project with:
mvn clean package
-
It takes a while to download and configure Eclipse dependencies, so be patient
-
Wait for a:
BUILD SUCCESS
message -
When building for the very first time there might be some missing dependencies, so please retry
mvn clean package
-
Setup Eclipse
-
Open Eclipse Luna (4.4)
-
Install Xtext 2.7.3
-
Copy and paste this url: http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/ in the Work with text field
-
Hit Enter
-
Choose XText 2.7.3. NOTE: DON'T confuse with Xtend, you must choose Xtext
-
Restart Eclipse after installing Xtext
-
Import the project into Eclipse
-
Go to:
File > Import...
thenGeneral > Existing Projects into Workspace
-
Choose project root
antlr4ide
-
Enabled:
Search for nested projects
-
Finish
You don't need any extra Eclipse plugin (like m2e or similar). Project metadata is on git so all you need to do is: mvn clean package
and then import the projects into Eclipse.
- Fork the project on Github.
- Wondering what to work on? See task/bug list and pick up something you would like to work on.
- Create an issue or fix one from issues list.
- If you know the answer to a question posted to our mailing list - don't hesitate to write a reply.
- Share your ideas or ask questions on mailing list - don't hesitate to write a reply - that helps us improve javadocs/FAQ.
- If you miss a particular feature - browse or ask on the mailing list - don't hesitate to write a reply, show us a sample code and describe the problem.
- Write a blog post about how you use or extend ANTLR 4 IDE.
- Please suggest changes to javadoc/exception messages when you find something unclear.
- If you have problems with documentation, find it non intuitive or hard to follow - let us know about it, we'll try to make it better according to your suggestions. Any constructive critique is greatly appreciated. Don't forget that this is an open source project developed and documented in spare time.
[Edgar Espina] (https://twitter.com/edgarespina)