Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Out of Order text generation
Out of Order text generation [message #727433] Wed, 21 September 2011 09:38 Go to next message
Ed Willink is currently offline Ed Willink
Messages: 4097
Registered: July 2009
Senior Member
Hi

Is there any mechanism for non-linear text emission?

For instance when generating Java code, the need for imports may be
detected and accumulated by an ImportManager, but, in a one pass
algorithm, the resulting imports must be emitted before detection.

The Mof2Text spec in 7.3 suggests that the FileBlock can be used as a
stack to change context. Perhaps a similar StringBlock could emulate a
'Program Section' accumulating contributions which are finally pasted
together.

[string body][emitBody()/][/string]
[string prefix][emitPrefix()/][/string]
[file ('useful')][prefix/][body/][/file]

Perhaps some query such as [emitImports(theImports)/] could be marked as
'late' or 'lazy' so that the invocation marks the insert point for the
late evaluation once theImports has been populated.

Regards

Ed Willink
Re: Out of Order text generation [message #727489 is a reply to message #727433] Wed, 21 September 2011 12:09 Go to previous messageGo to next message
Stephane Bouchet is currently offline Stephane Bouchet
Messages: 260
Registered: July 2009
Senior Member
Hi Ed,

we (EEF team) found a solution very similar to what you propose for the
EMF.Edit and EMF.Editor generation using Acceleo.

We do use a let block to generate body and then generates import block
before the body.

We reuse the EMF importManager to manage import calculation.

You can have a look to our templates here :
http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.emf/org.eclipse.emf.eef/plugins/org.eclipse.emf.eef.codegen.ecore/src/org/eclipse/emf/eef/codegen/ecore/edit/ItemProvider.mtl?view=markup&revision=1.7&root=Modeling_Project




Le 21/09/2011 11:38, Ed Willink a écrit :
> Hi
>
> Is there any mechanism for non-linear text emission?
>
> For instance when generating Java code, the need for imports may be
> detected and accumulated by an ImportManager, but, in a one pass
> algorithm, the resulting imports must be emitted before detection.
>
> The Mof2Text spec in 7.3 suggests that the FileBlock can be used as a
> stack to change context. Perhaps a similar StringBlock could emulate a
> 'Program Section' accumulating contributions which are finally pasted
> together.
>
> [string body][emitBody()/][/string]
> [string prefix][emitPrefix()/][/string]
> [file ('useful')][prefix/][body/][/file]
>
> Perhaps some query such as [emitImports(theImports)/] could be marked as
> 'late' or 'lazy' so that the invocation marks the insert point for the
> late evaluation once theImports has been populated.
>
> Regards
>
> Ed Willink
>
>


--
Cheers,

Stéphane Bouchet, OBEO
Re: Out of Order text generation [message #729288 is a reply to message #727489] Sun, 25 September 2011 18:49 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4097
Registered: July 2009
Senior Member
Hi Stephane

On 21/09/2011 13:09, stephane.bouchet@obeo.fr wrote:
> Hi Ed,
>
> we (EEF team) found a solution very similar to what you propose for
> the EMF.Edit and EMF.Editor generation using Acceleo.
>
> We do use a let block to generate body and then generates import block
> before the body.
That's really cool. Obvious really, and although not what the spec
says, it's what the spec could be clarified to say. What I wanted is
already there.

This just makes a template the same as a query with an implicit String
return, and support for polymorphic matching. Once queries have
polymorphic matching there will be even less difference.

Regards

ed Willink
Re: Out of Order text generation [message #730087 is a reply to message #727433] Tue, 27 September 2011 15:28 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4097
Registered: July 2009
Senior Member
Hi

I found that there is a really handy PreviewStrategy that exposes the
internal implementation of fileblocks as stringbuffers so that
generate() returns a map of 'filename' to 'filecontent'; just what's
needed for program sections.

Regards

Ed Willink

On 21/09/2011 10:38, Ed Willink wrote:
> Hi
>
> Is there any mechanism for non-linear text emission?
>
> For instance when generating Java code, the need for imports may be
> detected and accumulated by an ImportManager, but, in a one pass
> algorithm, the resulting imports must be emitted before detection.
>
> The Mof2Text spec in 7.3 suggests that the FileBlock can be used as a
> stack to change context. Perhaps a similar StringBlock could emulate a
> 'Program Section' accumulating contributions which are finally pasted
> together.
>
> [string body][emitBody()/][/string]
> [string prefix][emitPrefix()/][/string]
> [file ('useful')][prefix/][body/][/file]
>
> Perhaps some query such as [emitImports(theImports)/] could be marked
> as 'late' or 'lazy' so that the invocation marks the insert point for
> the late evaluation once theImports has been populated.
>
> Regards
>
> Ed Willink
>
>
Previous Topic:[acceleo 3.1] editor doesn't see inheritance
Next Topic:Modularizing an Acceleo transformation
Goto Forum:
  


Current Time: Fri Oct 24 15:47:02 GMT 2014

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

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