Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problem cross-referencing to non-ID terminal(Do xref targets have to be of type ID or STRING?)
Problem cross-referencing to non-ID terminal [message #807084] Sun, 26 February 2012 00:17 Go to next message
Scott Finnie is currently offline Scott FinnieFriend
Messages: 94
Registered: October 2011
Member
I have the following snippet of grammar:

Association:
	'Rel' id=REL_ID '{'	
	(roles+=RelRole)*
	'}';

terminal REL_ID :
	('R'|'r')('0'..'9')+
;

[..]

AssociationClass:
	'Association' 'Class' name=ID 'for' rel=[Association] '{'
	(features+=AssocFeature)*
	'}'
;


It compiles & generates fine, but with this sample input:

	Rel R1 {
		//...
	}
	
	Association Class Party_Role for R1 {
		//...
	}


I get an error when trying to run unit tests as follows:

    21: mismatched input 'R1' expecting RULE_ID
    24: extraneous input '}' expecting EOF


This thread suggests cross-reference targets need to be of terminal type ID. Is that correct?

Goal is simply that the value of Relationship.id matches the pattern above (Rxx). I could implement as a custom validation, or is there a better option?

Thanks.
Re: Problem cross-referencing to non-ID terminal [message #807378 is a reply to message #807084] Sun, 26 February 2012 10:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

rel=[Association] is short for rel=[Association|ID] which indicates that an ID will be parsed for the cross ref. but there is nobody who prevents you from changing this to rel=[Association|REL_ID] which leads to a REL_ID beeing parsed.
P.S: you will need a custom QualifiedNameProvider to since you Association has no name attribute. so you have to explictely declare the id as QualifiedName

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem cross-referencing to non-ID terminal [message #808438 is a reply to message #807378] Mon, 27 February 2012 19:46 Go to previous messageGo to next message
Scott Finnie is currently offline Scott FinnieFriend
Messages: 94
Registered: October 2011
Member
Thanks Christian (again!!).

BTW: how should I read the phrase [Association|ID]? Is it alternation? (Does that mean I could embed an entire association inline? Need to try it out...)
Re: Problem cross-referencing to non-ID terminal [message #808442 is a reply to message #808438] Mon, 27 February 2012 19:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
No, it is not an alternation. as i said [Association|ID] is short for: reference to an Association and therefore parse an ID

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem cross-referencing to non-ID terminal [message #808488 is a reply to message #808442] Mon, 27 February 2012 20:59 Go to previous message
Scott Finnie is currently offline Scott FinnieFriend
Messages: 94
Registered: October 2011
Member
ok thx.
Previous Topic:cross references and name spaces
Next Topic:inlined cross-references
Goto Forum:
  


Current Time: Thu Mar 28 08:12:49 GMT 2024

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

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

Back to the top