Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cross reference with the same name
Cross reference with the same name [message #1269354] Tue, 11 March 2014 19:11 Go to next message
Cristiano Politowski is currently offline Cristiano PolitowskiFriend
Messages: 11
Registered: February 2014
Location: Brasil
Junior Member
Hi guys, i need to do a model like this

Relationships
Vp1 : V1;
Vp2 : V2 V3 V4;
Constraints
V1 require V2
V2 require Vp1
Vp1 require Vp2


And my Grammar is like this

Model:
	'Relationships'
	a+=ElementA*
	'Constraints'
	c+=Constraint*	
;

Constraint:
	c1=[ElementA] 'require' c2=[ElementB] |
	c1=[ElementB] 'require' c2=[ElementA] | 
	c1=[ElementB] 'require' c2=[ElementB]
;

ElementB:
	name=ID
;

ElementA:
	name=ID ':' b+=ElementB ';'
;


I have had problems because the name of elements are equals:

warning(200): ../org.ovm.ui/src-gen/org/ovm/ui/contentassist/antlr/internal/InternalOvm.g:176:1: Decision can match input such as "RULE_ID 'require' RULE_ID" using multiple alternatives: 1, 2, 3
As a result, alternative(s) 3,2 were disabled for that input
error(201): ../org.ovm.ui/src-gen/org/ovm/ui/contentassist/antlr/internal/InternalOvm.g:176:1: The following alternatives can never be matched: 2,3


I have tried create two terminals with differents names, like ID1 and ID2 with same regex inside. Tried to use the operator =>. Create QualifiedNames, etc, with no success.

Here is my last hope.

Thanks in advance.
Re: Cross reference with the same name [message #1269357 is a reply to message #1269354] Tue, 11 March 2014 19:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

parsing and lexing is done in two phases
=>
you have to solve it like

Constraint:
c1=[Element] 'require' c2=[Element];

Element: ElementA|ElementB;

and adapt nameprovider and maybe write some checks


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cross reference with the same name [message #1269369 is a reply to message #1269357] Tue, 11 March 2014 19:36 Go to previous message
Cristiano Politowski is currently offline Cristiano PolitowskiFriend
Messages: 11
Registered: February 2014
Location: Brasil
Junior Member
Man, i don't know how to thank you. I passed many days working at this and you solved in one minute.

I will put your name in my final project.

Thank you very much.
Previous Topic:strange behavior in error marker generation
Next Topic:Tutorial Errors
Goto Forum:
  


Current Time: Thu Apr 25 01:40:08 GMT 2024

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

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

Back to the top