Serializing an unordered group? [message #1689469] |
Mon, 23 March 2015 12:37  |
Eclipse User |
|
|
|
Hi,
I have a grammar with a big unordered group, some elements of which are 0..1 and the others are 0..n, s.t., like:
( elem1=Rule1?
& elem2+=Rule2*
& elem3+=Rule3*
& elem4=Rule4?
...)
Next I have a model that populates some of the elements of this group.
Then I try to add more elements via a semantic modification (xtextEditor.getDocument().modify(..)).
The effect I'm seeing: all new elements for the unordered group are appended to the end of the existing content. This, however, violates the constraint of the unordered group:
Quote:Elements with a cardinality of * or + have to appear continuously without interruption
Does the serializer have a hook where I can influence serialization as to generate a valid model in this situation?
thanks
Stephan
|
|
|
|
|
|
Re: Serializing an unordered group? [message #1689566 is a reply to message #1689538] |
Mon, 23 March 2015 17:34   |
Eclipse User |
|
|
|
Hi Stephan
I have tried using unordered groups a couple of times to improve a
grammar written before they existed. However I have reverted each time.
I suggest that you abandon them and just use a bunch--of-adjectives
collection so that any order is permitted.
Unfortunately you are then obliged to use validation rules to impose
restrictions on multiplicity.
Regards
Ed Willink
On 23/03/2015 20:22, Stephan Herrmann wrote:
> Twenty or so grammars later I still don't know which factor exactly
> makes the difference. It's not the double keywords, it's not the fact
> that some group elements are separate rules while others are inline.
>
> Maybe when pulling the two special elements out of the unordered group
> I just got lucky in my experiments, but that's the only way I could
> get the serializer to work, i.e., produce valid models.
>
> This implies, that I will have to force an order in my grammar, where
> previous versions let users choose the order.
>
> BTW: In successful attempts the sub-list that I was adding to was
> always pulled to the end of the unordered group (also end of the
> document), so maybe it's just not possible to add to two sub-lists
> within the same unordered group at the same time ...
>
> Any hints on how to adapt the serializer in these regards appreciated,
>
> Stephan
|
|
|
|
Powered by
FUDForum. Page generated in 0.37201 seconds