How to create an embedded DSL in MPS
I am new to MPS and have just started looking into some of the screencasts to build a external DSL with mps. I would like to create an embedded DSL i.e. a DSL that is embedded in the user input. User input consists of an XML request in between which I would like to provide the ability to add new DSL tags. For e.g.
<Customer>
<Name>{{field_name}}</Name>
<forEach>
<Transaction><{{$another_field}}</Transaction>
</forEach>
</Customer>
In the above example the xml tags <Customer>, <Name> and <Transaction> are the user input tags. While I want to create a DSL that allows the user to specify a table field name inside certain tags using the notation {{field_name}} or {{$another_field}}.
I want to also allow the user to add certain custom DSL tags like in the above example the <forEach> tag that requires at least on child tag.
Are there examples that I can look into that could help me to create such a DSL with MPS?
Thanks.
Please sign in to leave a comment.
Hi Amit,
this is a pretty easy task for MPS. I've hammered together a quick demo of what you described - check it out at https://github.com/vaclav/EmbeddedInXMLDemo
I recommend to go through the Fast Track Tutorial (https://confluence.jetbrains.com/display/MPSD20172/Fast+Track+to+MPS) to get a feel for what is possible with MPS.
Vaclav
Thanks for a quick follow up. Highly appreciate your help in creating a quick demo. I will have a look the shared links and follow up with any questions.