In my last project I worked on a external textual DSL for defining products in telecommunications.
At this time, the products and their parts (deep tree of “features” then composed to products) are all maintained in Excel. This is great for the “inventor” and power-user, but it’s very hard to enforce structural correctness and business rules. Also working in a team and versioning is almost impossible.
A textual DSL was chosen over a custom application, because gives much more “power” to the user, because he is editing raw data in a very feasible way.
Sad that Microsoft dropped their investment in DSLs. But, so what. We’ve got Xtext. There is only one drawback. It’s Java + Eclipse, not C# + Visual Studio.
First I had plans (and started) to write about a particular scoping problem I had to solve in this DSL, but then I moved to a different project. So instead I’ll just post the introductory part where I listed the features of Xtext, just in case this is new to you 🙂
- Xtext is a Language Workbench for external textual DSLs.
- Xtext builds on Java+Eclipse.
- Xtext is a rich grammar language.
- Xtext builds on EMF (Eclipse Modeling Framework, a rich meta-meta model).
- Xtext derives a EMF-based meta-model from your grammar definition (Semantic Model).
- Xtext generates a Antlr-Parser from your grammar definition and automatically converts the AST into your semantic model.
- Xtext generates an Eclipse-based text editor including syntax highlighting, cross-reference resolving, validation, formatting, outline-view, code-completion, rename refactoring, go to definition navigation + much more.
- Xtext offers a rich API for validating you semantic model, but shows warnings and errors in the editor (squiggles).
- Xtext offers a rich API for configuring your DSLs formatting (spaces, line breaks, eg).
- Xtext lets you define custom scoping – including generic support for packages/namespaces + imports.
- Xtext comes with a base-language (Xbase) for expressions (including compilation of expressions to Java).
- Xtext comes with a template language (Xtend) for generating artifacts from your semantic model (model-to-model or model-to-text transformations).
- Xtext on Eclipse.ort
- About Xtext – Xtext (on xtext.itemis.org)
- Sven Efftinge’s Blog (inventor of Xtext)
- Sven Efftinge’s Blog: 5 simple steps to Fowler’s DSL with Xtext 2.0 Screencasts on Xtext
- xtext-utils – Unit testing Framework for unit-testing Xtext-based DSLs
- Language Workbench Comparison 2011 – Xtext A tutorial from Code Generation 2011’s Language Workbench Competition