Monday, December 26, 2011

Xtext 2.1: using Xbase variables

See the original post here:

Xtext 2.1: using Xbase variables

In this post, I’d like to continue to inspect how to use only a small part of Xbase and still have the control on the generation part: in particular (for other projects) I would like to retain the control on the generation for my model, while relying on the Xbase generation for the Xbase parts. Thus, in this post I’ll describe:

  • how to integrate Xbase variables (XVariableDeclaration) and expressions (XExpression) in your DSL
  • how to extend Xbase scoping for making the variables visible in the expressions
  • write a generator for your DSL and reuse the XbaseCompiler for the code of XVariableDeclaration and XExpressions