Code Downloads & Errata

If you have purchased a Packt book and/or video, you can use this page to
  • Download the code or support files
  • View errata and amendments
  • Send us feedback

You selected

Implementing Domain-Specific Languages with Xtext and Xtend

Lorenzo Bettini

Published 2013-08-21

Downloads

Please register your e-mail address to download files. We will e-mail you with a direct link to the code download. If you have bought this book, you can login to your account and download the code files from your account page.

Before downloading the files please tell us where you purchased this book.

Would you like to receive occasional emails about free content, recommended titles and site wide deals? you can unsubscribe at any time.

Errata

- 2 submitted: last submission 17 Jun 2016

 Errata type: Typo | Page number: 20

The line: The wizard will create three projects and will open the file MyDsl.xtext ,which is the grammar definition of the new DSL we are about to implement. Should be: The wizard will create three projects and will open the file MyDsl.xtext, which is the grammar definition of the new DSL we are about to implement.

Errata type: Typo | Page number: 28

The line: In this rule we have three keywords, namely 'entity', 'extends', '{', and '}'. Should be: In this rule we have four keywords, namely 'entity', 'extends', '{', and '}'.

Errata type: Technical | Page number: 41

The feature name for the array size in the screenshot should be "dimension" instead of "length".

Errata type: Technical | Page number: 42

The UML diagram shows the AttributeType class having an attribute named "dimension". The attribute should be named "length".

Errata type: Typo | Page number: 71

With validation you can implement additional constraint checks of a DSL which cannot be done at parsing time. Should be:  With validations you can implement additional constraint checks of a DSL which cannot be done at parsing time.

Errata type: Code | Page number: 74

// In order to solve the compiler errors add the following import statements // in front of the class defintion of the class EntitiesValidator: import org.eclipse.xtext.validation.Check import org.example.entities.entities.Entity import org.example.entities.entities.EntitiesPackage

Errata type: Code | Page number: 76

// To solve the compiler error add the following import statement: import org.example.entities.entities.Attribute

Errata type: Code | Page number: 79

// To solve the compiler errors add the following import statements: import org.eclipse.xtext.ui.editor.quickfix.Fix import org.eclipse.xtext.ui.editor.quickfix.IssueResolutionAcceptor import org.eclipse.xtext.validation.Issue import org.example.entities.validation.EntitiesValidator

Errata type: Code | Page number: 81

// To solve the compiler error add the following import statement: import org.example.entities.entities.Attribute

Errata type: Code | Page number: 82

// To solve the compiler error add the following import statement: import org.example.entities.entities.Entity

Errata type: Technical | Page number: 105

To get a representation of the AttributeType element, we use an injected extension, TypeRepresentation (it is similar to the way we generate Java code for attribute types in the generator of Chapter 5, Code Generation), in particular its method representation. Should be: To get a representation of the AttributeType element, we use an injected extension, TypeRepresentation (it is similar to the way we generate Java code for attributetypes in the generator of Chapter 5, Code Generation), in particular its method representation (you will find the code for this class "TypeRepresentation" in  the accompanying source code in the folder "org.example.entities.ui/src/org/example/entities/ui/labeling").

Errata type: Technical | Page number: 106

To do this, we create a directory where we place the image files of the icons we want to use. In order to benefit from Xtext's default handling of images, we call the directory icons, and we place two gif images there, Entity.gif and Attribute.gif (for entities and attributes respectively). Should be: To do this, we create a directory in the "org.example.entities.ui" project in Eclipse where we place the image files of the icons we want to use. In order to benefit from Xtext's default handling of images, we call the directory icons, and we place two gif images there, Entity.gif and Attribute.gif (for entities and attributes respectively). You will find the icon files in the accompanying source code in the folder "org.example.entities.ui/icons".

Errata type: Typo | Page number: 106

We then define two image methods in EntitesLabelProvider where we only need to return the name of the image files (Xtext will do the rest for us): Should be: We then define two image methods in EntitiesLabelProvider where we only need to return the name of the image files (Xtext will do the rest for us):

Errata type: Typo | Page number: 180

@Inject extesion ExpressionsTypeProvider Should be: @Inject extension ExpressionsTypeProvider

Errata type: Code | Page number: 193

Add the following rule after the code of the rule "SJVariableDeclaration:" on page 194: SJParameter: type=[SJClass] name=ID;

Errata type: Typo | Page number: 200

Note that we have a single rule for referring both to a parameter (SJParamenter) Should be: Note that we have a single rule for referring both to a parameter (SJParameter)

Errata type: Code | Page number: 201

Add the following rule after the code of the rule "SJVariableDeclaration:" SJParameter: type=[SJClass] name=ID;

Errata type: Code | Page number: 216

class R { public V v; } class P extends R { public R m() { return null; } } class V extends R { public N n; } Should be: class R { V v; } class P extends R { R m() { return null; } } class V extends R { N n; } Remove the keyword "public" to avoid a parsing error.

Errata type: Typo | Page number: 241

In Chapter 8, An Expression Language, we solved the problem of forward references by implementinga check in the validator Should be: In Chapter 8, An Expression Language, we solved the problem of forward references by implementing a check in the validator

Errata type: Typo | Page number: 254

In general, the validator approach allows you to give better feedback to the user, but it requires you to customize the content assist as shown in the following this section. Should be: In general, the validator approach allows you to give better feedback to the user, but it requires you to customize the content assist as shown in the following section.

Errata type: Typo | Page number: 296

Furthermore, by navigating to New | Example... | Xtext Examples | Xtext Domain-Model Example, you can import into your workspace the Domain-Model example that ships with Xtext; Should be: Furthermore, by navigating to File | New | Example... | Xtext Examples | Xtext Domain-Model Example, you can import into your workspace the Domain-Model example that ships with Xtext;

Errata type: Code | Page number: 307

@Inject extension IqualifiedNameProvider Should be: @Inject extension IQualifiedNameProvider

Errata type: Typo | Page number: 308

First of all, we specify that the the superclass of the mapped class will be the entity's superType if one is given. Should be: First of all, we specify that the superclass of the mapped class will be the entity's superType if one is given.

Errata type: Typo | Page number: 426

This: You can think of a scope as a symbol table (or a map) where the keys are stringsand the values are instances of IEObjectDescription.

Should be: You can think of a scope as a symbol table (or a map) where the keys are strings and the values are instances of IEObjectDescription.