O'Reilly logo

Implementing Domain-Specific Languages with Xtext and Xtend by Lorenzo Bettini

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Type checking

Most of the constraint checks for an object-oriented language such as SmallJava will deal with type checking ; that is, checking that expressions and statements are well-typed.

We have already seen how to perform a simple form of type checking in the Expressions DSL (Chapter 8, An Expression Language). In this chapter, we will see an advanced type checking mechanism which includes Subtyping or type conformance: an object of class C can be used in a context where an object of a superclass of C is expected.

We will follow the same strategy illustrated in Chapter 8, An Expression Language: we will separate the type computation from the actual type checking. We will be able to generate the error on the sub-expression or statement that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required