16Common Mapping
The mapping specification for each syntactic area defines how a specific Alf abstract syntax tree substructure is mapped into a corresponding part of the fUML abstract syntax representation, in terms of the further subtrees of that structure. This may be considered as a metamodel to metamodel transformation.
-
The transformation is from the Alf abstract syntax metamodel to the fUML abstract metamodel.
-
The transformation maps the root objects from the Alf abstract syntax representation to UML elements. A well-formed Alf abstract syntax tree is always rooted in either an expression (see Subclause 12.2), a statement sequence (see Subclause 13.2) or a unit (see Subclause 14.2).
The remainder of this clause defines the mapping of the common elements contained in the Alf::Syntax::Common package (see Clause 12). The following three clauses give mappings for elements in the Expressions, Statements and Units packages.
-
The root mapping takes an Alf syntax element to a UML element. By default, this mapping is empty, but the mapping is overridden as appropriate for subclasses of SyntaxElement. In particular, such a mapping definition is provided for Expression, Block, UnitDefinition and any kind of syntax element that may be the target of an internal element reference.
16.2Documented Elements -
If an element includes documentation, then each documentation string maps to a comment element attached to mapping of the documented element, with the comment body given by the documentation text.
16.3Element References
During mapping, an element reference is eventually mapped to a direct link to the referenced model element, either as directly identified by an external element reference or as the model element mapped from the syntax element identified by an internal element reference.
-
An element reference maps to a UML model element.
-
An external element reference maps to the identified model element.
-
An internal element reference maps to model element mapped from its identified syntax element.
16.4Assigned Sources
An assigned source must ultimately map to an activity node that provides the source for an object flow used to obtain the assigned value, as determined by the mapping of the source syntax element.
-
The mapping of the local name to an activity node depends on the assigned source syntax element for that local name.
-
An assigned source object is mapped to the appropriate activity node as determined by querying the source syntax element.
17Expressions Mapping
The clause defines the mapping of Alf expressions to UML. The abstract syntax for Alf expressions is described in Clause 12.2.
17.1General -
An Alf expression that is not contained in any other Alf text is mapped to UML as an activity with one parameter: a return parameter that gives the result of the expression.
-
Any Alf expression maps to some or all of the nodes and edges in an activity (sometimes called a subgraph of the activity).
-
The mapping of each kind of expression identifies the result source element in the mapping. This is the activity node to which an outgoing object flow may be attached in order to obtain the result of the expression. The result values of the expression correspond to the values of the sequence of object tokens produced on the flow. In some cases (such as when an expression is used in an expression statement; see Subclause 9.6) the result source element may remain unconnected. In this case the result values of the expression are lost.
17.2Qualified Names
The formal mapping of a qualified name is given in various contexts of its use in subsequent subclauses. In general:
-
When defining a named element, an unqualified name maps to the name of the named element, with the fully qualified name mapping to the qualified name of the named element.
-
When referencing a named element, its (qualified) name maps to a reference to that named element.
17.3Literal Expressions -
A literal expression maps to a value specification action with the literal mapping to an appropriate literal primitive element. The result pin of the value specification action is the result source element for the expression.
17.4Name Expressions -
A name expression maps to an activity graph depending on the kind of name referenced.
-
A name expression for a local name or parameter name is mapped to an object flow. The source of the object flow is given by the assigned source for the name before the name expression. The target of the object flow is determined by the context of the use of the name expression.
The assigned source of the name effectively also acts as the result source element for the expression. Note that, if this source is never connected (for example, if the name expression is used by itself as an expression statement), there can be no object flow and the name expression will actually not map to anything (since it will have no effect).
If there is a structured activity node that owns (directly or indirectly) both the source and target of the object flow, then the most deeply nested such node owns the object flow. Otherwise it is owned by the enclosing activity.
-
A name expression for an enumeration literal name is mapped to a value specification action whose value is given by an instance literal specifying the given enumeration literal. The result pin of the value specification action is the result source element for the expression.
-
A name expression for a name that disambiguates to a feature reference is mapped as a property access expression consisting of that feature reference (see Subclause 8.3.6).
Share with your friends: |