Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtext] implement toString() with the ParseTreeConstructor
[Xtext] implement toString() with the ParseTreeConstructor [message #659244] Fri, 11 March 2011 15:54 Go to next message
Jens von Pilgrim is currently offline Jens von PilgrimFriend
Messages: 313
Registered: July 2009
Senior Member
Hi,

I'm wondering if there is a way ((static) utility method or something
like this) for creating a String from a model object according to the
grammar. That is, I want to print out my model elements according to the
grammer, mainly for debugging purposes. In some cases, I do not have an
Xtext text file but only the model elements.

I figure it should be possible to use the generated parse tree
constructor to achieve that, isn't it? (I do not need the formatter).
Before I start digging into the constructor, I was wondering if some
kind of utility class doing exactly this already exists?

Actually, what I want to do is to replace the generated toString()
methods in my model implementation with this grammar like output. Maybe
there is a hidden switch to even enable that? Or do I have to do this
myself, e.g. by implementing a post processor transformation adding the
toString body to the model elements?

Cheers,

Jens
Re: [Xtext] implement toString() with the ParseTreeConstructor [message #659266 is a reply to message #659244] Fri, 11 March 2011 17:48 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Did you look at Serialization? - it produces text/string from the model.

- henrik

On 3/11/11 4:54 PM, Jens v.P. wrote:
> Hi,
>
> I'm wondering if there is a way ((static) utility method or something
> like this) for creating a String from a model object according to the
> grammar. That is, I want to print out my model elements according to the
> grammer, mainly for debugging purposes. In some cases, I do not have an
> Xtext text file but only the model elements.
>
> I figure it should be possible to use the generated parse tree
> constructor to achieve that, isn't it? (I do not need the formatter).
> Before I start digging into the constructor, I was wondering if some
> kind of utility class doing exactly this already exists?
>
> Actually, what I want to do is to replace the generated toString()
> methods in my model implementation with this grammar like output. Maybe
> there is a hidden switch to even enable that? Or do I have to do this
> myself, e.g. by implementing a post processor transformation adding the
> toString body to the model elements?
>
> Cheers,
>
> Jens
Re: [Xtext] implement toString() with the ParseTreeConstructor [message #659579 is a reply to message #659266] Mon, 14 March 2011 16:00 Go to previous message
Jens von Pilgrim is currently offline Jens von PilgrimFriend
Messages: 313
Registered: July 2009
Senior Member
On 11.03.11 18:48, Henrik Lindberg wrote:
> Did you look at Serialization? - it produces text/string from the model.

Here is my solution:

http://jevopisdeveloperblog.blogspot.com/2011/03/implement-t ostring-with-xtexts.html

Cheers,
Jens
Previous Topic:Increasing memory consumption
Next Topic:Changing the DSL file extension
Goto Forum:
  


Current Time: Tue Mar 19 02:29:21 GMT 2024

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

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

Back to the top