wiki:WikiStart
Last modified 4 years ago Last modified on 01/28/13 09:53:02
This is NOT the official page of Gra2MoL.

Visit http://code.google.com/a/eclipselabs.org/p/gra2mol

Welcome to Gra2MoL

Gra2Mol (Grammar to Model Language) is a domain specific transformation language to define the relationships between grammar elements and metamodel elements. It is a rule based language like model transformation languages as RubyTL or ATL. In Gra2MoL you define the source element (grammar), the target element (metamodel) and some metamodel initialization sentences. The main difference with a model transformation language is that Gra2MoL is oriented to extract models from source programs. Moreover, Gra2MoL defines a powerful language for traversing the syntax tress and for extracting information from the source code.

Description

A model-driven modernization process requires models to be extracted from legacy software and most software modernization scenarios involve dealing with source code written in some programming language. Thus, a bridge from grammarware to modelware technical spaces must be built to extract models from source code. Gra2MoL allows building a bridge between these technical spaces and intends to solve the current problems for extracting models from source code files in model driven development.

Gra2MoL has been specifically designed to address the problem of extracting models from source code. Gra2MoL is a rule-based transformation language like existing model-to-model transformation languages such as ATL or RubyTL, but with the fundamental difference that the source element of a rule is a grammar element instead of a source metamodel element. In this way, the language natively deals with grammars as source artifacts. Another important difference is that the language provides domain-specific features to address specific issues in grammar-to-model transformations. For instance, Gra2MoL provides a query language to ease the traversal of the syntax tree.

The execution process of Gra2MoL is showed in this Figure:

The parameters of a Gra2MoL transformation are: (1) source grammar, (2) target metamodel y (3) Gra2MoL transformation definition. The transformacion process of Gra2MoL begins with the CST extractor. This tool is generated from the grammar of the source code and it builds a sintax tree from the set of source files. Gra2MoL engine is parametrized with the Gra2MoL transformation definition, the target metamodel, and the syntax tree. The result of the Gra2MoL engine is a model that conforms to the target metamodel.

Features

  • Language specially tailored for extracting models from code conforming to a grammar
  • Powerful query language to traverse syntax trees
  • Extensibility mechanism to add new operators in mapping section
  • Island grammars support
  • Java API
  • CDO support for storing large models
  • Support for mixin and copy rules
  • Extensibility mechanism to add new query operators

Task lisk

These are the most important improvements to be incorporated in Gra2MoL:

  • Generation of the CST extractor on-the-fly. <- I am working on this issue
  • Generate an Eclipse plugin so that Gra2MoL transformations can be incorporated as MoDisco? discoverers
  • Improving the grammar enricher tool to deal with virtual nodes
  • Support for "filter" antlr option
  • Use of complex filters in from part. <- I am working on this issue

Documentation

At this moment, due to Gra2MoL is under development, the main reference of Gra2MoL is its manual where the main features of the language are presented. The manual includes a section which explain the Java model extraction example in detail. We recommend you to read the manual and to download the Java model extraction example to know this new language.

You can download the manual of Gra2MoL here

Source Code

Gra2MoL is released under the Eclipse Public Licence (EPL). The source code can be downloaded from here. You can also browse the source code by using the Browse Source menu.

Skeleton project

We have built a very simple project which contains the necessary for using Gra2MoL. It can be downloaded here.

The zip package has the following structure:

  • files/src/test.g2m is the gra2mol transformation definition. Three rules have been defined as example.
  • files/src/LanguageGrammar.g3. The first tentative grammar for a simple language.
  • files/metamodels/simpleLanguage.ecore. A first metamodel to represent script files.
  • files/metamodels/Gra2MoL.ecore. Abstract syntax of Gra2MoL.
  • files/metamodels/CST.ecore. Abstract Syntax of the CSTs
  • build.xml. It is an ANT file which specifies the gra2mol transformation process.

The execution of the "build" target of build.xml executes the transformation process. The result of such execution generates the following files:

  • debug.txt. A debug file which contains the traces of rule calls and operations performed during the transformation.
  • gra2molModel.ecore. The model file which represents the gra2mol transformation definition (it conforms to the gra2mol.ecore metamodel file located in files/metamodels).
  • CSTModel.ecore. The parse syntax tree extracted from the source files (it conforms to the CST.ecore metamodel file located in files/metamodels).
  • resultModel.ecore. The extracted model from the source files (it conforms to the simpleLanguage.ecore metamodel file).

Examples

The following projects contains some examples of the main features incorporated by the language. Please, be aware that Gra2MoL is under development and there may be errors. Please, contact me at jlcanovas[at]um.es.

  • Simple example. Basic Gra2MoL transformation, similar to skeleton project. It can be downloaded from here.
  • Skip rules. This example illutrates the use of skip rules. It can be downloaded from here.
  • Mixin rules. This example illutrates the use of mixin rules. It can be downloaded from here.
  • Extension mechanism. This example uses the extension mechanism of Gra2MoL. It can be downloaded from here.
  • Island grammar. This example illutrates the use of island grammars in Gra2MoL. It can be downloaded from here.
  • CDO example. This example uses the CDO repository for storing the CST. Some extra configuration is needed to execute this example. If you have any problem/question, please contact me. It can be downloaded from here.

Case studies

These are some case studies developed with Gra2MoL. Please, be aware that Gra2MoL is under development and there may be errors. Please, contact me at jlcanovas[at]um.es.

Extracting ASTM Models from Delphi code (Example used in ECMDA09 paper)

This example extracts a ASTM model from Delphi souce code.

This example is avaiable in our SVN server here. The example project will be uploaded in a couple of days.

Using Gra2MoL for defining the textual concrete syntax of a DSL

In this example we have used Gra2MoL to specify the textual concrete syntax to the SMM abstract syntax metamodel.

The example's website is here

Using Gra2MoL in a ADM-based modernization process

This example is composed of two parts. The former extracts KDM models from Oracle Forms applications and the latter measures some metrics from these models.

The example's website is here

Extracting KDM Models from PL/SQL code of Forms Applications (Examples used in IEEE paper)

This example extracts a KDM from PL/SQL source code of Oracle Forms applications.

The example's website is here.

Extracting PL/SQL Models from PL/SQL code of Forms Applications (Example used in ECMDA09 paper)

This example extracts a PL/SQL model from PL/SQL souce code of Oracle Forms applications.

This example can be downloaded here.

Extracting Java Model

This example extracts a Java model from a set of Java source files. It works with a simplfified Java metamodel and the Gra2MoL transformation definition considers some special structures of the Java grammar to extract model elements. It is a good example to know the language at first time.

This example is avaiable in our SVN server here. You can download the example project here.

Extracting ANTLR Model

This example was developed for the Gra2MoL editor plugin on Eclipse, exactly, the autocompletion feature. This example extracts a model from a ANTLR grammar definition so it works with the grammar of ANTLR grammar (metagrammar). The metamodel only models the rules defined on the grammar and their derivations. This way, we only has to navigate over the derivations of a rule to execute the autocompletion.

This example is avaiable in our SVN server here. You can download the example project here.

Extracting hierarchy Java Model

Gra2MoL is destined to extract models from source code files of a system. They are not some files, but a number of files. This example extracts the hierarchy of a set of classes. The metamodel is very simple and it only models the name of the class and its superclasses (by inheritance and interface).

The main purpose of this example is having a first perfomance analysis of Gra2MoL. It was executed with the SWT source code and the transformation took 18 seconds. It is important to note that the CST extractor was optimized to generate only the needed CST and to reduce the memory charge.

This example is avaiable in our SVN server here. You can download the example project here.

Extracting KDM models from Java source code

This example extracts a KDM model from a number of Java files. This example was one of the very first example we developed with Gra2MoL and allowed us to test some featurs of the Gra2MoL language in order to assess the management of the complexity of the KDM metamodel.

This example is avaiable in our SVN server here.

Extracting Ecore metamodel from ASTM OMG Specification

In this example, we worked with the textual specification of the ASTM metamodel for extracting a Ecore metamodel. The textual representacion is based on a grammar-based syntax so Gra2MoL is used to perform the extraction step. We have defined a grammar (only 6 rules) for parsing the syntax and the Gra2MoL transformation definition. The "source code" of this example has been extract by copying/pasting from the OMG especification. Once we have the syntax in a file, Gra2MoL builds automatically the ecore metamodel.

This example is avaiable in our SVN server here.

Extracting Wiki models

This example was carried out in collaboration with the Onekin research group. Gra2MoL was used to extract wiki data models from the sql source file of a database.

Please, contact us if you are interested in this example.

Download

This section contains the core files of Gra2MoL.

If you find any bug, please send us a ticket. On the other hand, if you have any comment or suggestion, send an e-mail to jlcanovas[at]um.es.

Attachments