Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext: Trying to check for cross references but get ambiguous grammar
Xtext: Trying to check for cross references but get ambiguous grammar [message #1028653] Thu, 28 March 2013 14:58 Go to previous message
Anja Liro is currently offline Anja LiroFriend
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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:Update to Xtext 2.4 and Xtend 2.4
Next Topic:What is this: " missing EOF at " error?
Goto Forum:
  


Current Time: Sat Jul 22 09:07:10 GMT 2017

Powered by FUDForum. Page generated in 0.02805 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software