Improvements to the DSL

Now that we have a working DSL, we can do some improvements and modifications to the grammar.

After every modification to the grammar, as we said in the section The Xtext generator, we must run the MWE2 workflow so that Xtext will generate the new ANTLR parser and the updated EMF classes.

First of all, while experimenting with the editor, you might have noted that while

MyEntity[] myattribute;

is a valid sentence of our DSL, this one (note the spaces between the square brackets)

MyEntity[  ] myattribute;

produces a syntax error.

This is not good, since spaces should not be relevant in a DSL (although there are languages like Python and Haskell where spaces are indeed relevant).

The problem is due to the fact that in the Attribute ...

Get Implementing Domain-Specific Languages with Xtext and Xtend now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.