Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Serializing a manually created xtext model(Serialization)
Serializing a manually created xtext model [message #486953] Mon, 21 September 2009 06:00 Go to next message
Eclipse UserFriend
Dear Xtext team,

I have created a grammar, say MyDsl.
Using the MyDslFactory class, Ive created a model and would like to serialize it into the textual representation.

In my grammar I have an annotation terminal rule:

terminal ML_DESC returns ecore::EString : ('@desc') WS* '{' -> '}';

How do I configure the serializer to include this terminal rule so that the textual representation will display the"@desc" with the description annotation.

So far, I have been able to print out the value of the annotation without the "@desc".

In my code, I have created the model, and added it to the contents of a resource before calling save. Therefore, the XtextResource does not have a parseresult.

Any hints into the right direction would be appreciated!

Many thanks
Dana
Re: Serializing a manually created xtext model [message #486990 is a reply to message #486953] Mon, 21 September 2009 08:42 Go to previous messageGo to next message
Eclipse UserFriend
Hi Dana,

did you implement a value converter for your ML_DESC?
The toString(String value) should prepend the @desc keyword before the
actual value of your comment.
See
http://www.eclipse.org/Xtext/documentation/0_7_2/xtext.html# valueconverter

Hope that helps,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Dana Wong schrieb:
> Dear Xtext team,
>
> I have created a grammar, say MyDsl. Using the MyDslFactory class, Ive
> created a model and would like to serialize it into the textual
> representation.
>
> In my grammar I have an annotation terminal rule:
>
> terminal ML_DESC returns ecore::EString : (mailto:'@desc') WS* '{' -> '}';
>
> How do I configure the serializer to include this terminal rule so that
> the textual representation will display the"@desc" with the description
> annotation.
>
> So far, I have been able to print out the value of the annotation
> without the "@desc".
>
> In my code, I have created the model, and added it to the contents of a
> resource before calling save. Therefore, the XtextResource does not
> have a parseresult.
>
> Any hints into the right direction would be appreciated!
> Many thanks
> Dana
Re: Serializing a manually created xtext model [message #487021 is a reply to message #486990] Mon, 21 September 2009 10:28 Go to previous message
Eclipse UserFriend
Thank you Sebastian! I didnt know about the AbstractNullSafeConverter class!
Previous Topic:Get AST from my DSL at runtime
Next Topic:How to use xtext editing inside a field of a dialog?
Goto Forum:
  


Current Time: Sun Jul 27 18:36:41 EDT 2025

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

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

Back to the top