How to migrate existing data into MPS?

Hi everyone,

I am learning MPS and would like to use it in my project.

I want to use MPS to create a IDL to describe protocol msgs. The created IDL would be very like google protobuf, e.g. define msgs, msg fields could be primitive types or existing msgs. Eventually I will generate c++ and python code.

The question I have right now is that, there are some existing XML files, each of them has thousands of lines to define one protocol. How could I import this kind of XML to MPS? Also the vendors keep releasing new version of XML files, I need to figure out a easy way to import it into MPS.

I could write python code to convert XML to the IDL file(plan text) if no way to import XML directly, but how to import plain text IDL file into MPS as a new model?

Thanks.

0
3 comments

You would need to write a parser for your XML files inside of MPS which then creates the model from that XML. The importer can then take care of merging this with existing instance of the imported file in MPS etc. 

Alternatively you could write a custom persistence that can load the XML files directly into MPS similar to what the java stubs are doing. 

0

Hi Kolja,

Thank you so much for your help, your comments mean a lot to me.

Now I could fully dive into the MPS since it really can satisfy all my needs and have much better user experience than other solutions.

0

 Hi Kolja,

I have implemented a simple DSL, actually I learnt most of them from your HEAVY META Tutorials, thanks very much!!!

Now it's time to write the code to import my XML files in to MPS.

Regarding "write a parser for your XML files inside of MPS", do you have a tutorial/project to show me how to do it? 

Is this way still good to use? The author created it couple of years ago.

https://tomassetti.me/antlr-and-jetbrains-mps-parsing-files-and-display-the-ast-usign-the-tree-notation/

Thanks.

 

0

Please sign in to leave a comment.