multiple generators per language

Hi

I'm reading through MPS documentation trying to understand if it fills our needs. We need some way to define a domain model and then generate various stuff from this definition, like Java sources, SQL DDL, etc.

The idea is to build a domain model definition language and all the target languages (having baseLanguage in place it narrows down to various SQL flavors for now). Then we could define generators from domain model language to all the target languages.. but currently the guide says:

"Technically, it is possible to create more than one generator for one language, but at the time of writing MPS does not provide full support for this feature."

Is it still true? This looks strange as the ability to define a generator for any pair of languages seems so natural..

Thanks

Update: after playing a bit with MPS I understand that there can be a single generator that uses several languages and thus produces several artifacts in different languages. Does the whole way of my thinking sound correct?

13 comments
Comment actions Permalink

Konstantin,

Now the "generator" can get a piece of code and transform it into another piece of code (using as many input and output languages as you need). There can be more than one generator for a language. But for now, there is no difference between one or many generators. Multiple generators only allow to split your generator's code into parts.

Actually, now it works the following way: given a model to generate, the generator looks into it and finds all languages used in it. Then it adds "engaged on generation" languages (see language properties), and so makes a complete set of generators that should be applied. Then the generators are splitted into groups by their priorities ("generation steps"), and then those groups are just applied to model. 

So, if you need to generate two parts in different languages from one input model, it's possible even in MPS 1.0 ). The only restriction is that they'll be placed in one output model, of course. But if you need, for example, to generate 2 _models_ from one input model, it's now impossible. If you need to customly define generators' set to apply to your model (e.g. to generate the 1st and the 2nd parts of output), it's also impossible for now. But we plan to have the mentioned features (workflow) in MPS 2.0.

If you have any further questions, feel free to ask.

Regards,

Mihail

0
Comment actions Permalink

Hi!

generators from domain model language to all the target languages.. but currently the guide says:

"Technically, it is possible to create more than one generator for one language, but at the time of writing MPS does not provide full support for this feature."

Is it still true? This looks strange as the ability to define a generator for any pair of languages seems so natural..

In MPS for each language you can create only one generator. Then in each generator you can create any numbed of generator models with any number of mapping configurations (actually used to "generate" anything). As a result you can define any number of mapping configurations mapping language concepts to different "low-level" languages. Single generator restriction looks more like a logical structure limitation.

0
Comment actions Permalink

Alex, you seem to be wrong about the possibility of creating multiple generators for language:

Screen shot 2010-12-03 at 8.22.10 PM.png



Attachment(s):
Screen shot 2010-12-03 at 8.22.10 PM.png
0
Comment actions Permalink

The idea behind the multiple generator modules for one input language has been that sometimes it might be desirable to generate into totally different and mutually exclusive targets (like to J2EE/.NET platforms). These generators would never be engaged in the same generation session. Instead, developer would create ‘generation profiles’ where he could explicitly specify which generator module must be used.

In practice however, this use-case has never really emerged (as yet, at least), so the multiple generators feature was dropped from UI. Internally MPS still supports it.

When generating MPS now always picks-up the 1-st generator module, I believe.

Igor.
0
Comment actions Permalink

Right!

So it's possible to create couple of generators but only first one will be used and i think documentation was mentioning it in originally quoted: "Technically, it is possible to create more than one generator for one language, but at the time of writing MPS does not provide full support for this feature." :-)

0
Comment actions Permalink

Yep. But if you are really super awesome, you can edit the language descriptor file to create more than one generator and push them around to have one you like best in the 1st position:)

0
Comment actions Permalink

Right.

Looked into code - only the first generator is used and an error is shown in case of multiple generators.

Sorry for confusing you ).

0
Comment actions Permalink

The idea behind the multiple generator modules for one input language has been that sometimes it might be desirable to generate into totally different and mutually exclusive targets.

[...]

use-case has never really emerged

Sorry, I don't get this. Generating into different languages and different models simultaneously seems to be a frequent use case. Building HTML+CSS+JS from some high-level web dev. DSL, Java+XML for EJB2 or Spring, Java+XML+Ruby+Python+watever from domain model description in my case..

If I have single generator building output in several languages it gets too complicated very quickly. For instance there seems to be no way to have different sets of reduction rules depending on the output language.

0
Comment actions Permalink

Hi!

I think, for now you have to stay with this complex single generator keeping in mind that in 2.0 version we plan to support generator parametrization (see Generator section of The MPS 2.0 Future Series: Part 2. blog post).

0
Comment actions Permalink

Hi,

i'm new to MPS and just playing around a little.

I cant understand that multiple generators isn't possible.

I want one generator to create a Documentation e.g. Latex or UML

and another generator for code.

As i understand i would have to mix both generators together into one. Thats a mess...

Greets

0
Comment actions Permalink

Hi!

I dont' see any problems here "generator" is just an aspect of the language. For now you have to create single generator and you still can create a number of different MappingConfiguration nodes below this generator: one mapping configuration handling code generation and another one for documentation. Where is the problem?

0
Comment actions Permalink

And how can i generate only one output of them? Or just a part of the model? Is it possible?

0
Comment actions Permalink

Currently not, but it will be possible (even with single generator) with new "generator parametrization" feature planned for 2.0 release :-)

0

Please sign in to leave a comment.