Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [TCS] indexing values in list property
[TCS] indexing values in list property [message #5323] Fri, 14 March 2008 05:51 Go to next message
Eclipse UserFriend
Hi,

Assuming I had a Metamodel class like this in KM3:

class MyClass {
attribute name : String;
attribute something : String;
reference elements[2-2] ordered container : Element
}
class Element {
attribute name : String;
}


is there any way I could refer to the first or the second of elements in
my TCS template directly?

Such as something like this (I invented "index" here):

template MyClass
: name ","
elements{index=0, referTo=name} ":"
something ","
elements{index=1, referTo=name}
;
Re: [TCS] indexing values in list property [message #7320 is a reply to message #5323] Fri, 14 March 2008 06:38 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

Did you try something like:

template MyClass
: name "," elements{index=0, referTo=name, separator =
":" something ","}
;

?


Regards,

Frédéric Jouault

Thibault a écrit :
> Hi,
>
> Assuming I had a Metamodel class like this in KM3:
>
> class MyClass {
> attribute name : String;
> attribute something : String;
> reference elements[2-2] ordered container : Element
> }
> class Element {
> attribute name : String;
> }
>
>
> is there any way I could refer to the first or the second of elements in
> my TCS template directly?
>
> Such as something like this (I invented "index" here):
>
> template MyClass
> : name "," elements{index=0, referTo=name} ":"
> something ","
> elements{index=1, referTo=name}
> ;
>
>
>
Re: [TCS] indexing values in list property [message #7341 is a reply to message #7320] Fri, 14 March 2008 07:37 Go to previous message
Eclipse UserFriend
Hi,


> template MyClass
> : name "," elements{index=0, referTo=name, separator =
> ":" something ","}
> ;


I assume you mean (leaving out the imaginary "index=0"):

template MyClass
: name "," elements{referTo=name, separator =
":" something ","}
;

I did not try, though I thought about using the separator in a similar
case.
But in a way, that's cheating to me, meaning somebody would have to think
about it to understand that the result would be "firstelement : something,
otherelement"
And this solution would not work for 3 elements and some similar problem.

I guess from your suggestion that TCS currently does not generally allow
referring to indexes of elements in property lists, though in the case of
2 elements, the separator concept might be used as workaround.

In any case thank you, as I had not thought the separator to be so
flexible to allow nesting properties in it.
Previous Topic:[TCS] Inferred property
Next Topic:[TCS] possible bug in ContextIterator
Goto Forum:
  


Current Time: Thu May 08 01:53:56 EDT 2025

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

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

Back to the top