Example: Modify a Tree model with EOL

var i := 0;
for (leaf in Tree.all.select(t|t.children.isEmpty())) {
  var child : new Tree;
  i := i+1;
  child.label := 'Added' + i;
  leaf.children.add(child);
}

Model.store(Model.modelFile + 'copy.model');
@namespace(uri="Tree", prefix="Tree")
package Tree;

class Tree {
   val Tree[*]#parent children;
   ref Tree#children parent;
   attr String label;
}

Clone Epsilon's Git repository:

  • navigate to trunk/examples
  • import the org.eclipse.epsilon.examples.metamodels project
  • import the org.eclipse.epsilon.examples.modelmodification project

Once you have checked out/imported the code, to run the example you need to go through the following steps:

  1. register all .ecore metamodels in the org.eclipse.epsilon.examples.metamodels project (select all of them and then right click and select Register EPackages)
  2. register any .ecore metamodels in the org.eclipse.epsilon.examples.modelmodification project
  3. right click the .launch file in the org.eclipse.epsilon.examples.modelmodification project
  4. select Run as... and click the first item in the menu that pops up

What's this?

In this example we use EOL to programmatically modify a model that conforms to a Tree metamodel and store the modified version as a new model.

What are .emf files?

.emf files are Ecore metamodels expressed using the Emfatic textual syntax.

More examples...

Epsilon Object Language
Epsilon Transformation Language
Epsilon Generation Language
Epsilon Validation Language
Epsilon Merging Language
Epsilon Flock
Combining the Epsilon Languages
EuGENia
EUnit

Even more examples...

More examples are available in the examples folder of the Git repository.