-
Book Overview & Buying
-
Table Of Contents
Implementing Domain-Specific Languages with Xtext and Xtend
By :
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 is the source of the problem.
The type provider for SmallJava expressions we are about to construct will compute the type of any SJExpression. The concept of type will be represented by SJClass since SmallJava does not support...