Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Serialization of unordered group yields invalid model code(Serialization of unordered group yields invalid codemodel code)
Serialization of unordered group yields invalid model code [message #1740269] Thu, 11 August 2016 05:59 Go to next message
Matthias Fromme is currently offline Matthias FrommeFriend
Messages: 22
Registered: December 2011
Location: Germany
Junior Member
Hello,

i have the following statement within my grammar (simplified):
...
AnotherObject:
    'AnotherObject' attr=INT
    ;

Another:
'Object' name = ID '{'
    (
         ('Attribute1' ':' attribute1= INT)?
       & ('Attribute2' ':' attribute2= INT)?
       & ('Attribute3' (attribute3 += Object)(',' attribute3+= Object)*)?
    )
'}'
...


If i'm now loading a model that looks like this
Object MyObject {
    Attribute1: 1
    Attribute3 AnotherObject 1
}

and programatically add an additional instance of AnotherObject to attribute3 the serialization yields the following invalid model:
Object MyObject {
    Attribute1: 1
    Attribute3 AnotherObject 1Attribute3 AnotherObject 2}

instead of
Object MyObject {
    Attribute1: 1
    Attribute3 AnotherObject 1, AnotherObject 2
}


Is there any way to solve this without changing the metamodel or the model instances? Something like an artificial rule without object creation or a customization of the serializer?

Regards,
Matthias
Re: Serialization of unordered group yields invalid model code [message #1740303 is a reply to message #1740269] Thu, 11 August 2016 11:19 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

you may follow https://bugs.eclipse.org/bugs/show_bug.cgi?id=369175
as a workaround as proposed:

class MyDslRuntimeModule extends AbstractMyDslRuntimeModule {
	
	def Class<? extends PdaUtil> bindPdaUtil() {
		return MyDslPDAUtil
	}
}



public class MyDslPDAUtil extends PdaUtil {
	
	@Override
	public <S, P, E, T, D extends Pda<S, P>> D create(Cfg<E, T> cfg, FollowerFunction<E> ff,
			PdaFactory<D, S, P, ? super E> fact) {
		((FollowerFunctionImpl<E, T>)ff).setUnorderedStrategy(UnorderedStrategy.SEQUENCE);
		return super.create(cfg, ff, fact);
	}

}


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Error when saving a generated XMI to DSL
Next Topic:Adding field with Annotation in ModelInferer
Goto Forum:
  


Current Time: Thu Apr 25 19:03:45 GMT 2024

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

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

Back to the top