Core Java

The important changes in the new ANTLR 4.6

After almost a year since the last major release, there is a new ANTLR version: 4.6. There are many news: new targets, better perfomance, better error handling and several improvements in the development of ANTLR itself.

New targets

The most impactful news is probably the new targets: C++, Go and Swift. Of course getting C++ support is a big deal. Hate it or love it, this is still one of the big languages out there. Go has gained traction in network applications, such as webservers and API, thanks to its great support for concurrency. This almost double the available targets and join the already included Java, C#, Python and Javascript.

Major performance improvement

One of the greatest addition in ANTLR 4 was the support for left-recursive expression, that is to say expressions that have one or more alternatives that referenced themselves. This greatly simplified grammar rules needed to support expressions, but there were were cases of nonterminating parses for very large expressions. This happened because of a problem with the parsing engine, due to an ambiguity between two choices. Both lead to a valid parse, but one was much slower than the other. The problem was discovered by Sam Harwell, one of the key contributors to ANTLR.

Error handling and messages

There have been improvements in error handling of some cases: related to LL(1) decisions, matching set of tokens mistakenly considered resynchronization tokens and the occasional non inclusion of error nodes for single token. Furthermore there are better error messages, for instance in the case of rules conflicting with symbols in the generated code in the specified target language.

Improvement in the development of ANTLR

Other important news are several improvements related to the development of ANTLR itself. While this don’t directly affect you, as a user, they may make easier for you to contribute to the project, to study how a big Java project works or even inspire you to improve your own opensource project. These range from betterment to the build system and the maven plug-in to a completely rewritten unit test mechanism. Also it’s useful to be aware that now the build environment requires ANTLR Java 7/JDK 1.7, a change spurred by the Swift target.

Conclusions

ANTLR is a precious tool for many people interested in languages. This release proves once again that ANTLR is here to stay and it keeps evolving. This release is a bit special because of the significant number of meaningful changes. I can see this projecting more enthusiasm in the ANTLR community and I am looking forward to see more great things happening in this area.

Reference: The important changes in the new ANTLR 4.6 from our JCG partner Federico Tomassetti at the Federico Tomassetti blog.

Federico Tomassetti

Federico has a PhD in Polyglot Software Development. He is fascinated by all forms of software development with a focus on Model-Driven Development and Domain Specific Languages.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Back to top button