TextGen generate different programming langugages code from one concept
I have a concept (let's call it A) that is being generated into a Ruby class using TextGen. I want to have the possibility to generate the same concept into other languages e.g Python. Could someone describe how to do it or some hint?
Please sign in to leave a comment.
This is answered at the end of the Generator Cookbook: https://www.jetbrains.com/help/mps/generator-cookbook.html#howtogeneratemultiplefilesperrootnode
Basically, don't use TextGen, use the generator for that (where you can use plaintextgen language).
I would create two concepts: GenerateRubyFromA and GeneratePythonFromA. Each would have a reference to, or a copy of, concept A. You can create these concepts in a preprocessing script of the generator mapping configuration. Then I would define, using textgen or plaintextgen, the transformation of GenerateRubyFromA and GeneratePythonFromA to text.
Thank you for a quick response. I am new to MPS. I tried to use the plaintextgen language and the pre-processing script aproach. I defined two concepts - GenerateRubyFromA and GeneratePythonFromA. I defined root mapping for them (resulting in plaintext generation). I defined the pre-processing script it looks something like the code below. Additionally the "Generate*" concepts have the concept A (in this case called ApiController) as a children.
Unfortunately, it does not work as intended. How should this script look like? Should I prepare separate models for the Generation concepts?
Update: I manage to generate this files using root mapping and following pre-processing script:
Is it a good approach? Should I now include there concept A instance via accessing it on the model variable?
Yes, exactly.
can you give me your sample project?