Can MPS execute the domain specific language or does it just check the syntax like a parser?

I am building a tool with which I can analyze dependencies between parameters. To do this, I want to create a domain-specific language that describes the different variants of dependencies.
When a domain expert uses my language to implement his case in MPS. Can MPS actually execute the language or does it just check the syntax?

If MPS only acts as a parser, does it still generate an output that contains program code and can be executed in a different environment?







If you have modelled your DSL in MPS, a domain expert can "code" in this DSL from within MPS. It is crucial to realize that MPS follows a non-traditional way of "coding", namely projectional editing. I mention this because you wondered whether MPS acts as a parser. It does not -- precisely because there is neither a need for parsing nor a need for syntax checking* with the projectional editing idiom. With projectional editing, you are working very close on the AST rendering these operations unnecessary.

You asked whether MPS can generate or even execute program code from the input provided by your domain expert. Yes, it can. For that, you need to add so-called generators to your DSL within MPS. These transform concepts of your DSL to concepts of a target language of your choice. If I remember correctly, the "Shapes" example in MPS' documentation (a drawing/painting DSL) generates Java code that draws with Swing.

The target language needs to be modelled in MPS, too. If you are fortunate to use a language other people have already modelled in MPS (e.g. the pre-shipped Java dialect), you can just use those. If modelling the target language yourself is too costly, you may look into the "plaintextgen" plugin which allows you to simply output arbitrary text files.

*) here, I mean syntax checking in the narrow sense that becomes unnecessary with MPS since you already have the AST. In a broader sense, you might want to add constraint and typing rules to your modelling of the DSL within MPS.


Additionally to what has been said about the generators, you can also follow a different approach for your DSL to make it executable and instead of generating the code for the target platform, write an interpreter for your language that will execute in some way constructs in your language directly in MPS. Although MPS itself does not ship any ready-to-use interpreter infrastructure, you can check the mbeddr platform intepreter ( that has been used across many different projects. It contains the language used to define interpreter rules for your language and the runtime infrastructure that executes those rules for a model written in your language. And then it's up to you, to define which parts of your language should be executable and which execution semantics should be applied to them.


Please sign in to leave a comment.