Simple generation test

I have recently started studying MPS and trying to do some simple tests.
I’m trying to create some simplest generator which uses jetbrains.mps.sampleXML language as input and output languages.
I have only one mapping rule:

where RootOut is

The input is

When I’m looking generated output (Preview Generated Text), I have

I do not understand, WHY? I specified to generate RootOut node always in the conditional root rules.
If I remove the Input node, I have correct output:


Could anybody say, what is wrong here? Maybe it is just my misunderstanding of some MPS concepts, but currently it looks for me as some MPS bug.
Comment actions Permalink

I'm not sure if I really understand your problem. But could it be that you haven't recognized the bottom tab bar in the preview generated text window?
Your conditional root rule will add a new root in output model, which is independent of your input. Since you have no rules for transformation your input it will be copied to your output, as far as I know. So you will have two xml files in your output, you can select one with the tabs at the bottom.

There was a generator tutorial, I really recommend. But I can't find it at the moment.
Comment actions Permalink
Thank you. I really missed the tab bellow. I also have added the Document concept into abandon roots and currently have only my RootOut node in the output, as I intended.
Comment actions Permalink
Here is the generator tutorial/demo I mentioned:
Comment actions Permalink
Thank you!
Really I have seen it already, but I have another question. How can I debug code in inspector? I can place breakpoints in some functions used in macros, but they do not stop on Preview Generated Code. The only way I have found so far is usage of some debug output when MPS started under IntelliJ IDEA (I used something like "System.out.println("). I hope there is better way.
Comment actions Permalink
I've asked for this in another thread some time ago, but unfortunately there is no answer yet. So I can't help you. But I'm still interested in the topic of debugging. I really hate printf debugging...
Comment actions Permalink
Well, hope MPS guys support it soon...

Please sign in to leave a comment.