Upgrade ANTLR to version 4.13.2
- Ivaylo Fiziev
- Jun 3
- 2 min read

The latest and greatest ANTLR (https://www.antlr.org/download.html) version is here. Hurray! As you probably already know this is the core of the SCL implementation in Process Simulate. For those that are not aware ANTLR (ANother Tool for Language Recognition) is a powerful parser generator that can build parsers that produce and walk parse trees.
Until now we were using ANTLR 4.7.1. Version 4.13.2 and all the versions in between bring a lot of improvements and bug fixes for the Cpp target. Here are some of the most important ones:
1. Optimize the concurrent performance of Cpp target by more than 10 times ( https://github.com/antlr/antlr4/pull/4237)
2. Avoid using dynamic_cast where possible by using hand rolled RTTI (https://github.com/antlr/antlr4/pull/3584 )
3. Update C++ documentation to state that C++17 is required (https://github.com/antlr/antlr4/pull/4588)
For us all this means only one thing: better performance.
But is it really so?
Let's first discuss the performance problems that we have with version 4.7.1
1. When dealing with big scripts (>2000 lines of code) the parse three traversal appeared to be a bottleneck. Why? Mainly because of the dynamic_cast operator in C++.
ANTLR used to rely heavily on it when visiting child nodes of the program tree. The second fix addresses this issue. With the new version you can expect up to 14% better performance in such cases. Smaller scripts will also benefit from this change since parse tree traversal is faster in general.
2. When dealing with concurrent (time critical) scripts parsing was slow due to a shared state in ANTLR. Now with the ANTLR4_USE_THREAD_LOCAL_CACHE compile option parsing is up to 10x faster. The first fix applies here making the concurrent parsing a marvel.
Time critical scripts are still not released officially but you can already benefit from them by enabling the TIME_CRITICAL_SCL_SCRIPTS feature toggle. If your logic is heavy then it makes sense to execute it in a time critical script. Process Simulate specific SCL functions however cannot be used. This makes them difficult to use.
3. New C++ standards are always welcome since they bring new features to the language and improve performance.
Overall, after the upgrade, you can expect SCL to be much more responsive to your actions. Auto completion, code introspection, validation, interpretation etc. will be faster. Try it yourself in the official 2509 release.
Enjoy!
Hi Ivo,
in which build is this available?