Introduction to Xbase
As we have seen throughout the examples of this book, it is straightforward to implement a DSL with Xtext. This is particularly true when you only need to care about structural aspects; in the Entities DSL of Chapter 2, Creating Your First Xtext Language, we only defined the structure of entities. Things become more complicated when it comes to implementing expressions in a DSL; as we have seen in Chapter 8, An Expression Language, we need to define many rules in the grammar using left factoring to avoid left recursion, even when we only deal with a limited number of expressions. Besides the grammar, the validation part also becomes more complex due to type checking. When we mix structures and expressions, such as in the SmallJava DSL, the complexity increases again; in addition to advanced type checking (Chapter 9, Type Checking), we also need to take care of scoping (Chapter 10, Scoping), that is implied by relations such as inheritance. An inheritance relation...