سؤال

I defined my DSL in XText and it automatically have Java version of language parser and code generation skeleton generated, which is really cool.

The problem is that my DSL is intended to be consumed by projects that are implements with multiple languages. You can imagine that we may need to parse the DSL in C#, Java and Ruby at least.

So the question is: Is there a way to generate the parser for multiple languages with the help of xtext?

هل كانت مفيدة؟

المحلول

The pure parsing stuff is only a small part of the complete Xtext suite. Integration into the Eclipse IDE and the Xtend generator stuff are two big chunks of code. And Xtext builds on top of the EMF Ecore model. None of these parts are available in other languages.

So running Xtext from within plain C# and Ruby is not possible.

What you can do:

  • You can package the parser and generator stuff into a standalone jar and call that as an external process from anywhere (including from C# and Ruby). This would be like javac for you own DSL.

  • You can run your Ruby code in JRuby and call the Xtext stuff from there. Since everything runs in the same JVM you would have better control than running an external program.

  • You can use Xtext in order to get a user-friendly editor with all the cool stuff but implement independent grammar for any language you want.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top