Creating an Xtext project from an Ecore model
In this section, we will implement an Xtext DSL starting from an existing Ecore model, which will represent the structure of AST.
Defining the Ecore model
We assume that we already have an EMF Ecore model for representing schools with students and teachers.
This Ecore model has the following structure:
SchoolModel
: This is the root element. The featureschools
is a multi-value containment reference ofSchool
objects.School
: The featurepersons
is a multi-value containment reference ofPerson
objects.Person
: This is an abstract class.Student
is aPerson
: TheregistrationNum
attribute is an integer,teachers
is a multi-value non-containment reference ofTeacher
objects, that is, a student can refer to several teachers.Teacher
is aPerson
.Named
is an abstract class, which is the base class forSchool
andPerson
. It contains the string attributename
.
Note
During this section, we will modify this Ecore model. If you want to implement the example DSL...