Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [Xtext] At least one alternative, given order, no repeating of any alternative
[Xtext] At least one alternative, given order, no repeating of any alternative [message #480722] Tue, 18 August 2009 06:26 Go to next message
Eclipse UserFriend
Originally posted by: oba.informatik.uni-kiel.de

Hello everyone,

is it possible to write a rule

+ which has optional alternatives
+ but one of the alternatives should occur
+ none of the alternatives should be repeated.

So, something like this (MTSI being different rules):

MTSI = M (TSI)? | TSI
TSI = T (SI)? | SI
SI = S (I)? | I

M = 'init' and/or 'final' // can occur both or none or just one
T = ('cond'|'reference'|'textual'|'normal')//this one is an enum
S = 'state'
I = <ID>


The first idea was:

((isInitial?='init' isFinal?='final') | type=StateType | 'state' | id=ID )+

enum StateType = ...

But this way, the reoccuring of any alternative is _not_ prohibited thus
this is a valid model for example:

init init final init ref cond state state anID anotherID

I also would not like to write rules that are very similar to the
MTSI-chain above because in that case Xtext generates model elements for
all of them --> Surely, I can prohibit Xtext from doing this but I
would prefer if I can solve this in the grammar.

Is this possible?
Or is it an "Eierlegende Wollmilchsau" as the Germans say..?

Thank you very much

myName
Re: [Xtext] At least one alternative, given order, no repeating of any alternative [message #480731 is a reply to message #480722] Tue, 18 August 2009 06:56 Go to previous messageGo to next message
Eclipse UserFriend
> is it possible to write a rule
>
> + which has optional alternatives
> + but one of the alternatives should occur
> + none of the alternatives should be repeated.

It is better to ensure that using validation, which also gives you the
chance to provide the user with customised error messages.

Alex
Re: [Xtext] At least one alternative, given order, no repeating of any alternative [message #480744 is a reply to message #480731] Tue, 18 August 2009 07:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: oba.informatik.uni-kiel.de

Alexander Nittka wrote:
>> is it possible to write a rule
>>
>> + which has optional alternatives
>> + but one of the alternatives should occur
>> + none of the alternatives should be repeated.
>
> It is better to ensure that using validation, which also gives you the
> chance to provide the user with customised error messages.
>

Thanks Alex, for your response.
I am not sure, if I know how to do check whether for example "cond
textual" has been typed. Because the attribute "type" will be set only
once, even the user has typed two values for it. The latter will
overwrite the first one, so how can I check if an attribute has been set
twice or more for a model instance?

Thanks

myName
Re: [Xtext] At least one alternative, given order, no repeating of any alternative [message #480745 is a reply to message #480731] Tue, 18 August 2009 07:30 Go to previous messageGo to next message
Eclipse UserFriend
See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=271482
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 18.08.09 12:56, schrieb Alexander Nittka:
>> is it possible to write a rule
>>
>> + which has optional alternatives
>> + but one of the alternatives should occur
>> + none of the alternatives should be repeated.
>
> It is better to ensure that using validation, which also gives you the
> chance to provide the user with customised error messages.
>
> Alex
Re: [Xtext] At least one alternative, given order, no repeating of any alternative [message #480746 is a reply to message #480744] Tue, 18 August 2009 07:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: oba.informatik.uni-kiel.de

I mean:
> I am not sure, if I know how to do check whether for example "cond
> textual" has been typed. Because the attribute "type" will be set only
> once, even the user has typed two values for it.

The according attribute will be set to one value, even if the user has
typed two different values.
Re: [Xtext] At least one alternative, given order, no repeating of any alternative [message #480761 is a reply to message #480745] Tue, 18 August 2009 08:30 Go to previous message
Eclipse UserFriend
Originally posted by: oba.informatik.uni-kiel.de

I have read the "[Xtext]"choice"cardinality" discussion and the bug
description. It looks like, the best option for me at the moment is list
the alternatives and wait for the new "unordered group" construct.

Thanks for pointing out the references.

mN

Sebastian Zarnekow wrote:
> See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=271482
Previous Topic:MweReader class
Next Topic:[XTEXT 0.7.2] Update Site Xpand not available
Goto Forum:
  


Current Time: Wed Nov 05 06:29:14 EST 2025

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

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

Back to the top