Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » assigned value will possible override itself
assigned value will possible override itself [message #522244] Sun, 21 March 2010 17:27 Go to next message
John J. Franey is currently offline John J. FraneyFriend
Messages: 55
Registered: July 2009
Member
I understand why I get this warning:

Quote:

The assigned value of feature 'end' will possibly override itself because it is used inside of a loop.



In my dsl grammar, I want to say that 'end' and 'start' can appear in any order. That's all I want to say. I'll accept that the values can be overwritten. My question: is there a way to avoid the loop or the warning message but still permit these to appear in any order?


Entity:
  (
     ('end' end=INT) |
     ('start' start=INT)
  )*

Re: assigned value will possible override itself [message #522246 is a reply to message #522244] Sun, 21 March 2010 17:34 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
If you only have two rules, you could always do this:

Entity:
(
(('end' end=INT) ('start' start=INT)?)
|(('start' start=INT) ('end' end=INT)?)
)

- henrik

On 3/21/10 6:27 PM, John J. Franey wrote:
> I understand why I get this warning:
>
> Quote:
>> The assigned value of feature 'end' will possibly override itself
>> because it is used inside of a loop.
>
>
> In my dsl grammar, I want to say that 'end' and 'start' can appear in
> any order. That's all I want to say. I'll accept that the values can be
> overwritten. My question: is there a way to avoid the loop or the
> warning message but still permit these to appear in any order?
>
>
> Entity:
> (
> ('end' end=INT) |
> ('start' start=INT)
> )*
>
>
Re: assigned value will possible override itself [message #522268 is a reply to message #522246] Sun, 21 March 2010 23:29 Go to previous messageGo to next message
John J. Franey is currently offline John J. FraneyFriend
Messages: 55
Registered: July 2009
Member
Henrik Lindberg wrote on Sun, 21 March 2010 13:34
If you only have two rules, you could always do this:

Entity:
(
(('end' end=INT) ('start' start=INT)?)
|(('start' start=INT) ('end' end=INT)?)
)

- henrik




Terrific idea. Thanks.

However, I do indeed have much more than two rules.

Re: assigned value will possible override itself [message #522269 is a reply to message #522268] Sun, 21 March 2010 23:39 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3109
Registered: July 2009
Senior Member
Hi John,

Xtext 1.0 will have the concept of unordered groups (in fact, the
feature is already available in the latest milestone but has still some
problems in the content assist scenario). Unordere groups allow to
define a set of alternatives that may occur in arbitrary order but each
one only onces.

It looks like this:

Entity:
('start' start = INT)?
& ('end' end = INT)?
;

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

Am 22.03.10 00:29, schrieb John J. Franey:
> Henrik Lindberg wrote on Sun, 21 March 2010 13:34
>> If you only have two rules, you could always do this:
>>
>> Entity:
>> (
>> (('end' end=INT) ('start' start=INT)?)
>> |(('start' start=INT) ('end' end=INT)?)
>> )
>>
>> - henrik
>
>
> Terrific idea. Thanks.
>
> However, I do indeed have much more than two rules.
>
>
Re: assigned value will possible override itself [message #522339 is a reply to message #522269] Mon, 22 March 2010 12:43 Go to previous messageGo to next message
John J. Franey is currently offline John J. FraneyFriend
Messages: 55
Registered: July 2009
Member
Thanks.
Re: assigned value will possible override itself [message #1694014 is a reply to message #522339] Thu, 30 April 2015 06:47 Go to previous messageGo to next message
Markus Duft is currently offline Markus DuftFriend
Messages: 30
Registered: March 2015
Member
Hey. Sorry for resurrecting this stone old post - but my problem seems pretty related Smile

I have something like this:

Persistent:
	(modifiers=PersistentModifier) 'persistent' name = FQName 
	 inheritance=PersistentInheritance?
		'{'
			('data-category' category=PersistentCategory ';')? 
			(properties+=Property|elements+=StructuralElement)*
		'}'
;


this allows for properties and elements to appear intermixed in any order, which is cool Smile however, data-category must be before any of these elements appear. So this is possible:

persistent XX {
    data-category Protocol;
    property label "something";
    attribute something : String;
    property something "something";
}


but i would like to somehow achieve this:

persistent XX {
    property label "something";
    attribute something : String;
    data-category Protocol;
    property something "something";
}


If I add the data-category rule to the (|)* group I will get the warning that data-category might override itself (if it appears multiple times). How could I make sure that it can only appear once, but still be intermixed somewhere in the code? Is it possible?
Re: assigned value will possible override itself [message #1694017 is a reply to message #1694014] Thu, 30 April 2015 07:01 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 13884
Registered: July 2009
Senior Member
Hi,

the feature "any order" is called unordered group and can be found in the docs


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: assigned value will possible override itself [message #1694032 is a reply to message #1694017] Thu, 30 April 2015 07:59 Go to previous messageGo to next message
Markus Duft is currently offline Markus DuftFriend
Messages: 30
Registered: March 2015
Member
Hey,

I know about unordered groups, but i cannot imagine how to create what i described with unordered groups....?! Can you given an example? I want 3 different objects in arbitrary order, but two of them are collections, and one is not.

Thanks!
Re: assigned value will possible override itself [message #1694041 is a reply to message #1694032] Thu, 30 April 2015 08:43 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 13884
Registered: July 2009
Senior Member
Model:
	(a+=A|
	b+=B)*
	& (c=C)?
	& (a+=A|
	b+=B)*
	;


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: assigned value will possible override itself [message #1694047 is a reply to message #1694017] Thu, 30 April 2015 09:03 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3109
Registered: July 2009
Senior Member
On 30.04.15 09:01, Christian Dietrich wrote:
> Hi,
>
> the feature "any order" is called unordered group and can be found in
> the docs

It's not even necessary to use unordered groups here. You may want to
try this pattern:

Persistent:
(modifiers=PersistentModifier) 'persistent' name = FQName
inheritance=PersistentInheritance?

'{'
(prop+=Prop|ele+=Ele)*
('d-c' cat=Cat ';' (prop+=Prop|ele+=Ele)*)?
'}'
;

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Find help at http://xtext.itemis.com or xtext(@)itemis.com
Blog: zarnekow.blogspot.com
Twitter: @szarnekow
Google+: https://www.google.com/+SebastianZarnekow
Re: assigned value will possible override itself [message #1694060 is a reply to message #1694047] Thu, 30 April 2015 09:42 Go to previous message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 13884
Registered: July 2009
Senior Member
oh - yes. and it is way more elegant

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Reusing XAnnotation
Next Topic:Formatter2: how to correctly format a block (indentation)
Goto Forum:
  


Current Time: Fri Apr 16 12:15:43 GMT 2021

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

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

Back to the top