I have created my ecore model:

enter image description here

I have specified it in my xtext file:

MinRequirementsType returns MinRequirementsType:
    'MinRequirementsType'

Next I want to implement the rule, but when I try

enum minrequire: 0|1 ;

I get a mistake!

How is the correct syntax?

有帮助吗?

解决方案

Your enum declaration is wrong. Try the following:

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model: test+=Test*;

enum OneOrZero: one = '1' | zero = '0';

Test returns Test: value = OneOrZero;

Regards,

Xavier

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top