Extending Xbase

In this section, we will extend the Xbase Expressions DSL presented in the previous chapter with a new Xbase expression. We will add the new XExpression eval to the DSL, which takes as an argument any Xbase expression.

In order to present the aspects of Xbase that need to be customized when adding new expressions, we want our new EvalExpression to have the following semantics:

  • It can be used both as a statement and as an expression inside any other expression
  • It has a String type and the argument expression must not have type void
  • When it is used as a statement, it will be compiled into a Java System.out.println statement with the evaluation of the argument expression
  • When it is used inside another expression, it will be compiled into ...

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.