Export/Import generated Nodes

Hi there!

I recently got some good advice to take a closer look at MPS, since I'm trying to generate some DSL out of a GPL and back into another one. First of all: MPS is a great tool for editing and creating DSL as far as I can tell. Yet, I have come across some issues, that are crucial for my thoughts, and it would be nice, if anyone can give me some answers ;)

At first: Is there a possible way to generate a language out of a given XML-file? When I looked at the MPS 2.04 Example Models I came across the SampleXML model and I asked myself if there is any chance to do things the other way around, saying that the source is an XML file and the generated outcome is a language like SampleXML.

The second question is if any generated output, that is not JAVA based, can be saved and lateron be imported by another model. The example I was trying to do is the following. Language A generates a node N for language B. Can N be saved or reimported by a model that has language B/ a solution for language B implemented?

I'd be glad to get some answers. Keep up the good work!

Greetings, Markus
7 comments
Markus,

About your first question. If I heard you aright, you would like to use MPS generator to generate something from existing XML. Now this is possible only if you export your XML file into MPS (I mean, you write a code which parses your XML and creates MPS model corresponding to that XML). We plan to introduce custom model persistence in the nearest future (in 3.0, or even 2.1), so that you'll be able to make MPS treat your XML as regular MPS model. The difference is not very big, now it's just a bit less convenient now and slower if you have a big amount of models.

The second one. Answer is: "we haven't covered that case yet, but still you principally can". The thing is, MPS can save intermediate models on generation, and you can just copy-paste from those models. In addition, you can write your own "generate partially" action, which could generate your model to a given stage and then copy the result to a real model further saved on disk. As far as I remember, this is possible, but you have to get familiar with MPS code or ask some questions here on the forum.

Regards,
Mihail
0
Hi Mihail!

Thanks for the fast answer! So if I understand you correctly: My problems can be solved by MPS, but (at least at the moment) it will take some no-trivial workarounds by myself (non trivial in my case ;)). Concerning question one: So I should start with the baseLanguage, write a parser-method for the xml file and generate a new language out of that or do you refer to something else.

Greetings, Markus
0
So if I understand you correctly: My problems can be solved by MPS, but (at least at the moment) it will take some no-trivial workarounds by myself (non trivial in my case ;))

That's it.

Concerning question one: So I should start with the baseLanguage, write a parser-method for the xml file and generate a new language out of that or do you refer to something else.

Ah, it seems like I misunderstood you. You want to generate a _language_ by the code written on it? E.g. you give MPS some xml file and it generates a language on which the file is written? Or you mean you have an XML-descriptor of some language and want that language in MPS?

Thanks for your attention,
Mihail
0
The first one is exactly the one I am searching for. I'd like to generate a language out of the xml, such that the content of the xml could be a node itself.

Thanks for your help!
0
If you want to do it for XML specifically, we've already have a language for it - jetbrains.mps.xml. So, you don't need to generate the language, you just make a piece of code that parses an XML-file and builds an MPS model using the existing j.m.xml language.

If you want to sole the problem in common (generating the language by the code on it), it's just impossible.

Regards,
Mihail
0
Hi!

Actually, I have another question concerning this topic. Assuming that I have the XML-Scheme given to the XML file, is it possible to generate a language out of the scheme and use the XML file as a node in a solution that uses the language (kind of copy and paste the xml to the node)?

Thanks in advance for any answers!
0
Markus,

I see no problem in implementing this, but MPS does not currently have such an ability. You can try to write your own action that will transform the scheme into a language - it's not a very complex task. If you need any help on this, please feel free to ask. If you decide to implement such a feature, we could contribute it into MPS if you'd like.

Good luck,
Mihail
0

Please sign in to leave a comment.