Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Reference Question for a goto like statement
Reference Question for a goto like statement [message #993395] Mon, 24 December 2012 08:56 Go to next message
Selim Ciraci is currently offline Selim CiraciFriend
Messages: 1
Registered: December 2012
Junior Member
Hi,

I have generated an xtext project from my ecore model. In my model, I have an EClass called statement which has an attribute called label. Every statement is a subclass of this class. For example, I have a call statement class, and its syntax is defined as:
call returns call
label=EString? 'call' to=[CCElem|Estring] '(' ')'

I want the label of s statement to be optinally defined. Now I have special goto like statement, where the user can refer to a statement by its label. So using the above syntax for call, I want to have something like:
n1 call foo();
call mbar();
goto n1;

The syntax for goto is defined as:
goto returns goto
label=EString? 'goto' st=[statement|EString]

With this rule and the above program segment, I get an error in the goto line saying:
Couldn't resolve reference to Statement 'n1'

Somehow it cannot identify the statement by its label. What am I doing wrong? do you have any suggestions?
Re: Reference Question for a goto like statement [message #993589 is a reply to message #993395] Mon, 24 December 2012 22:32 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
By default, the linker links an ID to a feature called "name" in the
target. Since your target uses a feature called "label", this will not
work out of the box. Also note that the reference must be a non
containment reference.

I have not had to change this myself, but I think the issue has been
answered earlier in this forum.

Since your metamodel is an already existing one, I assume you can't
change it (rename "label" to "name") even if this is by far the easiest.
Not sure if it works to add a derived attribute (called "name"), but
should be very quick to find out.

I hope that helps.
Regards and Happy Holidays.

- henrik

On 2012-24-12 21:03, Selim Ciraci wrote:
> Hi,
>
> I have generated an xtext project from my ecore model. In my model, I
> have an EClass called statement which has an attribute called label.
> Every statement is a subclass of this class. For example, I have a call
> statement class, and its syntax is defined as:
> call returns call
> label=EString? 'call' to=[CCElem|Estring] '(' ')'
>
> I want the label of s statement to be optinally defined. Now I have
> special goto like statement, where the user can refer to a statement by
> its label. So using the above syntax for call, I want to have something
> like:
> n1 call foo();
> call mbar();
> goto n1;
>
> The syntax for goto is defined as:
> goto returns goto
> label=EString? 'goto' st=[statement|EString]
>
> With this rule and the above program segment, I get an error in the goto
> line saying: Couldn't resolve reference to Statement 'n1'
> Somehow it cannot identify the statement by its label. What am I doing
> wrong? do you have any suggestions?
>
Previous Topic:problem with trying the editor as Eclipse Application
Next Topic:Debugging lexer & parser
Goto Forum:
  


Current Time: Thu Apr 25 21:19:00 GMT 2024

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

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

Back to the top