plied to a subset of the members of a language ele-
ment model. This subset determines the syntax of ref-
erences to particular instances of such elements in the
concrete syntax of the corresponding language. That
is, any appearance of the same set of values will be
interpreted as a reference to the same instance of the
referred language element.
The use of references is resolved in our imple-
mentation of ModelCC by the introduction of gram-
mar productions that characterize such references and
semantic actions that map them to the corresponding
language elements.
In Figure 3, the @ID annotation is employed to
identify users by a single number.
However, the @ID annotation can be used to-
gether with other ModelCC annotations, such as
@FreeOrder, which allows the members of a lan-
guage element to be shuffled in their textual represen-
tation, and @Prefix and @Suffix, which add syntactic
sugar to the incarnation of the abstract syntax model
as a concrete textual language.
The inadvertent definition of two entities of the
same class with the same identifier results in a run-
time warning produced by ModelCC when parsing its
input.
3.2 The @Reference Annotation
ModelCC resorts to the @Reference metadata anno-
tation to complete its support for reference resolu-
tion. The @Reference annotation applies to indi-
vidual members of any language element, provided
that the referenced types contain at least one @ID-
annotated member in their model.
Whenever a language element member is anno-
tated with @Reference, the corresponding grammar
productions are modified so that they refer to the sym-
bol corresponding to the element reference specifica-
tion rather than the symbol that corresponds to its full
specification. These productions are then associated
to a semantic action that resolves the references at
the end of the parsing process, in order to support
cataphoric and recursive references, apart from the
anaphoric references that could be resolved on the fly
during the parsing process.
In Figure 3, the textual syntax of messages in-
cludes numbers that, as identifiers, refer to particular
users. ModelCC will parse such identifiers, recognize
the references, resolve them, and return the correct
object graph.
[@@@.@
[@@@.@
[@@.@
ssssssssssssssssss
[@@@.@
[@@.@
[
I]]U
[
Figure 3: ModelCC specification of Messages, their
senders, and their receivers.
4 A WORKING EXAMPLE
In this section, we present an example language that
allows the specification and rendering of complex 3D
objects using the reference resolution capabilities of
ModelCC.
First, we will outline the features we wish to in-
clude in our 3D object specification language. Then,
we will provide the full language specification for
ModelCC by defining an abstract syntax model,
which will be annotated to specify the desired ASM-
CSM mapping. Lastly, we will see an example input
and output pair for our 3D object specification lan-
guage.
4.1 Language Description
Our 3D object specification language is designed to
support the following features:
• A special section, denoted by the “scene” key-
word, delimits the statements that will be used for
rendering the scene.
• The definition of custom objects, which are iden-
tified by an object name. As references can be
lazily resolved, recursion is allowed.
• Scoped statements, delimited by “{” and “}”, that
allow the specification of lists of statements that
will run in a new scope.
• Composite statements, delimited by “[” and “]”,
that allow the specification of lists of statements
that will run in the current scope.
• Repeated statements that allow the repetition of
a statement, a group of statements, or a block of
statements, a number of times.
• Draw statements, which draw either basic objects
(e.g. a cube) or user-defined objects. Draw state-
ments allow the specification of a numeric param-
eter. The “next” keyword, when used as this nu-
meric parameter, is replaced in runtime by the cur-
rent parameter decreased by one, and draw state-
ments will not run when the parameter is 0.
• Scale transformation statements, which support
the specification of a combination of x, y, and z
MODELSWARD2014-InternationalConferenceonModel-DrivenEngineeringandSoftwareDevelopment
154