Concrete Syntax Definition
-
The Concrete Syntax define the way language models are represented. If we consider again natural languages, the concrete syntax would be written or spoken languages.Those languages comes with a set words being the atoms of the language and with a set of well formedness rules (ruling the arrangement of those words in sentences) composing the grammar of the language.
People who are familiar with the given language can associate presented sentences to their original idea. The concrete syntax can be seen as a tool to convey information more intuitively.
-
In Lightning, a concrete syntax definition is composed of :
-
The LightningVLM.als model: This model defines the set of atoms and well formedness rules to be used in our definition of the concrete syntax. Basically, it is a simple specification of a generic visual language.
-
At least one Functional Alloy Module: Functional Alloy modules are meant to specify interpretable model transformations in Alloy.
In the context of a concrete syntax definition, functional Alloy modules are used to define the relation between the abstract syntax (the world of "ideas") and the visual language model previously described.
As an idea generally have several representation (eg. the idea of "Happiness" , can be expressed using different synonyms, in different language and in different format : (written/ spoken / ...)), it is only natural to assume that for a given abstract syntax model, several graphical representations might be appreciated.
In that respect, the number of functional alloy modules that can be specified per language is not limited.
How Should I proceed ?
As the LightningVLM.als is given by default, you do not need to bother about the definition of the language constructs.
Your only task is to define a mapping between elements of the abstract syntax and those language constructs.
To do so, simply create a new functional Alloy module.
Functional Alloy modules follow a really rigorous and specific syntax in order to be interpretatble, you should thus refer to
this page in order to learn how to write functional alloy modules.
And then ?
Well, once the definition of a transformation is done, you can apply it to any instance currently viewed in the viewer by selecting it in the first check box (see more about
verification )
You can then ask the tool to render accordingly the visual language elements present in the resulting transformation instance by selecting "CS with GEF" in the second check box.
Note that this visualization can be performed on saved instances as well, and it becomes especially handy during instance edition. (the transformation is applied at each changes)