Automated node creation/alteration

I'm very new to MPS and am working on a DSL that will generate XML to be parsed and executed by a separate application.

As part of my DSL, I want to be able to refer to aspects of an external code library. In this case, the external code is in C#. For example, I want to be able to reference the types and public methods contained therein. My DSL contains concepts which wrap the types of things I want to reference in my MPS solution (e.g. CSharpType and CSharpMethod).

I can effectively generate a representation of my C# code in an easy-to-parse format (e.g. XML) which describes all the information my MPS solution will need to import.

I'm just trying to determine the best way to handle the import and node creation automation. It looks like this can be handled through the openAPI of MPS, but I've yet to find a nice example.

Is there one which someone can point me towards?

Is it best to handle the node generation from within MPS, or by modifying the model externally? Will MPS cope well with an automated process which later alters some aspects of these generated nodes (i.e. keeping the generated nodes in sync with the external codebase). It's fine if such an update creates errors which need to be fixed in the DSL solution. I just want to make sure I don't ever risk corrupting an entire solution by breaking references during an update.

Thanks very much for any insight. Hopefully this makes sense, and is possible :)
3 comments
Comment actions Permalink
Hello larrylebron!

If you don't desperately need a custom xml representation of your DSL then this is the right one to go: (uses mbeddr)

Serializer (com.mbeddr.mpsutil.serializer)
The serializer used to create the XML representations above is accessible programmatically. The classes are called NodeSerializer and NodeDeserializer


However, I had a similar use case in the past. I solved it using the jetbrains.mps.core.xml language to output the xml from my dsl. The other way round was built with an import action and manually passing the xml tree. Look here:
https://confluence.jetbrains.com/display/MPSD32/Plugin#Plugin-Actionsandactiongroups

If you want an advanced solution, you can look here: (although I haven't tried it yet)
http://forum.jetbrains.com/thread/Meta-Programming-System-4956

Regards
msch95
0
Comment actions Permalink
Thank you so much for the response, msch95. I'm likely going to have more follow-up questions, but here's the first that comes to mind!

You mention using mbeddr's NodeSerializer and NodeDeserializer if I don't need a custom XML representation. Are you saying that I can use these libraries to generate XML directly from my model instead of defining XML-generators for my concepts? This sounds great, if so, and if it's a format which will be nicely parse-able by another language (e.g. python or c# which are my two main contenders).

If that is the case, can you help me understand how to use it? I've downloaded the mbeddr source, and found the com.mbeddr.mpsutil.serializer.xml directory. I attempted to open it in mps, but got errors regarding a git repository. Is this the intended workflow, or is there a compiled version of serializer/deserializer I should be looking for?

Any chance you know of a sample project with this workflow established which I could check out, or even an example of mbeddr's serializer's xml output?

Thanks again!
0
Comment actions Permalink
You're welcome. That`s the purpose of this forum.

If it's only this warning, I won't see any problems.
Undefined macro: mbeddr.github.core.home

Anyways, you need to work through this installation guide:
http://mbeddr.com/download.html

I included this package, in the alt+enter dialog.
If you have problems with it, you can always ask here.

I've defined a plugin action with the code from the threads:
https://confluence.jetbrains.com/display/MPSD32/Plugin#Plugin-Actionsandactiongroups

This thread is worth looking:
http://forum.jetbrains.com/thread/Meta-Programming-System-4912
/_persistent/add_node_from_clipboard.png?file=29-5742&v=0&c=true

For C# I also recommend the feature Paste XML as C# classes
http://blog.codeinside.eu/2014/09/08/Visual-Studio-2013-Paste-Special-JSON-And-Xml/

Regards
msch95
0

Please sign in to leave a comment.