How to trigger text generators for children


I'm new to MPS, and I have designed a language with the ultimate goal of generating Java classes based on some configuration files. The problem is that I don't know how to trigger the text generator for some of my concepts. A part of what I have (a configuration file) is this:

For the database part, I have a separate concept which has a TextGen, and I used a mapping between that one and the configuration file. Worked just fine.
The problem is the BLE part. Each bleService section (namely A and B in this case, the might be more in other cases) should be a class with every char and charPack as a property (for A, it would be AA, AB, etc.). And every charPack is a class itself with lines inside as properties. Something like this for the first bleService in the above image:

public class A {
    float AA;    
    AB aB;
    Ac aC;


public class AB {
    int AB1;
    int AB2;
    int AB3;


Both bleService and charPack concepts have text generators. I don't know how to trigger them. I tried mapping from configuration file concept to both these concepts and looping over their nodes and use COPY_SRC but it didn't work.

Any advice is much appreciated.



Edit: This is what I have for my mapping rule:



There seems to be some confusion about TextGen, Generator and text generation in your question, I'm afraid. What you need in order to turn your Configuration into BaseLanguage classes is the generator, which has nothing in common with text generation (TextGen). 

Maybe I need more information to understand fully your case, since you should rarely have a need to define both TextGen and Generator for a single concept. Why did you create TextGen for bleService and charPack? Why is your generator turning Configurations into bleServices (your mapping rule)?




Hi Vaclav,

What I want to do is asking for some information from the user in one file (an instance of Configurations), and generate multiple Java classes and JSON files. When I create a solution for Database concept, the text generator works fine and generates the file I want. Same for bleService and charPack. But when they are all in the Configuration concept (shown above) the text generators don't generate the files. What I did for the database part was creating a mapping from Configuration to DatabaseConfig like this:

Then I used property macros to assign all the properties (like assigning authority from Configurations to authority in DbConfig concept). I'm not even sure this is the right thing to do, but it works. Now, the file for the database part of the Configuration is generated. I tried doing the same thing with bleService and charPack (so creating a mapping rule for turning Configurations into bleServices), but it seems that their text generators are not called.

Basically, I need to call text generators for multiple concepts (databaseConfig, bleService, charPack) included in one (Configurations). There might be multiple bleServices in one Configuration or multiple charPacks in a bleService, and each needs to be turned into a file.

Hopefully, this makes things clear.



I figured it out! Creating mappings from my Configurations concept to each included concept (bleService, charPack, etc.) and using COPY_SRC in each mapping worked.


This is good to hear. If you haven't looked at the generator tutorial yet (, maybe you could gain some additional insight into how the generator in MPS works.




Please sign in to leave a comment.