Grammar Cells

 

Grammar Cells (com.mbeddr.mpsutil.grammarCells)

MPS projectional editor affords users a lot of flexibility in terms of notational flexibility and language composition. This blog is full of examples of this, so we don't have to provide more examples.

However, this comes at a cost: building editor in MPS that don't just look nice but that also are nicely usable can be challenging. In particular, editor developers have to create so-called actions -- wrappers, side transforms, substitutions, delete actions -- that, for example, allow entering expression tree structures linearly. Enabling the insertion of parentheses in cross-tree locations, or splitting a number literal in two is even more challenging. Implementing all of this correctly can be a challenge, even for practiced users of MPS. More importantly, it is easy to forget some of those actions, which then leads to editors that behave inconsistently: good in some cases, and bad in others. Such inconsistencies are a major source of frustration for new MPS users.

To address this issue, we (mostly Sascha) have built the grammar cells infrastructure. These are new editor cells that have enough semantic richness so that the necessary actions can be generated automatically. To implement a nicely usable expression language, developers do not have to write a single line of action code. Check out this video:

Even though language developers have to invest a little bit of effort into learning how to use these new cells, it is certainly simpler to work with than the actions. In particular, it is easier to get things consistent. Check them out, they are in the master branch.