Language to Language generator
I am learning MPS and I would like to create a generator that generates a language other than java. Can someone point me to a tutorial or a project or information where this is done?
I created a test project, with two simple languages, L1 and L2, each one with just one concept. I want to generate L2 from an L1 solution. I can generate Java from L1, but after some time trying, I can´t generate L2.
Please sign in to leave a comment.
Have you seen this page: https://confluence.jetbrains.com/display/MPSD33/Generator?
I have read it and gone through the tutorial. Still the same question.
I have two languages. L1 and L2. Each one with just a root node (l1 in L1 and l2 in L2). Also, I have a solution cointaining just the root node from L1 .
I declare in language L1 a dependency on language L2 as generation target.
On L1.generator I declare usage of language L2.
On L1.generator.template/main@generator I declare usage of language L2.
Then, when I go to the "mapping configuration main" script, I try to add a root mapping rule that will map from l2 to l1. I click on the intention, select "New Root Template" and then l2 root node from the menu.
A "l2" node is created inside L1.generator.template/main@generator, but the consequence part of the root mapping rule doesn't show it, and if I try to set the consequence to "l2", it doesn't allow it.
On the other hand, if instead of selecting "l2" from the "New Root Template" intention menu I select "class". A new node named "map_l1" is created inside L1.generator.template/main@generator and I can use it in the consequence part of the rule.
What is the difference between the "class" node and the "l2" node? both are root nodes. My understanding is that I should be able to map "l1" to "l2" in the same way I can map "l1" to "class".
I can send screenshots if they would help.
I remember a similar behavior, when I2 was not implementing the INamedConcept interface. Could this be the case?
Vaclav
Yes, that is exactly the case. It works as expected after adding the interface.
This is a big gotcha. Wouldn't it be a good idea to throw an error when the user tries to create a map between root Concepts that don't implement the INamedInterface?
I forgot to say thanks.
Right, I had the same issue with the missing INamedConcept interface!
Sorry for the trouble, guys. It is scheduled for fixing in 3.4 - https://youtrack.jetbrains.com/issue/MPS-23716