Structure language is used for defining language structure. It allows you to define concepts and concept interfaces as well as their members: properties, references, children, concept properties, and concept links.
Concepts and concept interfaces
Concept defines the structure of a concept instance: which properties it might contain, which nodes it might reference, and which children it might contain (for more information about nodes see the Basic notions section). Concepts also define concept-wide members: concept properties and concept links. There are two kinds of concepts: concepts and concept interfaces.
Concept interfaces represent traits which can be implemented by many different concepts. For example, if your concept has a name by which it can be identified, you can implement the INamedConcept concept interface.
Concepts inheritance
A concept can extend one concept, but implement many concept interfaces. A concept interface can extend multiple other concept interfaces. This system is similar to Java classes, where a class can have only one extended class but many implemented interfaces, and where interfaces may extend many other interfaces.
When a concept extends or implements a concept or concept interface, it transitively inherits all of its extended/implemented concept's members (i.e if A has member m, B is extended by C and C is extended by E, then E has member m)
Concept members
Properties
Property is a primitive value stored inside a concept instance. Each property has a type. The possible types of properties include: primitives, such as boolean, string and integer; enumerations, which can have a value from a predefined set; and constrained data types, which are strings that are constrained by a regular expression.
References
Nodes can store references to other nodes. In the reference section of concept declaration, you can specify which reference a concept instance can have. Each reference has a name, a type, and a cardinality. Type restricts the type of a reference target. Cardinality defines how many reference of this kind a node can have. References can only have two types of cardinalities: 1:0..1 and 1:1.
Smart references
If your node contains a single reference of 1:1 cardinality, this node is called a smart reference. In this case MPS creates default completion items: for each possible reference target, it creates a menu item with matching text equal to the presentation of a target node.
Children
The Children section defines which nodes can be aggregated in an instance of a concept. Each child declaration has a target concept, role, and cardinality. Target concept specifies the type of children. Role specifies the name for this group of children. Finally, cardinality specifies how many children from this group can be contained in a single node. There are 4 allowed types of cardinality: 1:1, 1:0..1, 1:0..n, and 1:1..n.
Specialized references and children
Sometimes, when one concept extends another, we not only want to inherit all of its members but also want to override some of its traits. This is possible with children and references specialization. When you specialize a child or reference, you narrow its target type. For example, if you have concept A which extends B, and have a reference r in concept C with target type B, you might narrow the type of reference r in C's subconcepts. It works the same way for concept's children.
TODO draw a picture
Concept links and properties
Sometimes we want to define concept-wide members. For example, we might want to describe how an instance of this type will be presented in a completion menu, or mark a concept as abstract, or have some domain specific purpose. For this MPS has concept links and properties. Concept link and properties can be declared in a concept declaration. If you have their declaration in a concept, then you can set its value in its subconcept. For example, "abstract" concept property, which has boolean type, is declared in the BaseConcept concept; it can be set in all of its subconcepts.
Annotation concepts
TO DO..
Add Comment