**3.1 NEREUS language specification**

NEREUS consists of several constructs to express classes, associations and packages and a repertoire of mechanisms for structuring them. Next, we show the syntax of a class in NEREUS:


NEREUS distinguishes variable parts in a specification by means of explicit parameterization. The IMPORTS clause expresses client relations. The specification of the new class is based on the imported specifications declared in *<importstList>* and their public operations may be used in the new specification. NEREUS distinguishes inheritance from 64 Reverse Engineering – Recent Advances and Applications

transformations. Most of the MOF metamodel concepts can be mapped directly to NEREUS.

The semantics of MOF metamodels (that is specified in OCL) can be enriched and refined by integrating it with NEREUS. This integration facilitates proofs and tests of models and model transformations via the formal specification of metamodels. Some properties can be deduced from the formal specification and could be re-injected into the MOF specification without wasting the advantages of semi-formal languages of being more intuitive and

Our approach has two main advantages linked to automation and interoperability. On the one hand, we show how to generate automatically formal specifications from MOF metamodels. Due to scalability problems, this is an essential prerequisite. We define a system of transformation rules for translating MOF metamodels specified in OCL into algebraic languages. On the other hand, our approach focuses on interoperability of formal languages. Languages that are defined in terms of NEREUS metamodels can be related to each other because they are defined in the same way through a textual syntax. Any number of source languages such as different DSLs and target languages (different formal language) could be connected without having to define explicit metamodel transformations for each language pair. Such as MOF is a DSL to define semi-formal metamodels, NEREUS can be

In addition to define strictly the type system, NEREUS, like algebraic languages, allows finding instance models that satisfy metamodel specification. Semiformal metamodels such

Another advantage of our approach is linked to pragmatic aspects. NEREUS is a formal notation closed to MOF metamodels that allows meta-designers who must manipulate

NEREUS allows specifying metamodels such as the Ecore metamodel, the specific metamodel for defining models in EMF (Eclipse Modeling Framework) (Eclipse, 2010).

NEREUS consists of several constructs to express classes, associations and packages and a repertoire of mechanisms for structuring them. Next, we show the syntax of a class in NEREUS:

NEREUS distinguishes variable parts in a specification by means of explicit parameterization. The IMPORTS clause expresses client relations. The specification of the new class is based on the imported specifications declared in *<importstList>* and their public operations may be used in the new specification. NEREUS distinguishes inheritance from

**EFFECTIVE TYPES** *<sortList>* 

**AXIOMS** *<varList> <axiomList>* **END-CLASS** 

**OPERATIONS** *<operationList>* 

**OPERATIONS** *<operationList>* 

as MOF do not find instance models and only detect constraint violations.

The type system of NEREUS was defined rigorously in the algebraic framework.

pragmatic for most implementers and practitioners.

viewed as a DSL for defining formal metamodels.

metamodels to understand their formal specification.

Today, we are integrating NEREUS in EMF.

**3.1 NEREUS language specification** 

**CLASS** className [*<parameterList>]*

**GENERATED-BY** *<constructorList>*

**IMPORTS** *<importList>*  **IS-SUBTYPE-OF** *<subtypeList>* **INHERITS** *<inheritList>*

**DEFERRED TYPES** *<sortList>*  subtyping. Subtyping is like inheritance of behavior, while inheritance relies on the module viewpoint of classes. Inheritance is expressed in the INHERITS clause, the specification of the class is built from the union of the specifications of the classes appearing in the *<inheritList>*. Subtypings are declared in the IS-SUBTYPE-OF clause. A notion closely related with subtyping is polymorphism, which satisfies the property that each object of a subclass is at the same time an object of its superclasses. NEREUS allows us to define local instances of a class in the IMPORTS and INHERITS clauses.

NEREUS distinguishes deferred and effective parts. The DEFERRED clause declares new types or operations that are incompletely defined. The EFFECTIVE clause either declares new sorts or operations that are completely defined, or completes the definition of some inherited sort or operation. Attributes and operations are declared in ATTRIBUTES and OPERATIONS clauses. NEREUS supports higher-order operations (a function f is higherorder if functional sorts appear in a parameter sort or the result sort of f). In the context of OCL Collection formalization, second-order operations are required. In NEREUS it is possible to specify any of the three levels of visibility for operations: public, protected and private. NEREUS provides the construction LET… IN.. to limit the scope of the declarations of auxiliary symbols by using local definitions.

NEREUS provides a taxonomy of type constructors that classifies associations according to kind (aggregation, composition, association, association class, qualified association), degree (unary, binary), navigability (unidirectional, bidirectional) and connectivity (one-to one, one-to-many, many-to-many). New associations can be defined by the ASSOCIATION construction. The IS clause expresses the instantiation of *<typeConstructorName>* with classes, roles, visibility, and multiplicity. The CONSTRAINED-BY clause allows the specification of static constraints in first order logic. Next, we show the association syntax:

#### **ASSOCIATION** <relationName>

**IS** <typeConstructorName> […:class1;…:class2;…:role1;…:role2;…:mult1;…:mult2;…:visibility1;…:visibility2] **CONSTRAINED-BY** <constraintList> **END** 

Associations are defined in a class by means of the ASSOCIATES clause:

**CLASS** className… **ASSOCIATES** <<associationName>>… **END-CLASS** 

The PACKAGE construct groups classes and associations and controls its visibility. *<importsList>* lists the imported packages; *<inheritList>* lists the inherited packages and *<elements>* are classes, associations and packages. Next, we show the package syntax:

**PACKAGE** packageName **IMPORTING** <importsList> **GENERALIZATION** <inheritsList> **NESTING** <nestingList> **CLUSTERING** <clusteringList> <elements> **END-PACKAGE**

MDA-Based Reverse Engineering 67

As an example, we show the formalization in NEREUS of a simplified QVT Core metamodel (Figure 2). The Core language is as powerful as the Relation language and may be used as a reference for the semantics of relations, which are mapped to Core. The complete diagram may be found at (QVT, 2008, pp.15). Figure 2 shows a simplified metamodel including

A transformation defines how one set of models can be transformed into another. It is composed by a set of rules that specify its execution behavior. The following constraints (*extendingRule* and *transitiveRule*) may be attached to Figure 2 specifying that the rules of the extended transformation are included in the extending transformation and the extension is

The OCL specification, *extendingRule* and *transformationRule* can be translated into the

*Translate*NEREUS(exp1)*Translate*NEREUS(infix-op) *Translate*NEREUS(exp2) *Translate*NEREUS(infix-oper) (*Translate*NEREUS(exp1),*Translate*NEREUS(exp2))

**R5** e.op e: expression

**R6** exp1 infix-op exp2

transformation and rules classes.

Fig. 2. A simplified metamodel

**extendingRule** = Transformation.allInstances ->

**transitiveRule** = Transformation.allInstances ->

and (t1.extends.rule -> includes (t2.rule) and

shaded axioms of the following specification:

**INHERITS** EMOF::MetaClass, EMOF::Package

forAll (t |t.extends.size = 1 implies t.extends.rule -> include (t.rule))

forAll (t1, t2, t3 | t1.extends.size = 1 and t2.extends.size = 1 and t3.extends.size = 1

t2.extends.rule -> includes (t3.rules)) implies t1.extends.rule -> includes (t3.rule)

transitive:

**PACKAGE** QVTBase **CLASS** Transformation **IMPORTS** EMOF::Tag

op(*Translate*NEREUS(e))

**R7** T-> operationName (v :Type | bool-expr-with-v) OperationName ::= forAll│exists│select│reject

> T ::= Collection|Set|OrderedSet|Bag operationName (v) (*TranslateNEREUS* (T), [*TranslateNEREUS* (bool-expr-with-v)])

NEREUS is an intermediate notation open to many other formal languages such as algebraic, logic or functional. We define its semantics by giving a precise formal meaning to each of the constructs of the NEREUS language in terms of the CASL language (Bidoit & Mosses, 2004).
