Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Why the cross-reference does not work?
Why the cross-reference does not work? [message #854738] Tue, 24 April 2012 07:46 Go to next message
Jingang Zhou is currently offline Jingang ZhouFriend
Messages: 57
Registered: December 2010
Member
Hi, all,

In my simple grammar (see the code below), I want to reference attributes of some entities, e.g., the age of a people. But when I use the grammar, an error occurs as below:

Couldn't resolve reference to Attribute 'age'.

My grammar is below:

Model:
	entity += Entity+
	expr += Expr*
;

Entity: 'entity' name=ID '{' attrs+=Attribute* '}';
	
Attribute: Type name=ID;

Expr: ref=[Attribute];

Type: 'int' | 'string';


and the instance is below:
entity People {
    int age	
}
age


What is the problem?

Thanks.

Robin

[Updated on: Tue, 24 April 2012 07:47]

Report message to a moderator

Re: Why the cross-reference does not work? [message #854761 is a reply to message #854738] Tue, 24 April 2012 08:07 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
From outside the Entity, the age attribute has to be referred to with
the fully qualified name, i.e. 'People.age'. Unfortunately, you specify
the cross-reference as being
[Attribute]
which is equivalent to
[Attribute|ID]
and the ID rule does not allow to the separator char '.'



Am 24.04.12 09:46, schrieb Robin Zhou:
> Hi, all,
>
> In my simple grammar (see the code below), I want to reference
> attributes of some entities, e.g., the age of a people. But when I use
> the grammar, an error occurs as below:
>
> Couldn't resolve reference to Attribute 'age'.
>
> My grammar is below:
>
>
> Model:
> entity += Entity+
> expr += Expr*
> ;
>
> Entity: 'entity' name=ID '{' attrs+=Attribute* '}';
>
> Attribute: Type name=ID;
>
> Expr: ref=[Attribute];
>
> Type: 'int' | 'string';
>
>
> and the instance is below:
>
> entity People {
> int age
> }
> age
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: Why the cross-reference does not work? [message #854800 is a reply to message #854761] Tue, 24 April 2012 08:41 Go to previous messageGo to next message
Jingang Zhou is currently offline Jingang ZhouFriend
Messages: 57
Registered: December 2010
Member
Jan Kohnlein wrote on Tue, 24 April 2012 04:07
From outside the Entity, the age attribute has to be referred to with
the fully qualified name, i.e. 'People.age'. Unfortunately, you specify
the cross-reference as being
[Attribute]
which is equivalent to
[Attribute|ID]
and the ID rule does not allow to the separator char '.'





So, how to solve this problem?

Thanks.
Re: Why the cross-reference does not work? [message #854835 is a reply to message #854800] Tue, 24 April 2012 09:18 Go to previous message
Jingang Zhou is currently offline Jingang ZhouFriend
Messages: 57
Registered: December 2010
Member
I sovled the problem using a format of
Expr: attr=[Attribute|QualifiedAttributeName];

QualifiedAttributeName: ID ('.' ID)*;


The question here is how to replace the '.' by '@' if the last ID is an attribute, so that I can gain the following elments like:

People.Child
People.Child@name

Of couse, I changed the grammar to allow entity nesting.

Thanks.

Robin
Previous Topic:Single File Generation - IFileSystemAccess/JavaIoFileSytemAccess
Next Topic:[Solved]Problem in a constrain
Goto Forum:
  


Current Time: Wed Aug 12 19:14:07 GMT 2020

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

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

Back to the top