Search code examples
grammardslxtextecore

Xtext DSL: boolean rule with 2 different string


Currently I have problem in defining a boolean variable :

I have a class with a boolean variable:

Pet:
   isFeline ?= 'cat' | isFeline ?= 'dog' ;

However this result in Pet returning with 'cat'/'dog' as true. Is there anyway to define DSL: 'cat' as true and 'dog' as false ??


Solution

  • Maybe you can try this:

    Pet:
        {Pet} (isFeline?='cat' | 'dog');
    

    Normally it should do what you want!