Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Crossreferencing with custom terminal rules / need ^ for reference
Crossreferencing with custom terminal rules / need ^ for reference [message #657462] Wed, 02 March 2011 20:37 Go to next message
Simon Stratmann is currently offline Simon StratmannFriend
Messages: 27
Registered: February 2011
Junior Member
Hello,

I use XText 2.0 M5. I need to use my own terminal rules for element names. Say this is my grammar:

Test1:
"testentity" name=IDENTIFIER ";";

RefTest:
"testuse" refTo=[Test1] ";";

terminal IDENTIFIER returns ecore::EString:
	('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;

I realize this terminal rule is not (yet) different from ID.

With this cross-references in the language are only recognized when they have a leading caret:

testentity test;
testuse ^test; //works
testuse test; //error: mismatched input 'test' expecting RULE_ID


When I remove the import of common terminals from my grammar I get the error "Cannot resolve implicit reference to rule 'ID'".

So my question is: How do I get the cross-references to work without leading caret? From
this thread know that ID is used for cross-references by default. Could I change that?

Thanks a lot for your help!

Simon
Re: Crossreferencing with custom terminal rules / need ^ for reference [message #657464 is a reply to message #657462] Wed, 02 March 2011 20:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

refTo=[Test1]

is short for

refTo=[Test1|ID]

so in you case it might be

refTo=[Test1|IDENTIFIER]

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Crossreferencing with custom terminal rules / need ^ for reference [message #657465 is a reply to message #657462] Wed, 02 March 2011 20:44 Go to previous message
Simon Stratmann is currently offline Simon StratmannFriend
Messages: 27
Registered: February 2011
Junior Member
Edit: Christian, that was fast. I just found it out by myself. Thanks anyway!

Sorry, editing doesn't work anymore. I found it out. I saw numerous examples like
refTo=[Test1|Identifier]
but never realized this was the way to accomplish what I needed.

[Updated on: Wed, 02 March 2011 20:44]

Report message to a moderator

Previous Topic:Acess the EAttribute of EClass of imported ecore model into Xtext Grammar
Next Topic:IXtextBuilderParticipant: element moved
Goto Forum:
  


Current Time: Thu Apr 25 14:06:33 GMT 2024

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

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

Back to the top