Skip to end of metadata
Go to start of metadata

Development environments


There is a very complete and useful plug-in for intellij 12-14, you can grab at the download page. Check the plugin readme for feature set. Just go to the preferences and click on the "Install plug-in from disk..." button from this dialog box:

Select the (or whatever version) file and hit okay or apply. It will ask you to restart the IDE. If you look at the plug-ins again, you will see:

Also, I have prepared a video that will help you generate grammars and so on using ANTLR v4 in Intellij (w/o the plugin).


Edgar Espina has created an eclipse plugin for ANTLR v4. Features: Advanced Syntax Highlighting, Automatic Code Generation (on save), Manual Code Generation (through External Tools menu), Code Formatter (Ctrl+Shift+F), Syntax Diagrams, Advanced Rule Navigation between files (F3), Quick fixes.


Sam Harwell's ANTLRWorks2 works also as a plug-in, not just a stand-alone tool built on top of NetBeans.

Build systems



Maven Plugin Reference

The reference pages for the latest version of the Maven plugin for ANTLR 4 can be found here:


This section describes how to create a simple Antlr 4 project and build it using maven. We are going to use the ArrayInit.g4 example from chapter 3 of the book, and bring it under maven. We will need to rename files and modify them. We will conclude by building a portable stand alone application.

Generate the skeleton

To generate the maven skeleton, type these commands:

Maven will ask a series of questions, simply accept the default answers by hitting enter.

Move into the directory created by maven:

We can use the find command to see the files created by maven:

We need to edit the pom.xml file extensively. The will be renamed to and will contain the main ANTLR java program which we will download from the book examples. The file will be renamed but will remain the empty test as created by maven. We will also be adding the grammar file ArrayInit.g4 from the book examples in there.

Get the examples for the book and put them in the Downloads folder

To obtain the ArrayInit.g4 grammar from the book, simply download it:

Copy the grammar to the maven project

The grammar file goes into a special folder under the src/ directory. The folder name must match the maven package name org.abcd.examples.ArrayInit.

Copy the main program to the maven project

We replace the maven file with the main java program from the book. In the book, that main program is called, we rename it to

Spend a few minutes to read the main program. Notice that it reads the standard input stream. We need to remember this when we run the application.

Edit the file

We need to add a package declaration and to rename the class. Edit the file ./src/main/java/org/abcd/examples/ArrayInit/ in your favorite editor. The head of the file should look like this when you are done:

Edit the file

Maven creates a test file called, we need to rename it to match the name of our application:

Edit the pom.xml file

Now we need to extensively modify the pom.xml file. The final product looks like this:


This concludes the changes we had to make. We can look at the list of files we have with the find command:

Building a stand alone application

With all the files now in place, we can ask maven to create a standalone application. The following command does this:

Maven creates a self-contained jar file called target/array-init-1.0-jar-with-dependencies.jar. We can execute the jar file, but remember that it expects some input on the command line, which means the command will hang on the command line until we feed it some input:

And let's feed it the following input:

The ^D signals the end of the input to the standard input stream and gets the rest of the application going. You should see the following output:

You can also build a jar file without the dependencies, and execute it with a maven command instead:

  • No labels