Question

I have successfully managed to combine two grammars in xtext using the 'with' keyword, however I am having an issue in the language validation and generation.

When there are two grammars combined, any validation / code generation has to be placed in the original grammar or the one extending it? Say I have grammars A and B, and B sits on top of A. Any validation related to the rules in grammar A must be in A, or they have to be in B? Thanks :)

Was it helpful?

Solution

I'm experiencing the same problem and I found a solution looking at this link.

The trick is to override the method

protected List<EPackage> getEPackages() {
    List<EPackage> result = super.getEPackages();
    result.add(OdlDataPackage.eINSTANCE);
    return result;
}

In order add the package of the super grammar to the list of the parent package.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top