Example: Create an OO model with EOL

var m : new Model;

m.name = "m";

// Create five packages
for (i in 1.to(5)){
  var package : Package = new Package;
  package.name = "p" + i;
  package.package = m;

  // Create three classes in each package
  for (j in 1.to(3)) {
    var class : Class = new Class;
    class.name = "c" + i + "" + j;
    class.isAbstract = false;
    class.package = package;

// Assign random supertypes to the classes created
for (c in Class.allInstances) {
  c.extends = Class.allInstances.random();
@namespace(uri="OO", prefix="OO")
package OO;

class Model extends Package {

abstract class PackageableElement extends NamedElement {
  ref Package#contents ~package;

abstract class AnnotatedElement {
  val Annotation[*] annotations;

class Annotation {
  attr String key;
  attr String value;

abstract class NamedElement extends AnnotatedElement {
  attr String name;

class Package extends PackageableElement {
  val PackageableElement[*]#~package contents;

abstract class ~Classifier extends PackageableElement {

class ExternalClass extends ~Class {

class ~Class extends ~Classifier {
  ref ~Class#extendedBy ~extends;
  ref ~Class[*]#~extends extendedBy;
  val Feature[*]#owner features;
  attr Boolean isAbstract;

class Datatype extends ~Classifier {

abstract class Feature extends NamedElement {
  ref ~Class#features owner;
  ref ~Classifier type;
  attr VisibilityEnum visibility;

abstract class StructuralFeature extends Feature {
  attr Boolean isMany;

class Operation extends Feature {
  val Parameter[*]#owner parameters;

class Parameter extends NamedElement {
  ref ~Classifier type;
  ref Operation#parameters owner;

class Reference extends StructuralFeature {

class Attribute extends StructuralFeature {

enum VisibilityEnum {
  public = 1;
  private = 2;

Clone Epsilon's Git repository and then:

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.buildooinstance project
  3. right click the .launch file in the org.eclipse.epsilon.examples.buildooinstance 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 construct a model that conforms to an object-oriented metamodel.

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
Epsilon Model Generation Language
Epsilon Pattern Language
Combining the Epsilon Languages

Even more examples...

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