Why the cross-reference does not work? [message #854738] |
Tue, 24 April 2012 07:46 |
Jingang Zhou 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 |
Jan Koehnlein 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02241 seconds