Headline

Text to Model transformation with Technology:Gra2Mol

Motivation

A Text to Model transformation from a grammar into a model with Gra2MoL is exercised in this implementation. Technology:ANTLR is used to create a lexer and a parser based on a grammar. Then, the Technology:Gra2Mol specific rules are used to convert the parsing results into a model that conforms to a given Language:Ecore metamodel.

Illustration

The grammar used in the example is a normal Technology:ANTLR grammar. For example, the line for parsing companies looks like

Invalid Language supplied

The results of the parsing process are then converted into a model by using rules like

Invalid Language supplied
The rule takes the result "c" from the Technology:ANTLR rule and converts it into an element of type "Company" in the resulting model. To do so, it queries all departments in "c". It then maps the String from the Technology:ANTLR rule on the name property of the Company element. The departments "dElem" are mapped on the property "deps" of the Company element.

Architecture

  • The "Company.ecore" metamodel models companies (see "grammars" folder)
  • transformation rules are defined in "transformation.g2m" (see "src" folder)
  • The grammar used is called "Company.g" (see "grammars" folder)
  • example1.101 in the directory "src" is the input file for the transformation

Usage

To this end, the Eclipse Modeling Project or a standard Eclipse with the MDE Plugin is needed.

Steps:

  • The project should be imported into Eclipse ("File" -> "Import")
  • The project provides an Ant file called build.xml. This file can be used to apply the transformation.
  • Right click on the build.xml and select "Run As" -> "1 Ant build". This may fail the first time, but it should succeed the second time.
Comments:
  • In order to see the output, it may be needed to refresh the Package Explorer View in Eclipse. To do that, right click on the project and choose "Refresh".


There are no revisions for this page.

User contributions

    This user never has never made submissions.

    User edits

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.