MPS
 
2021.1
Get MPS
You are viewing the documentation for an earlier version of MPS.

Lightweight DSL

Last modified: 23 March 2021

Years of evolving the MPS core languages led us to recognizing recurring patterns in our language-descriptive DSLs for IDE integration. Conceptually they looked and behaved like higher-level constructions expressed by plain classes that implement some higher-level interfaces. In the good tradition of language-oriented programming we decided to reflect these patterns in the languages and re-implement them as a thin abstraction on top of plain BaseLanguage classes. The new Lightweight DSL language has been created to enable such abstractions.

The  jetbrains.mps.baselanguage.lightweightdsl  language enables internal DSLs to be embedded inside BaseLanguage  classes. Internal DSLs in general are easier and faster to develop than full-blown external DSLs, they typically reuse the syntax of the host language and tightly integrate with the surrounding non-DSL code. Similarly, lightweight DSLs  in MPS can be created by defining a single node and then weaving the node into a BaseLanguage ClassConcept or its subconcepts.

MPS itself leverages this mechanism in several places:

  • MigrationScript  concept, which is a mere BaseLanguage class, is enhanced by the Migration  DSLDescriptor that adds a few extra properties, members and custom members

  • Find Usages

  • Intentions

  • Custom language aspects

You can have your lightweight DSL weaved into a plain BaseLanguage class or into your own concept extending ClassConcept.