xtexteclipse-emf

XText Grammar rule for Abstract EMF Class


I have an EMF metamodel containing Abstract Class A and Concrete Classes B & C implement A.

In XText I can have a rule such as A: B | C; and refer to A in other rules.

Is there a way not to have to declare the rule for A and have a default rule used for abstract classes (which would be OR(All concrete children)) by Just providing the rules for B and C?


Solution

  • it is not possible to call rules you don't have nor a catch all children

    if you just want to have child rules and add a parent to them without a explicit rule for the parent

    you can do

    B returns A:
         {B} "b" name=ID;