Standalone command-line compiler

We already know that the Xtext project wizard created the projects for our DSL separating the features related to the user interface in separate projects, the .ide project and the .ui project. The runtime project does not depend on the Eclipse user interface. Thus, we can create a command-line application consisting of a simple class with a main method. Xtext can generate such a class for you. We need to add the generator specification in the StandardLanguage block in the MWE2 workflow file:

language = StandardLanguage {
    name = "org.example.entities.Entities"
    fileExtensions = "entities"
    ...
    generator = {
        generateXtendMain = true
    }
}

If you now run the workflow, you will find an Xtend Main class in the src folder ...

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.