Showing items from Xtext-Tips

Xtext Tip: How to use fully qualified names in your language

Xtext allows to easily add support for fully qualified names in your language. The full code for this example can be found here.

The basic block language

To illustrate this feature I will use a simple language to represent blocks. Each block has a name and can contain three members:

  • Fields, which are basically a name,
  • Blocks, which are blocks contained in another block
  • Aliases, which allow to give another name to another member

This is an example of our block language:

Continue Reading

Xtext Tip: Use Java instead of Xtend

Xtend is a wonderful language. It is specially practical when traversing ASTs and it is the best option to generate code. However, it is “is no longer the Java 17 of today”, as Christian Dietrich (one of Xtext maintainers) put it in this thread.

Hence, the recommended best practices for Xtend as of today are:

  • Use Xtend as a thin code generation layer.
  • Use Java for the rest of the logic.
  • Migrate Xtend code to Java whenever possible.
  • Set the code generators in the MWE file to generate Java stubs instead of Xtend (newer versions of Xtext do this by default.)

The configurations in the MWE file are the following:

Continue Reading