Co-founder of Strumenta. Essays on software languages, legacy systems and the craft of building tools.

274 articles · since 2009

A lived-in Torino street with the Mole Antonelliana beyond it
Parsing & compilers · 3 min · 558 words · 37 of 72 in this topic

The only good thing of 2020: ANTLR 4.9

The last major update of ANTLR was in January 2019, now after almost two years we have a new update of ANTLR: 4.9, released on November 24. Finally this year has given us something good. The highlight of this release is a new target language: Dart.

New target: Dart

The big news of this release is the new target for ANTLR: Dart, thanks to the work of Larry Li.

Dart is a programming language designed by Google that can be compiled into native code or in JavaScript. Dart is optimized for client applications and building user interfaces. From the official website:

Now with one ANTLR grammar you can build parsers in:

  • Java
  • C#
  • C++
  • JavaScript
  • Python 2 and 3
  • Go
  • Swift
  • PHP
  • Dart
  • Kotlin (with our experimental target)
  • TypeScript (with the experimental target by Tunnel Vision Laboratories)

That is a lot of languages, which means that you can learn the technology once and use it for all your parser needs. Now let’s see some other hightlights,

Improving Python import time

Rob McGregor has fixed a configuration bug affecting the Python runtime. Most of the loading time was spent importing the unittest module, that was not even used for the runtime. In his testing this fix has reduced the importing time from around 150ms to around 50ms. That is a big improvement if you need to build a Python application that loads quickly.

Improved debugging behavior in C#

A small but useful change is the improvement in behavior when debugging C# code. Before this change you would step into the generated ANTLR code when debugging your C# project. Now, the code is ignored unless you set the option to debug non-user code. This is a small change, but simplify your life a bit if you need to debug C# code.

Improvements to C++ and JavaScript targets

In this release there are also quite a few small improvements to the C++ and JavaScript targets. They are mostly quality fixes: changes that slightly improve memory or performance of small parts of the code. There are also updates to support newer versions of the respective languages, like C++20 or ES6.

Summary

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 fixes and maintenance changes. Setting aside particular use cases, you will not see any significant change. That is because it already had all that you need for parsing. The only big news it is the support for a new target language: Dart.

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.

Read more:

If you want to understand how to use ANTLR you can read our article The ANTLR MEga Tutorial.

A programming language optimized for building user interfaces with features such as the spread operator for expanding collections, and collection if for customizing UI for each platform
Federico Tomassetti

I build parsers, transpilers and languages for people whose work is too specific for off-the-shelf software. I co-founded Strumenta, in Torino.

Reply by email · I read everything.

If this was useful, there are more on the same problem.

More in Parsing & compilers

Joining forces to modernize legacy software 2 min read Case Study | Vertec | IT Industry | SQL Parser to translate code to English 1 min read How to use the Visual Basic 6 and VBA Parser 10 min read · code inside

A legacy estate you need to understand before you commit.

See how Strumenta works

Disclosure — Strumenta is a company I co-founded.

One letter when there is something worth sending.

Written by Federico · Torino

Scroll to Top