I created a new language (again) for one of my clients this week. I love doing new languages and I’ve been working 20h a day on this one. I’ve been doing my last languages using the Microsoft tools, so I was afraid I would be a bit rusty on the open-source tools.
The language requires a textual syntax, so I decided to use ANTLR for the concrete syntax. EMF is of course my default choice for the abstract syntax.
After a few days I had completed the abstract and concrete syntax and had a pretty complete plan of how I wanted to perform the transformation. This is when I ran into some interesting choices.
First, I wanted to make sure I picked the proper transformation engine. The transformation is not very hard (it requires many transformers, but the distance from the abstract syntax to the finished products are not complex), so I decided for a direct model-to-text transformation (M2T). I usually try to avoid this as it makes the generation templates more complex than they need to be (that is, I like to do model-to-mode transformations until the transformation to text requires no logic), however, I’m not going to maintain this code and I did not want the client to have to also learn a M2M framework.
The M2T project at eclipse (http://www.eclipse.org/modeling/m2t) lists a few candidates. I was pretty sure I would select JET as the template engine. I already created a course section on JET (in our EMF course http://www.inferdata.com/training/java/emf.html), and I feel I know JET very well. It turns out that JET has taken leaps forward since I looked at it (and EMF does not take advantage of it yet), so I realized I’d have to spend some time learning the new constructs. I then went on to look at the alternative M2T engines. There are two listed in the M2T section:
  • Acceleo: http://wiki.eclipse.org/Acceleo
  • Xpand: http://wiki.eclipse.org/Xpand
After some quick evaluation, I could not find a reason to go from JET to any of these tools. Not that Acceleo and Xpand was not good, I just could not find any main reason to switch ideas.
Next, I wanted to also provide a good editor for the developers of my new DSL. I thought surely there has to be someone that has defined a code-generator with ANTLR as input and an Eclipse editor as output? I may have been sloppy, but I could not find one. Tempted as I was to write one, I realized, I will not have time… Then I ran across the Xtext project (http://www.eclipse.org/Xtext/). I’ve heard of it, but never fully investigated it. After my first investigation (and some communication with the main contributors, thanks guys!), I’m not pretty sure it is the right tool.
I’ll get back to the blog after I’ve finished my project, but it really looks as a brilliant piece of work. Xtext seems to be able to combine the ANTLR grammar (as concrete syntax) with ECORE models (as the abstract syntax). It also provides a very nice template based code generation language.
I’M ALL EXCITED!!!

2

View comments

About Me
About Me
Blog Archive
Subscribe
Subscribe
Links
Subscribe
Subscribe
Loading