The Entities DSL with Xbase

We will now implement a modified version of the Entities DSL that we implemented in Chapter 2, Creating Your First Xtext Language. This will allow us to implement a more complex DSL where, inside entities, we can also write operations apart from attributes. This is inspired by the Xtext Domain-Model example.

Creating the project

We create a new Xtext project with the following settings:

  • Project name: org.example.xbase.entities
  • Name: org.example.xbase.entities.Entities
  • Extensions: xentities

Defining attributes

We define the rules for attributes using some rules inherited from the Xbase grammar:

grammar org.example.xbase.entities.Entities
  with org.eclipse.xtext.xbase.Xbase

generate entities "http://www.example.org/xbase/entities/Entities" ...

Get Implementing Domain-Specific Languages with Xtext and Xtend - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.