Hi,
I don't understand why i get the following ambiguity error for the minimal grammer posted below:
error(202): ../org.xtext.example.mydsl/src-gen/org/xtext/example/mydsl/parser/antlr/internal/InternalMyDsl.g:286:3: the decision cannot distinguish between alternative(s) 1,2 for input such as "RULE_ID EOF EOF"
Minimal Grammar for my problem:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Model:
(elements+=Enumeration)*
;
Enumeration:
{Enumeration}
'Enumeration' name=ID '{'
(encoding=Encoding)
'}'
;
Encoding:
{Encoding}
Annotations
name=ID
;
fragment Annotations *:
(annotations+=Annotation)*
;
Annotation:
{Annotation}
'@'(name=ID)?
;
The problem is that the name of the Annotation-rule is optional (after the @-character). I assume the parser has a problem when trying to parse something like:
Enumeration ABC {
@
MyEncoding
}
In this example, the ID "MyEncoding" could either be the name of the annotation or the name of the encoding. Is there any way to tell the parser that is is supposed to be the name of the encoding? I tried Syntactic predicates but without success. I also tried to forbid any Hidden Terminal Symbols between the add character and the name, also without success.
Any ideas?