Medea. A DSL for defining SMM textual metrics
Medea is a DSL which allows you to specify SMM metrics in a textual way. Medea definitions are translated to SMM abstract syntax models by using Gra2Mol and then executed by the SMM engine. The following figure describes the execution process for calculating metrics in a KDM model:

Features
- Textual DSL for defining SMM metrics
- SMM execution engine for SMM abstract syntax models
- Ant task to execute the process
Download
The Medea tool can be downloaded from this link.
Gra2MoL use
Gra2MoL has been used in this project for specifying the textual concrete syntax of SMM. The language has allowed us to deal with the SMM abstract syntax metamodel directly. Moreover, the query language integrated into Gra2MoL allowed allowed us to resolver the identifier-based references of the Medea grammar. The following figure describes the Gra2MoL process defined for extracting SMM abstract syntax models from the Medea grammar:
Medea is a DSL which allows you to specify SMM metrics in a textual way. Medea definitions are translated to SMM abstract syntax models by using Gra2Mol and then executed by the SMM engine. The following figure describes the execution process for calculating metrics in a KDM model:

As it is said previously, the defined grammar contains a number of identifier-based references between elements. The following snippet code shows a part of the grammar defined:
smm_model:
'smm_model' ID ‘{’ elements* ‘}’
;
elements :
libraries | scopes | charac |...
;
libraries :
'library' ID ‘{’ measures+ ‘}’
;
measures :
ranking | dimensional
;
dimensional :
'dimensionalMeasure' name=ID ‘{’
'scope' sc=ID
('trait'tr=ID)?
'unit' un=ID
'type' type
‘}’
;
type :
'direct' ‘{’ 'operation' OP }
| 'collective' ‘{’
'accumulator' accumulator
'baseMeasure' bm=ID
‘}’
| ...
;
An example of text conforms to the previous grammar is the following:
smm_model myModel {
characteristic ModuleCount
scope codeModel{
class code::CodeModel
}
scope AbstractCodeElement{
class code::AbstractCodeElement
}
library myLibrary{
dimensionalMeasure ModuleCount{
scope codeModel
trait ModuleCount
unit code::Module
type collective{
accumulator sum
baseMeasure ModuleCountRecognizer
}
}
dimensionalMeasure ModuleCountRecognizer{
scope AbstractCodeElement
trait ModuleCount
unit code::Module
type direct{
operation "oclIsTypeOf(code::Module)"
}
}
}
}
And this is an example of Gra2MoL rule used for extracting SMM model element. This rules is in charge of obtaining DimensionalMeasure? elements and initializing its attributes.

The attributes name, unit and accumulator use the result of the queries measure and accumulator, which extract the information from the node received by the rule in the from part (i.e. fromNode variable). On the other hand, for initializing the attributes scope, trait, baseMeasure and library, the queries locatedScope, locatedCharac, locatedBaseMeasure and locatedLibrary are defined, respectively. The first three queries traverse the syntax tree for locating the desired grammar node, for instance, the locatedScope query looks for the Scope grammar node by using the query //elements/#scopes. However, the query called locatedLibrary is necessary to locate in which library block the measure is located. Thus, this query is in charge of traversing the syntax tree to located the library grammar node which contains the measure.
Attachments
-
smmProcess.png
(72.7 KB) - added by jlcanovas
2 years ago.
medea process
-
gra2molProcessB.png
(31.8 KB) - added by jlcanovas
2 years ago.
medea gra2mol process
-
gra2molRule.png
(134.0 KB) - added by jlcanovas
2 years ago.
gra2mol rule
