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 ...
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.