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 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
MyEntity[] myattribute;
is a valid statement of our DSL, while the one below (note the spaces between the square brackets):
MyEntity[ ] myattribute;
produces a syntax error.
This is not good, since we do not want spaces to be relevant (although there are languages such as Python and Haskell where spaces are indeed relevant).
The problem is due to the fact that, in the Attribute
rule, we specified []
, thus, no space is allowed between the square brackets; we can modify the rule as follows:
Attribute: type=[Entity] (array?='[' ']')? name=ID ';';
Since we split the two square brackets...