| Summary: | Serializer produces results that don't conform to the grammar | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Ed Merks <Ed.Merks> |
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> |
| Status: | NEW --- | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | costasradu01, galland, mike, moritz.eysholdt, niels.brouwers |
| Version: | 2.3.0 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
|
Description
Ed Merks
Hi Ed,
this is because the serializer currently treats unordered groups as multiple alternatives. I.e., for the serializer ('a' & 'b') is the same as ('a' | 'b')*.
I did this because the sate machines for muliple alternatives are easier to create and tend to be much smaller then then ones for "real" unordered groups.
What you're experiencing right now is the downside that in a multiple alternative, every element is implicitly optional.
As a workaround, you can enable the old behavior of the serializer, which is to treat unordered groups as regular groups (i.e. ('a' & 'b') equals ('a' 'b')):
You'll need to to subclass org.eclipse.xtext.serializer.analysis.ContextPDAProvider and overwrite the following method:
---
protected Pda<ISerState, RuleCall> createPDA(EObject context) {
SerializerCfg cfg = new SerializerCfg(context);
SerializerFollowerFunction ff = new SerializerFollowerFunction(cfg, context);
// treat unordered groups as regular groups
ff.setUnorderedStrategy(FollowerFunctionImpl.UnorderedStrategy.SEQUENCE);
Pda<ISerState, RuleCall> pda = new PdaUtil().create(cfg, ff, new SerializerPDAElementFactory());
new NfaUtil().removeOrphans(pda);
return pda;
}
----
The downside of this workaround, however, is, that if you parse and re-serialize models the order in which unorderedgrou-elements will be serialized is determined by the grammar and *not* by the preveiously parsed files. I.e. the order doesn't remain how it was but is reseted to its default.
I'll leave this bug open until there is a real solution for this.
Shouldn't it treat ('a' & 'b') as ('a' 'b') | ('b' 'a'). I know that the number of permutations grows exponentially (n!). I can can work around the problem like this:
XReference:
(annotations+=XAnnotation)*
((resolveProxies?='resolving' containment?='contains') |
(containment?='contains' resolveProxies?='resolving') |
containment?='contains' |
(resolveProxies?='resolving' container?='container') |
(container?='container' resolveProxies?='resolving') |
container?='container' |
(local?='local' 'refers') |
('refers' local?='local') |
'refers')
But that's just doing by hand what the serialize could do automatically.
once this is fixed, activate the test cases mentioned in bug 369175 (In reply to comment #3) > once this is fixed, activate the test cases mentioned in bug 369175 The link was supposed to point to bug 346695 *** Bug 346695 has been marked as a duplicate of this bug. *** *** Bug 412600 has been marked as a duplicate of this bug. *** *** Bug 457006 has been marked as a duplicate of this bug. *** *** Bug 476409 has been marked as a duplicate of this bug. *** |