Meta Programming System
How to text gen from language A via language B?
I'm attempting to write a text editor around a few concepts. I want to generate HTML from it, so I defined an additional language, 'Xml', which contains two basic entities –
The idea is that I use a concept from my original language (e.g.,
), I transform it into the Xml language's
element, and then use the text gen from that to output the resulting HTML.
My question: how do I actually do it? I have added the Xml language to the original language's imports, but I see no ability to actually
this language in the textGen portion of the language. Am I missing something?
Dmitri Nesteruk, Developer Evangelist, ReSharper Team
You're on the right track, but there are a couple of things that will make this much simpler. First, you don't need to define your own XML language, there is one built into MPS (3 in fact, but the recommended one is j.m.core.xml). Second, you only need to do a Textgen transformation for the last language in the chain - everything else is a model-to-model transformation down to that language. In this case, the built-in XML language has its own textgen, so you simply transform your language to the XML language, and then the textgen will be taken care of for you.
One slight annoyance is that the j.m.core.xml language hardcodes the file extension to "xml". Of course, many XML format documents do not use the .xml extension, e.g. xhtml in your case. The workaround is pretty straightforward, but a little clunky IMO - I can send you an example if you need it. I'm actually working on a patch to fix this problem which I will submit soon (tried to do it last night, but the master branch was broken so I need to wait for a clean build). Hopefully it will get approved and merged into the main codebase before the 3.0 release, as it's fairly trivial.
I worked up a simple example to show how this works. You can get the code from git://github.com/haneysoft/haneysoft-mps.git
go to parent
Thanks for that, I'll check it out!
go to parent
Jabber notifications not working
Maintenance of customer's model
Build #176 (May/07/2014 4:41PM)