| [Xtext] At least one alternative, given order, no repeating of any alternative [message #480722] |
Tue, 18 August 2009 06:26  |
Eclipse User |
|
|
|
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
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04527 seconds