Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo 3 / MTL] Variables in MTL?
[Acceleo 3 / MTL] Variables in MTL? [message #634648] Fri, 22 October 2010 11:01 Go to next message
Eclipse UserFriend
Dear all,

Reading the MTL Standard (v1.0) I have found in one of its examples (Example 3, Annex A) a syntax construction that seems to be a sort of variable declaration. In the standard's example is used to create a counter.

As this feature would be very handy for me, I've tried to use this in Acceleo MTL, but I'm not able to avoid errors.

First, I tried to "copy and paste" the standard's example, but it didn't compiled. Then I discovered that if I changed the line

[TEMPLATE PUBLIC class_header (...) {int count = -1}]

by this other (1):

[TEMPLATE PUBLIC class_header (...) {count : Integer = -1}]

the MTL compiler accepted the line. This line seems to have the same effect than a FOR + LET instruction, since 'count' is visible inside of the loop's scope, and you can print it.

My problem is when I try to copy the part in which the counter is incremented. The standard's version is

[FOR (...) {count = count + 1;}]

but this raises a compilation error.

I've been trying different combinations without successful.

Is this feature supported in Acceleo MTL?

If so, what syntax should I use?

There is any way to use variables inside of MTL?


Thank you very much in advance.


Regards,
Emilio.
Re: [Acceleo 3 / MTL] Variables in MTL? [message #634659 is a reply to message #634648] Fri, 22 October 2010 11:50 Go to previous messageGo to next message
Eclipse UserFriend
Hi Emilio,
please refer to this old post:
http://www.eclipse.org/forums/index.php?t=msg&&th=19 986
and to my very recent post:
http://www.eclipse.org/forums/index.php?t=msg&th=198754

The use of variables in Acceleo seems indeed quite limited and a little tricky. Also remember that as described in the user guide, all variables are "final", i.e. they cannot be modified after they have been initialized. This generally means that you cannot "compute" a variable through a for loop, but you have to use a single OCL statement.
Re: [Acceleo 3 / MTL] Variables in MTL? [message #634720 is a reply to message #634659] Fri, 22 October 2010 16:25 Go to previous message
Eclipse UserFriend
Hi Simone,

Thank you for your fast answer, I hadn't seen this old post...

Actually, is just what I was asking for, so sorry for repeat issues in the forum.

It's a pity, because it would have been very handy.


Regards,
Emilio.


Previous Topic:[xpand] Xpand/MWE execution in runtime
Next Topic:[Acceleo] Can Acceleo support @text-explicit syntax ?
Goto Forum:
  


Current Time: Wed Jul 23 10:45:51 EDT 2025

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

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

Back to the top