Create a language / Define syntaxes


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.

1. xDSML project (TODO rename GEMOC Project)


1.1. Purpose

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;

1.2. Creating the xDSML Project

In the GEMOC Studio, go to: File > New > Project…​ > New GEMOC Language Project. This will create a new xDSML Project in your workspace.

1.3. Editing the xDSML Project

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 IconeGemocModel 16).

1.4. xDSML perspective

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 Java xDSML Project
  • GEMOC Concurrent xDSML Project
New xDSML project

1.5. GEMOC Language menu

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
Project menu

1.6. Melange menu

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.
Project menu

1.7. Melange editor

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.

1.7.1. Syntax

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:

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>"
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*' will import all classes under this namespace.
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>"
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.


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

1.7.2. Content assist

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
Language content assist
  • After syntax

Display the list of available .ecore in your workspace and update syntax with the path to the selection.

Syntax content assist
  • After with

Display the list of accessible Java classes from your project dependencies. K3 Aspects are displayed first.

With content assist
  • After ecl

Display the list of available .ecl in your workspace and update ecl with the path to the selection.

Ecl content assist

1.7.3. Outline

The outline view is available when you open a .melange file. It gives an overview of the file content.

Outline view

1.7.4. Plugin.xml

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">

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">


<XDSML_Definition name> have to be equal to <language id>

2. Define a domain model project


2.1. Purpose

The Domain Model Project specifies the concepts of the domain at hand and the structural relations between the concepts.

2.2. Creating the Domain Model Project

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.

2.3. Editing the Domain Model Project

If you wish to modify your Domain Model, do not forget to reload the associated genmodel and regenerate the EMF model code (and edit/editor code if you use them).

3. Define a concrete syntax


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.

3.1. Defining a Concrete Syntax with Xtext

See the Xtext website.

3.2. Defining a Concrete Syntax with Sirius

If you want to create a graphical concrete syntax you can use Sirius. The Sirius documentation provides information for Sirius Specifier Manual.

3.3. Defining a Concrete Syntax with EMF

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 the icons folder.
  • change the displayed labels by providing a custom implementation of the getText methos in the * 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.

Same editor without customization

Same editor without customization

Table 1. Example of customization of icons on Timed Finite State Machine tree editor.


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.


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 ???, ???, ??? and ???).


More complex images can be obtained by implementing the getImage method in the * 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.