Xtext: Trying to check for cross references but get ambiguous grammar [message #1028653] |
Thu, 28 March 2013 14:58 |
Anja Liro Messages: 3 Registered: March 2013 |
Junior Member |
|
|
Hi,
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:
individual ind1;
individual ind2;
group gr1;
group gr2;
ind2 = ind1; //ok
gr2 = gr1; //ok
gr2 = ind2; //ok
ind2 = gr2; //forbidden
I tried to realize this with the following grammar:
VanillaModel:
statements+=Statement*;
Statement:
Group | Individual | Assignment;
Group:
'group' name=ID ';' ;
Individual:
'individual' name=ID ';' ;
Assignment:
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
-anja
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03641 seconds