Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cannot serialize a Boolean false value
Cannot serialize a Boolean false value [message #1037510] Tue, 09 April 2013 16:42 Go to next message
Ronan B is currently offline Ronan B
Messages: 247
Registered: July 2009
Senior Member
Hi,
I'm having a problem when setting the "config" property in the grammar below to false. It seems that XText doesn't allow booleans to be set to false, true works fine. Is there a trick to this? Am I missing some specific property setting on my EAttribute?

My example is I have a "config" property which is of type EBooleanObject in my Ecore file. When I set the value to false in ATL I get an XText exception as follows:

org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Serialization failed
<# of serialized tokens>: <EObject path> "<serializable fragment, starting from the end>":
-> <possible reasons for not continuing>
31:SubModule'X'.statements[0]->List'ManagedElement'.children[0]->Leaf'managedElementId': "leaf managedElementId { type string ; mandatory tru...":
-> Can not leave rule 'Leaf' since the current object 'Leaf' has features with unconsumed values: 'config':1
29:SubModule'X'.statements[0]->List'ManagedElement'.children[0]->Leaf'managedElementId'.type->DataType'string': ": string ; mandatory true ; } } }":
-> DataType_NamespaceAssignment_0_0: DataType.namespace is not set.
27:SubModule'X'.statements[0]->List'ManagedElement'.children[0]->Leaf'managedElementId': "leaf managedElementId { type string ; } } }":
-> Can not leave rule 'Leaf' since the current object 'Leaf' has features with unconsumed values: 'mandatory':1, 'config':1
25:SubModule'X'.statements[0]->List'ManagedElement'.children[0]->Leaf'managedElementId'.type->DataType'string': ": string ; } } }":
-> DataType_NamespaceAssignment_0_0: DataType.namespace is not set.
23:SubModule'X'.statements[0]->List'ManagedElement'.children[0]->Leaf'managedElementId'.type->DataType'string': ": string ; } } }":
-> DataType_NamespaceAssignment_0_0: DataType.namespace is not set.
22:SubModule'X': "submodule XX { belongs-to XX { prefix ...":
-> Can not leave rule 'SubModule' since the current object 'SubModule' has features with unconsumed values: 'statements':1
21:SubModule'X': "; belongs-to XX { prefix XX ; } descr...":
-> SubModule_YangVersionAssignment_3_1: AbstractModule(SubModule).yangVersion is not set.
20:SubModule'X': "submodule X { belongs-to XX { prefix ...":
-> Can not leave rule 'SubModule' since the current object 'SubModule' has features with unconsumed values: 'statements':1
19:SubModule'X': "; belongs-to XX { prefix XX ; } descr...":
-> SubModule_YangVersionAssignment_3_1: AbstractModule(SubModule).yangVersion is not set.
18:SubModule'X'.statements[0]->List'ManagedElement'.children[0]->Leaf'managedElementId': "; } } }":
-> Leaf_ReferenceAssignment_14_1: ModuleStatement(Leaf).reference is not set.
at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeConstructor.serialize(Unknown Source)
at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeConstructor.serialize(Unknown Source)
at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeConstructor.serializeSubtree(Unknown Source)
at org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Unknown Source)
at org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Unknown Source)
at org.eclipse.xtext.resource.XtextResource.doSave(Unknown Source)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Unknown Source)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Unknown Source)
at org.eclipse.m2m.atl.core.emf.EMFExtractor.extract(Unknown Source)
at org.eclipse.m2m.atl.core.service.LauncherService.launch(Unknown Source)
at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launchOrDebug(Unknown Source)
at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launch(Unknown Source)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(Unknown Source)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(Unknown Source)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(Unknown Source)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(Unknown Source)
at org.eclipse.core.internal.jobs.Worker.run(Unknown Source)


I had expected to see the property "config false" in my XText output. If I generate to XMI the value shows up correctly i.e. config="false"

I have a grammer as follows:
Leaf returns yang::Leaf:
'leaf' name=(ID|STRING|KEYWORD) '{'
( when=When )?
( ifFeature=IfFeature )?
'type' type=Type
('mandatory' mandatory?=('true'|'false') ';')?
(musts+=Must)*
( 'default' defaultValue=Value ';' )?
( 'units' units=STRING ';' )?
( 'config' config?=('true'|'false') ';' )?
( 'status' status=StatusKind ';' )?
( 'description' description=STRING ';' )?
( 'reference' reference=STRING ';' )?
( properties+=Property )*
'}'
;

Note: EAttribute "config" is changeable, unique, ordered. All the other settings are false.

Thanks,
Ronan

Re: Cannot serialize a Boolean false value [message #1037533 is a reply to message #1037510] Tue, 09 April 2013 17:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6385
Registered: July 2009
Senior Member
Hi,

i guess you want

((config?='true')|'false') 
Re: Cannot serialize a Boolean false value [message #1038073 is a reply to message #1037533] Wed, 10 April 2013 11:12 Go to previous messageGo to next message
Ronan B is currently offline Ronan B
Messages: 247
Registered: July 2009
Senior Member
Thanks Christian but that is only part of the solution. Changing the grammar alone does not fix the issue, but it helps of course Smile I also had to set the default of the config EAttribute to false also to stop the exceptions showing up.

However, doing this makes my ATL code very confusing. Now I have to set config=true to see config false ; in the serialized output. Setting config=false in my ATL causes the omission of the config statement.

When I look at the XMI the value is set as I expect everytime so perhaps the grammar is still slighly wrong?

Regards,
Ronan

[Updated on: Wed, 10 April 2013 15:00]

Report message to a moderator

Re: Cannot serialize a Boolean false value [message #1038238 is a reply to message #1038073] Wed, 10 April 2013 15:43 Go to previous messageGo to next message
Ronan B is currently offline Ronan B
Messages: 247
Registered: July 2009
Senior Member
Hi,
I'm not sure my previous solutions works as it is not repeatable. Perhaps I made a change somewhere else by accident and it made it work. Either way it doesn't work now.

Instead I can get it to work with the following XText:
( 'config' ((config?='false')|'true') ';' )?

This works without changing the Ecore model to set a default value. However, it has the same problem as above in that I have to set the config=true to get config false; in the output.
Thanks,
Ronan
Re: Cannot serialize a Boolean false value [message #1038252 is a reply to message #1038238] Wed, 10 April 2013 16:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6385
Registered: July 2009
Senior Member
Hi ?= sets a property to true if the thing that is assigned is there

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: Cannot serialize a Boolean false value [message #1047612 is a reply to message #1038252] Tue, 23 April 2013 12:50 Go to previous message
Ronan B is currently offline Ronan B
Messages: 247
Registered: July 2009
Senior Member
Hi,
Sorry meant to say thanks! So thanks!
Previous Topic:Triggering a re-link
Next Topic:Linking for a cross-reference-less grammar?
Goto Forum:
  


Current Time: Fri Oct 24 08:32:15 GMT 2014

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

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