Let’s focus on the language syntax. Ie. how the models will appears.
This is done by defining an abstract syntax and one or several concrete syntaxes.
Even if some tool may hide either the concrete syntax or abstract syntax details, in GEMOC we consider the general case where syntaxes are distinct entities.
The GEMOC project will be used to drive the creation and assemble the language artefacts/projects.
The xDSML Project is the core project of languages created using the GEMOC Studio. It has one main purposes:
- Referencing the different projects implementing the various parts constituting an xDSML;
In the GEMOC Studio, go to: File > New > Project… > New GEMOC Language Project. This will create a new xDSML Project in your workspace.
The .melange file is the main element of the xDSML Project.
From the information contained in this file, the project generates additional code that is used by the Execution Engine during the execution of models conforming to the xDSML (see Modeling workbench User Guide ).
The GEMOC Language Workbench provides an xDSML perspective. It is available in the menu Window > Open Perspective > Other.
This perspective eases the creation of a new xDSML project. In the menu File > New, you have direct access to
- GEMOC Sequential xDSML Project
- GEMOC Concurrent xDSML Project
On a right click on an xDSML project you have access to this menu containing theses commands:
- Generate Multidimentional Trace Addon project for language
- Create Domain Model Project for language
- Create Sirius Editor for language
- Create XText Editor Project for language
- Create Animator Project for language
On a right click on a .melange file you have access to this menu containing theses commands:
- Generate All
- Generate Language Runtime, Adapters, Interfaces and Plugin.xml
- Clean All
- Delete generated artifacts
- Generate Language Runtime
- Generate new Eclipse projects for Languages that inherit or with multiple syntax. A new project contains the .ecore merging the multiple Domain models of the Language. It also contains copies of inherited Aspects but applying on the new .ecore file (which has classes in another namespace).
- Generate Adapters
- Generates adaptation classes to see a model as an instance of a compatible Language. (experimental)
- Generate Interfaces
- Generate the ModelTypes as .ecore file. It represents the merge of Domain models and semantics of the Language.
- Generate Plugin.xml
- Generate extension points in the plugin.xml file. They are used by the Modelling Workbench to get informations about defined Languages.
Melange is a Language designing tool. Through a .melange file you can define a Language as an assembly of abstract syntaxes with operational semantics and also as a composition of Languages. To do so, Melange is provided with a textual Languages editor.
A .melange file start with
package your.language.namespace
and contains a list of Language definitions starting with the keyword language.
a basic Language.
package org.eclipse.gemoc.sample.tfsm.xdsml language Tfsm { /* * Declare abstract syntax */ syntax "platform:/resource/org.eclipse.gemoc.sample.tfsm.plaink3.model/model/tfsm.ecore" /* * Set name of the ModelType (ie: the type of this language) */ exactType TfsmMT }
A Language definition accept theses keywords:
- syntax
- Link your language to your Domain Model. The path to your model follows the Eclipse platform URLs convention: "platform:/resource/<name of your EMF project>/<path to the .ecore file>"
- with
- Link the DSA project to your language. with is followed by the name of a Java class. Melange support wildcard character for this operator. Typing in your language 'with some.package.name.*' will import all classes under this namespace.
- ecl
- Link your language to your ECL project. The intended format for the path to your .ecl file is: "<name of your ECL project>/<path to the .ecl file>"
- inherits
- The keyword inherits allows you to define a Language as an extension of another. It means the abstract syntax and the semantics of the inherited Language are copied in your Language.
Note
Your xDSML project need a dependency to your DSA project. Check the Require-Bundle section in the MANIFEST.MF if the Melange editor can’t see the used Aspect.
a Language with semantic.
package org.eclipse.gemoc.sample.tfsm.xdsml language Tfsm { /* * Declare abstract syntax */ syntax "platform:/resource/org.eclipse.gemoc.sample.tfsm.plaink3.model/model/tfsm.ecore" /* * Declare DSA */ with org.eclipse.gemoc.sample.tfsm.plaink3.dsa.TFSMAspect with org.eclipse.gemoc.sample.tfsm.plaink3.dsa.TFSMVisitorAspect with org.eclipse.gemoc.sample.tfsm.plaink3.dsa.FSMEventAspect with org.eclipse.gemoc.sample.tfsm.plaink3.dsa.FSMClockAspect with org.eclipse.gemoc.sample.tfsm.plaink3.dsa.FSMClockVisitorAspect with org.eclipse.gemoc.sample.tfsm.plaink3.dsa.StateAspect with org.eclipse.gemoc.sample.tfsm.plaink3.dsa.StateVisitorAspect with org.eclipse.gemoc.sample.tfsm.plaink3.dsa.TransitionAspect with org.eclipse.gemoc.sample.tfsm.plaink3.dsa.TransitionVisitorAspect with org.eclipse.gemoc.sample.tfsm.plaink3.dsa.GuardVisitorAspect with org.eclipse.gemoc.sample.tfsm.plaink3.dsa.TemporalGuardVisitorAspect with org.eclipse.gemoc.sample.tfsm.plaink3.dsa.EventGuardVisitorAspect with org.eclipse.gemoc.sample.tfsm.plaink3.dsa.TimedSystemAspect with org.eclipse.gemoc.sample.tfsm.plaink3.dsa.TimedSystemVisitorAspect /* * Set name of the ModelType (ie: the type of this language) */ exactType TfsmMT }
You can press Ctrl+Space to have a content assist in the Melange editor.
-
In language { … }
- — Create a Domain Model Project —
- Create a new EMF project and upadte the syntax of your language.
- — Create a DSA Project —
- Create an new K3 project. Based on the syntax of your language, it automatically create Aspects for each class of your Domain. Theses Aspects are also added in your Language.
- — Import existing DSA project —
- Automatically imports all Aspects from a K3 project
- After syntax
Display the list of available .ecore in your workspace and update syntax with the path to the selection.
- After with
Display the list of accessible Java classes from your project dependencies. K3 Aspects are displayed first.
- After ecl
Display the list of available .ecl in your workspace and update ecl with the path to the selection.
The outline view is available when you open a .melange file. It gives an overview of the file content.
The plugin.xml file is the link between the Languages and the Modelling Workbench. It is mainly composed of two extension points:
- GEMOC extension point: "org.eclipse.gemoc.gemoc_language_workbench.sequential.xdsml"
- Melange extension point: "fr.inria.diverse.melange.language"
Gemoc extension points declare Languages availables in the Modelling Workbench. It also give the class able to load models for each Language.
GEMOC language.
<extension point="org.eclipse.gemoc.gemoc_language_workbench.sequential.xdsml"> <XDSML_Definition modelLoader_class="org.eclipse.gemoc.executionframework.extensions.sirius.modelloader.DefaultModelLoader" name="org.eclipse.gemoc.sample.tfsm.xdsml.Tfsm" xdsmlFilePath="/org.eclipse.gemoc.sample.tfsm.plaink3.xdsml/bin/org/eclipse/gemoc/sample/tfsm/xdsml/Main.melange" >
Melange extension points declare semantic of Languages as list of Domain model classes associated to their K3 Aspects. It also gives the available entry points for the execution, which are the Aspects methods tagged with @Main.
Melange Language.
<extension point="fr.inria.diverse.melange.language"> <language aspects="FSMClock:org.eclipse.gemoc.sample.tfsm.plaink3.dsa.FSMClockAspect,org.eclipse.gemoc.sample.tfsm.plaink3.dsa.FSMClockVisitorAspect;..." entryPoints="org.eclipse.gemoc.sample.tfsm.plaink3.dsa.TimedSystemAspect.main(org.eclipse.gemoc.sample.tfsm_plaink3.TimedSystem)" exactType="org.eclipse.gemoc.sample.tfsm.xdsml.TfsmMT" id="org.eclipse.gemoc.sample.tfsm.xdsml.Tfsm" uri="http://tfsmmt/" >
Note
<XDSML_Definition name> have to be equal to <language id>
The Domain Model Project specifies the concepts of the domain at hand and the structural relations between the concepts.
The GEMOC Studio relies on the Eclipse Modeling Framework for its Domain Model Projects. See the EMF website for more information on how to create an EMF project in Eclipse. The Domain Model is materialized as an Ecore metamodel.
When your EMF Project is done, connect your xDSML Project to it by specifying in the .melange file the path to your Ecore metamodel thanks the keyword syntax. See Section 1.7, “Melange editor” for more informations about Melange keywords and the content assist.
An xDSML can support different concrete syntaxes. Most EMF-based editors should work with GEMOC, however the GEMOC Studio provides additional support for some specific editors. Thus, we recommend using: an EMF arborescent editor, an Xtext editor, and/or a Sirius editor.
See the Xtext website.
If you want to create a graphical concrete syntax you can use Sirius. The Sirius documentation provides information for Sirius Specifier Manual.
EMF provides several services, as seen in Section 2, “Define a Domain Model Project” , EMf allows generating many artifacts. In addition to generate the java code for the metamodel and provide a reflective tree editor, EMF allows to generate a customizable Tree Editor.
On the .genmodel right click on the root element then Generate Edit Code
and Generate Editor Code
.
Some very easy customizations can be done in the .edit
project:
- change the icons for each of the metaclasses of yourmetamodel by replacing the
.gif
files in theicons
folder. - change the displayed labels by providing a custom implementation of the getText methos in the
*ItemProvider.java
classes.
Table Table 1, “Example of customization of icons on Timed Finite State Machine tree editor.” illustrates the value of adding dedicated icons for a given domain.
Note
When modifing java code in the generated projects, do not forget to change the comment from generated
to generated NOT
, so the genmodel generator will keep your changes.
Tip
Providing custom icons and labels are not dedicated to the Tree Editor only. When possible, these elements will also be used to improve the Outline, the Debug Stack or the Variable views (see sections Section 3.7, “Debug View”, Section 3.8, “Variable View”, Section 2.6, “Debug View” and Section 2.7, “Variable View”).
Tip
More complex images can be obtained by implementing the getImage
method in the *ItemProvider.java
classes. For example by using overlay or switching the image depending on one of its attribute in order to represent more
precisely the content of model element.
[4] asciidoc source of this page: https://github.com/eclipse/gemoc-studio/tree/master/docs/org.eclipse.gemoc.studio.doc/src/main/asciidoc/userguide/lw_CreateLanguage.asciidoc.
[5] asciidoc source of this page: https://github.com/eclipse/gemoc-studio/tree/master/docs/org.eclipse.gemoc.studio.doc/src/main/asciidoc/userguide/lw_CreateGEMOCProject_headContent.asciidoc.