Community
Participate
Working Groups
The particular problem I have is with XReferences in Xcore XReference: (annotations+=XAnnotation)* ((resolveProxies?='resolving'? & (containment?='contains' | container?='container')) | (local?='local'? & 'refers')) You can see from the grammar that it should not be possible to proceed without producing at least contains, container, or refers, with resolving and local being optional where the former is allowed only in the first two cases while the latter only in the last one. The serializer ends up not producing the refers keyword for proxy resolving references. If you install Xcore you can see this by invoking Convert to Xcore on a *.genmodel. This used to work long ago. Then the serialize threw exceptions for quite some time. Now it produces these wrong results. I suppose I could change the grammar if this can't be solved...
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. ***