Custom Generator Class

Now that I have a Template Editor for language c, I would like to use it do define a transformation from another language d to language c and output the result as text.

So I do the following:

  • create a solution d_test using language d

  • set up the "generator ->c" in language d

  • try to run "Generate Text from Model" on solution d_test

I get an error, that I need to set my generator class. So I do that in the language properties of language c (that is the target language) and pick the DefaultXMLGenerator (c_lang_prop.png). Now the generation seems to work, but the result cannot be mapped to text (text_output.png).

I guess, I need to define a Generator Class for language c (i.e. extend jetbrains.mps.generator.AbstractModelGenerator).

I was looking for an example of one of the predefined generators (like, but I dould not find them. Maybe someone has an example of how the Generator Classes work.


Never mind, I figured it out.

The sample project "textLanguage" shows everything I needed to know (see projects\textLanguage\source\jetbrains\textLanguage\textPresentation in your mps-installation).

So I just use the DefaultXMLGenerator + supply my own TextPresentationGenerators for the target language in a package called mylanguage.textPresentation.



Please sign in to leave a comment.