Import and export from text file

Hi,

I'm just starting with MPS and I have a fundamental question for me.

I would like to know if it possible to export the text representation of my code done in MPS to a file. In addition, and above all, can MPS import it back?

In short, can I share my code written within MPS with someone who do not use MPS to edit the code? Will I be able to import his code?

Thank you for your answer.
5 comments
Comment actions Permalink
As MPS is a projectional editor you can't edit the code in another editor.
Actually MPS is just a great GUI to your model and there is no text-representation.
How would you create references in that other editor etc...

The models are saved as XML-Files. You can take a look at those if you are interested.

Of course you can write a generator to generate the text from the model.
And you probably can write a import-tool to generate back a model from the text.
(This is currently done when you import legacy java files. Like the "paste as java" command.)

see. http://forum.jetbrains.com/thread/Meta-Programming-System-543
0
Comment actions Permalink

Hi,

What is the state of this feature? Can you export and import the XML representation of the models back in MPS?

Other question, can you export only the *AST* of the domain-specific language you've created? In which format?

Thank you.

0
Comment actions Permalink

MPS already uses XML underneath and the XML already represents the AST. You can also use mbeddr's Copy as XML/Paste XML to export nodes in a slightly different format. Or write your own XML exporter which is not difficult.

0
Comment actions Permalink

Thank you for your answer and your work on MPS.

Another question.

Can I feed external plain text file representing a "solution" to Jetbrains MPS command-line ant-based tool to generate the output? Is there any way to make the external plain text "solution" be considered as one of the "text-based editor" representation of the domain specific language previously designed with MPS? Somehow feed the plain text into the XML underlying structure, and raise error, if any?

With kind regards,

Nicolas

0
Comment actions Permalink

There's an easy way and a complicated way.

The easy way is to write custom code to parse your text file and create MPS nodes out of it, and do it explicitly when a user triggers an action.

The complicated way is to use custom persistence support in MPS to integrate this deeper. For more information, look up "custom persistence" in MPS Help: https://www.jetbrains.com/help/mps/mps-user-s-guide.html?q=custom%20persistence&s=quick. You'll still need to parse the text file and create MPS nodes out of the results but now you'll need to implement some code around it to integrate with MPS.

In my experience with MPS (several years so far) I have implemented/worked on several importers and exporters but never used custom persistence.

1

Please sign in to leave a comment.