I was surprised to learn that Bram Pellens, from the Spikes research team had developed an ATL parser in C#. So I asked him if he could share more about this original tool with us. Enter Bram.

ATL#, pronounced as “ATL Sharp”, is an ATL (ATL Transformation Language) parser written in C# for the .NET platform. It is implemented as an assembly and thus can easily be incorporated into other projects (in any .NET language).

The base parser was generated using the Antlr parser generator. Antlr translates a so-called grammar into a parser/lexer. The grammar for the ATL language was created from its BNF grammar. However, some changes were made to this original BNF.

Firstly, the “module” rule was expanded. It is now referencing separate rules for the source model, target model and transformation mode (i.e. sourceModelPattern, targetModelPattern and transformationMode). There might be more of these changes possible in other parts of the grammar, depending on your particular use case.

Secondly, in some places “IDENTIFIER” has been changed to the choice of an identifier or a string as some of the example transformations used during the development of the parser allowed both. This is a bit different than the concept of Identifer in other languages such as Java, C#. It is still unclear whether this applies to every instance though. If so, the grammar should be modified accordingly.

A small wrapper class, the “ATLTransformationParser”, was written to facilitate the parsing of ATL transformations. The parser can take either a filename or a stream as input (i.e. via the Parse method). Alternatively, a string can also be given as input (i.e. via the ParseString method). In both cases, a parse tree (syntax tree) is returned which can be traversed either manually or via a dedicated visitor.

Sidenote: The origin of the ATL# parser lies in the ARTIST EU project where ATL transformations are extensively used. One of the tools developed in the context of ARTIST, the Evolution Support Service. The Evolution Support Service is taking different versions of one particular ATL transformation, tries to find low level changes, and afterwards tries to infer high-level changes/change patterns from these low level changes. ATL# was used during the initial model creation of ATL transformations.

The source code for the ATL parser can be found on GitHub . Please note that the same grammar that was used here could also be used to generate a similar Java parser for ATL.

All modeling trends in your inbox

All modeling trends in your inbox

Follow the latest news on software modeling and low-code development

You have Successfully Subscribed!

Pin It on Pinterest

Share This