What is the application order of rules in generator templates?

I've many time recognized that I haven't really understood the order MPS applies the rules of a template. That is why my generators now consists of many templates with sophisticated priorities.
And now again I want to implement the following:
  1. A root node a of concept A should be transformed to a node b of B. But root node a should be kept in the model. There will be just one node of A in each model.
  2. For each node c of C, which is no descendant of a, one node d should be generated to the subtree of b.
  3. Each node of concept C should be transformed to a node of E.

Is there any way to implement this with just one mapping template without any scripts?

My first approach was to put the functionality of 1 into a root mapping rule with a mapping label. The second step should done by a weaving rule, where the label is used to get weaving context. And the last step can be transformed by a simple reduction rule. But unfortunately the root mapping rule seems not to be applied before the weaving rule starts, since node b is not available as context. I've also checked this with printf-debugging. So I can't follow the order mentioned in http://confluence.jetbrains.com/display/MPSD25/Generator


Please sign in to leave a comment.