|Xtext: Trying to check for cross references but get ambiguous grammar [message #1028653]
||Thu, 28 March 2013 14:58
| Anja Liro
Registered: March 2013
I am trying to implement something like this:
I have two types, individuals and groups. I can assign one individual to another individual and one group to another. Now I want to be able to assign an individual to a group, but it should be forbidden to assign a group to an individual.
Here is an example:
ind2 = ind1; //ok
gr2 = gr1; //ok
gr2 = ind2; //ok
ind2 = gr2; //forbidden
I tried to realize this with the following grammar:
Group | Individual | Assignment;
'group' name=ID ';' ;
'individual' name=ID ';' ;
left=[Group] '=' right=[Group] ';'
| left=[Group] '=' right=[Individual] ';'
| left=[Individual] '=' right=[Individual] ';'
However, this grammar is ambiguous and ANTLR complains, which makes sense
warning(200): ../org.xtext.example.vanilladsl.ui/src-gen/org/xtext/example/mydsl/ui/contentassist/antlr/internal/InternalVanillaDsl.g:232:1: Decision can match input such as "RULE_ID '=' RULE_ID ';'" using multiple alternatives: 1, 2, 3
As a result, alternative(s) 3,2 were disabled for that input
However, shouldn't there be a way to somehow realize this setting? I'm pretty new to Xtext, so I might be just missing something. Does anybody have an idea what I could do?
Thanks a lot
Powered by FUDForum
. Page generated in 0.01754 seconds