LionWeb can represent MPS languages in LionCore. It supports most MPS languages without changes to the language; all limitations are listed in this document.
We amend MPS' language structure aspect with node attributes to support advanced LionWeb features.
To use advanced LionWeb features, add io.lionweb.mps.structure.attribute
to the Used Languages of the structure aspect of your language.
Even if you don’t need any advanced LionWeb features, you should add this Used Language to all your LionWeb-processed languages: It checks the constraints described in this document.
In LionWeb, partitions serve as the container for one node tree (similar to models in MPS).
Use intention Toggle LionWeb Partition to add a boolean attribute LionWeb partition
to a concept.
If no such attribute exists, we assume default value false
.
LionWeb supports optional properties on structure level, whereas MPS only considers them on editor level.
Use intention Toggle LionWeb Optional to add a boolean attribute LionWeb optional
to a property.
If no such attribute exists, we assume default value false
, i.e. consider the property as mandatory.
Unlike MPS, LionWeb supports multiple references, i.e. references with cardinality ⎵..n
.
MPS approximates them with smart references; LionWeb formalizes this approach.
Use intention Add LionWeb Smart Reference on a concept to turn the concept into a LionWeb smart reference.
Point the new attribute LionWeb smart reference for
to a child with the smart reference as target.
LionWeb considers the child as a reference with the smart reference’s target as type, and does not represent the smart reference itself.
A Book
can refer to zero or more authors
of type Writer
.
In MPS, we need an additional smart reference WriterReference
, annotated with a LionWeb smart reference for
that points at the child Book.authors
.
LionWeb omits the smart reference, and turns MPS' author
child into a reference with multiple: true
.
concept Book extends BaseConcept … children: authors : WriterReference[0..n] references: << ... >>
concept Writer extends BaseConcept … children: << ... >> references: << ... >>
concept WriterReference extends <default> … children: << ... >> references: writer : Writer[1] LionWeb smart reference for: Book.authors
Concept Book extends Node Reference authors: Writer optional: true multiple: true Concept Writer extends Node << ... >>
-
Must be a concrete (i.e. non-
abstract
) concept -
Must not be used for anything else (e.g. a target of a reference, or super-concept)
-
Must not extend any concept except
BaseConcept
-
Must not implement any interfaces
-
Must not have any property members
-
Must not have any child members
-
Must have exactly one reference member
LionWeb uses keys to refer to language entities. By default, LionWeb-MPS derives the key from MPS' internal ids. As language designer, we can customize the LionWeb key (e.g. if they need to be consistent across different implementations).
-
Keys must be valid identifiers. Use intention Replace invalid characters with dash to fix invalid keys.
-
Keys must be unique within one language.
Create a root node of concept LionWeb Language Key
inside a structure aspect to customize the language’s key.
This concept provides two handy intentions:
-
Replace Key with Name for All Language Elements uses all elements' names as key. Example:
MyGreatConcept
gets keyMyGreatConcept
, and its propertynumberOfThings
gets keyMyGreatConcept-numberOfThings
. This intention overwrites all existing manually assigned keys. -
Add Name as Key to All Language Elements assignes the same keys, but only to elements without an existing LionWeb key.
LionWeb-MPS supports custom keys for the following MPS language structure elements:
Use intention Toggle LionWeb Key Annotation to add or remove a LionWeb key. Alternatively, use intention Remove LionWeb key on the key itself to remove.
Contrary to MPS, LionWeb supports JSON as primitive type.
Add io.lionweb.mps.m3.structure
to the Dependencies of the structure aspect of your language, and use JSON
as data type of your property.
Note
|
LionWeb-MPS currently does not validate the contents of a JSON property.
This might change in future releases.
|
MPS' attributes map to LionWeb’s annotations. MPS specifies details via attribute info.
However, LionWeb does not support all edge cases of attributes:
-
LionWeb only supports attributes on nodes, i.e. specializations of
NodeAttribute
. LionWeb does not support attributes on properties, children, and links, i.e. specializations ofPropertyAttribute
,ChildAttribute
, andLinkAttribute
. -
LionWeb does not support annotations on all annotations i.e. the attribute info / attributed concepts must not target
NodeAttribute
.
LionWeb-MPS does not support MPS' primitive datatypes completely. We can process them based on the structure aspect of a language, but not based on the run-time language representation (because primitive datatypes are not represented in the SLanguage).
LionWeb-MPS does not support deprecated Enumeration Data Types. Use Enumerations instead.