Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » A Rule with a list of rules where all entrys are allowed once
A Rule with a list of rules where all entrys are allowed once [message #1058842] Wed, 15 May 2013 11:45 Go to next message
Liroth Lustim is currently offline Liroth LustimFriend
Messages: 14
Registered: May 2013
Junior Member
Hello,

I am trying to add some optional settings to some elements in my DSL:

Element:
  settings+=Settings*
  OtherStuff+=MoreRules* ;


Now the settings like version or activation are all allowed only once, so I tryed different approches, but non of them worked.

Settings:
  Version? | Activation;

Version_NR:
  'vers' version = INT;

Activation:
  (active?='activate')?


One try is shown with version, a different one with Activation but all result in an error:
Quote:
Decision can match input such as "{')', 'vers'..'activate'}" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input


I don't want to call Version_NR and Activation in the Rule Elements because I don't want to force the order. If I use the Settings-Rule the DSL can handle activate bevore version and vice versa.

Has anyone an idea how I can have these Rules called once or not even once without forcing a special order.

Thanks
Liroth

[Updated on: Wed, 15 May 2013 11:47]

Report message to a moderator

Re: A Rule with a list of rules where all entrys are allowed once [message #1058843 is a reply to message #1058842] Wed, 15 May 2013 11:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6485
Registered: July 2009
Senior Member
Hi,

why so Optional?

Settings:
Version | Activation;

Version_NR:
'vers' version = INT;

Activation:
{Activation}(active?='activate')?
Re: A Rule with a list of rules where all entrys are allowed once [message #1058848 is a reply to message #1058843] Wed, 15 May 2013 12:04 Go to previous messageGo to next message
Liroth Lustim is currently offline Liroth LustimFriend
Messages: 14
Registered: May 2013
Junior Member
thanks for the quick reply, but I still get the same error.

I want to have it optional and flexible because there are 10 or 20 different settings. I don't want to force the user to write the whole list down for every element. Also I don't want that he has to remember the correct order for all the settings, if he wants to add a setting later he shuld be able to add it at the bottom of the list.
Re: A Rule with a list of rules where all entrys are allowed once [message #1058851 is a reply to message #1058848] Wed, 15 May 2013 12:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6485
Registered: July 2009
Senior Member
Hi,

and what starts and stops a settings object?
Re: A Rule with a list of rules where all entrys are allowed once [message #1058868 is a reply to message #1058851] Wed, 15 May 2013 13:21 Go to previous messageGo to next message
Liroth Lustim is currently offline Liroth LustimFriend
Messages: 14
Registered: May 2013
Junior Member
I don't know what you mean wit start and stop. Settings is just a parsing rule to Version and Activation which have their startwords 'vers' and 'activate'.
Or do you mean the Element stuff, I forgot '('and ')' around the ruls in Element but they are in my code.
Re: A Rule with a list of rules where all entrys are allowed once [message #1058876 is a reply to message #1058868] Wed, 15 May 2013 13:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6485
Registered: July 2009
Senior Member
If you have a model

if you dont have a version and dont have a 'activate' (empty model)
should that be 1 oder 100000 settings?
Re: A Rule with a list of rules where all entrys are allowed once [message #1058879 is a reply to message #1058876] Wed, 15 May 2013 14:11 Go to previous messageGo to next message
Liroth Lustim is currently offline Liroth LustimFriend
Messages: 14
Registered: May 2013
Junior Member
In my model is the entry rule Elements. In there is the list settings (2nd line in the 1st code) with the rule Settings which could be called multiple times or not.
If I don't have a version and I don't have 'activate' than settings.size should return 0.
In some other rules for the Element are forced entrys so there is no empty model.
Re: A Rule with a list of rules where all entrys are allowed once [message #1058882 is a reply to message #1058879] Wed, 15 May 2013 14:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6485
Registered: July 2009
Senior Member
So why not

Settings:
Version | Activation;

Version_NR:
'vers' version = INT;

Activation:
active?='activate'
Re: A Rule with a list of rules where all entrys are allowed once [message #1058886 is a reply to message #1058882] Wed, 15 May 2013 14:33 Go to previous messageGo to next message
Liroth Lustim is currently offline Liroth LustimFriend
Messages: 14
Registered: May 2013
Junior Member
If I would do this the user could add many different versions and activate it multiple times.
I want to have none or one version, same with activate.
Re: A Rule with a list of rules where all entrys are allowed once [message #1058887 is a reply to message #1058886] Wed, 15 May 2013 14:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6485
Registered: July 2009
Senior Member
Hi,

have a look at the feature called "unordered groups"
Re: A Rule with a list of rules where all entrys are allowed once [message #1058895 is a reply to message #1058887] Wed, 15 May 2013 15:08 Go to previous message
Liroth Lustim is currently offline Liroth LustimFriend
Messages: 14
Registered: May 2013
Junior Member
This did the trick and it also eliminated the necissity to make settings a list in the rule Element. So i can directly access the items insted of filtering an iterable in the codegeneration with xtend.

now it looks like:
Element:
  settings=Settings  //no list here anymore
  OtherStuff+=MoreRules*
;

Settings:
    ('vers' version = INT)? & (active?='activate')?
;


and everything works fine.

Thank you very much!
Liroth
Previous Topic:Remove gaps from the blanked name
Next Topic:autoimport with Xbase 2.4
Goto Forum:
  


Current Time: Sun Nov 23 06:24:31 GMT 2014

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

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