A new major release for ANTLR with version 4.11.1. Technically we are at release 4.11.1, but this is the same as 4.11 apart from correcting the internal version name. Excluding the Go target, this is not a major release in terms of features, but there are significant improvements for the ANTLR project itself. As a side note, if you ever need to create a custom parser, following the development project could be a good way to learn how to create them. Since it is a successful and well supported opensource project, people will discuss the pro and cons of major development and contributions.

Project Improvements

This is another release with improvements to the project itself. There have been improvements in the speed of ANTLR generation and also massive improvements in speed of tests, which can now run in parallel. Also, now there are CI that build all targets on all supported platforms. ANTLR developers are going to have a better experience and this should lead to less bugs and better support for all platforms.

A Better Go

The Go target has been reworked, with the major addition of better support for go modules for the ANTLR project. The gist of it is that now the Go target more properly follows Go conventions regarding the path of imported code, so it is easier to keep track of new ANTLR releases. You should read the updated Go Target README for more details and how to update your project to work with this change.

An Interpreted TestRig

This release also brings an interpreted TestRig, better known as Grun, the utility tool for manually testing and aiding the developing of grammars.

A simple example coming directly from the commit:

java org.antlr.v4.gui.Interpreter /Users/parrt/sample/JavaParser.g4 /Users/parrt/sample/JavaLexer.g4 compilationUnit -profile /tmp/a.csv -trace
class T { int i; }
enter   compilationUnit, LT(1)=class
enter   typeDeclaration, LT(1)=class
enter   classDeclaration, LT(1)=class
consume [@0,0:4='class',<9>,1:0] rule classDeclaration
enter   identifier, LT(1)=T
consume [@2,6:6='T',<128>,1:6] rule identifier
exit    identifier, LT(1)={
enter   classBody, LT(1)={
consume [@4,8:8='{',<80>,1:8] rule classBody
enter   classBodyDeclaration, LT(1)=int
...
exit    compilationUnit, LT(1)=<EOF>
$ head /tmp/a.csv
Rule,Invocations,Time (ms),Total k,Max k,Ambiguities,DFA cache miss
compilationUnit:0,1,0.30525,1,1,0,1
compilationUnit:1,1,0.578416,1,1,0,1
compilationUnit:2,2,0.634208,2,1,0,2
compilationUnit:3,1,1.662042,1,1,0,1
packageDeclaration:4,0,0.0,0,0,0,0
importDeclaration:5,0,0.0,0,0,0,0
importDeclaration:6,0,0.0,0,0,0,0
typeDeclaration:7,1,0.0925,1,1,0,1
typeDeclaration:8,1,0.086917,1,1,0,1

This is an useful addition in itself, if you need to integrate ANTLR in some other Java software. However, it has been developed because this is going to be used in antlr4-tools, which is an interesting project to run ANTLR without Java, but with Python:

Tools to run antlr4 w/o needing to install java or antlr4! The only requirement is Python3, which is typically installed on all developer machines on all operating systems.

Notice that at the moment the python package will actually download and use the antlr4 java command line tool automatically. It also do not work on Windows. The tool now contains this interpreted class. The interpreted TestRig ran Java-based (and compiled) parser/lexers that can be used by the python package to debug and profile pure grammars (without actions or semantic predicates).

Summary

In addition to the mentioned changes, there are a number of bugfixes and small things that you can read in the release notes, including interesting technical details such as the use of constant folding for many runtimes (which improves speed).

ANTLR is the best tool to build parsers out there: it is well-tested, reliable enough to be used in an enterprise setting and usable enough so that you actually want to work with it. This release confirms this, by offering a few quality-of-live improvements, fixes and maintenance changes. 

To support you in polishing your parser you can use libraries like Kolasu:

Kolasu supplies the infrastructure to build a custom, possibly mutable, Abstract Syntax Tree (AST) using Kotlin. In particular it can be integrated easily with ANTLR, but it can also be used without.

You know it is good, because we made it.

If you still do not know how to use this wonderful tool, you can read our complete mega tutorial on ANTLR.