Xbase interactive programming environment

10 Dec 2010

One of the exciting new features of the upcoming Xtext 2.0 is the integration of the general purpose expression language Xbase. Sven Efftinge gives an excellent introduction to Xbase in his blog post. Having such a language makes it a lot easier to create more complex DSLs which require some form of expression language. For example, creating a DSL for modeling statecharts with states and transitions is already really easy with Xtext. However, extending the language to support defining guards and actions for transitions is still quite complicated, because these require an expression language. Implementing such a language with Xtext is not trivial. But with Xbase this will be a thing of the past, because you can integrate it directly into your DSL. Even better, Xbase also provides an interpreter which you can use for executing your statecharts.

Xtext 2.0 will be released together with Eclipse Indigo in June 2011. However, being curious I wanted to try the current implementation of Xbase. One of the best ways to explore a new language is via an interactive programming environment (often called a REPL for Read-Evaluate-Print-Loop). So far Xtext only provides an interpreter for Xbase, without an actual REPL. So I started to write my own. I wanted to see whether it was possible to create a REPL for Xtext-based languages. Of course, the REPL should support all the goodness that is provided by Xtext, such as syntax highlighting, code completion, and validation. It proved to be simpler than expected. My implementation is based on the Xtext forms integration and the OCL console which is part of the OCL Examples. Here is a short screen cast demonstrating the capabilities of the new REPL (and of course Xbase).

Xbase is currently in active development and does not yet supports all of its planned upcoming features. I think the REPL is a nice way to explore Xbase. Therefore I plan to make it publicly available with one of the next Xtext milestone releases. I am really excited about the possibilities that Xbase provides and have some great ideas for future versions of the REPL. So stay tuned...