Is it possible to export a DSL compiler created with MPS and use it independently (e.g. invoke it from another java program)

I'd like to build a DSL and use it as follows:

  • The DSL compiles to Java.
  • I don't intend to write my DSL programs and compile them from an IDE. Instead I'd like to export the DSL compiler and package it (i.e. as a JAR), so I can invoke the DSL compiler from a Java application to compile "code written in my DSL" into "Java source code" (I'll use other libraries to programmatically compile Java into bytecode).

Can I use MPS to build a DSL and export its compiler as described? 

3 comments
Comment actions Permalink

The MPS generator can be run from Ant, so it is possible to have a command-line build pipeline that includes MPS to generate models into Java source files.

You have to provide MPS models on the input side of the pipeline, though. MPS cannot handle text-based DSLs. So the models will have to be written in MPS.

Vaclav

0
Comment actions Permalink

How do you intend to write your DSL programs? MPS uses projectional editing and the DSL programs are stored as XML files. You won't be able to write them using a text editor.

0
Comment actions Permalink

I see. That means I need MPS to write my DSL; unless there is a programmatic way to convert my DSL text (which is a projection) into MPS models, which seems to be not present at the moment.

thanks Vaclav Pech and Sergej Koščejev for the answer/clarification.

0

Please sign in to leave a comment.