Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » No pre/post conditions in ETL?
No pre/post conditions in ETL? [message #900209] Sun, 05 August 2012 15:23 Go to next message
Fabian Hänsel is currently offline Fabian HänselFriend
Messages: 8
Registered: May 2012
Junior Member
Hej!

As I understand the Epsilon book, all the features of EOL should be
available in all its offspring languages, e.g. ETL. Is this correct so far?

I have a transformation which implements a simple mapping. I'm including
the sample add function from the Epsilon book, listing
3.7, annotated with a pre condition. The transformation does actually
never call the add function.

Already when typing, $pre gives me an Eclipse error marker in editor:

Multiple markers at this line
- required (...)+ loop did not match anything at input '$'
- mismatched input '>' expecting '{'

Running the transformation yields (reformatted for readability):

[epsilon.etl - minimalRevolution.etl] Line: whatever, Reason:

required (...)+ loop did not match anything at input '$'
required (...)+ loop did not match anything at input '$'
mismatched input '>' expecting '{'

The actual transformation is not run. Similar issue for post conditions.

Is this an error and I should open a bug report? Or did I miss something
and it's should not be expected to work (or in a different way)?

Thanks & best regards,
Fabian
Re: No pre/post conditions in ETL? [message #900326 is a reply to message #900209] Mon, 06 August 2012 13:46 Go to previous messageGo to next message
Horacio Hoyos is currently offline Horacio HoyosFriend
Messages: 156
Registered: October 2009
Senior Member

Hello Fabian,

If you look at section 5.4 in the Epsilon book you will find that in ETL pre and post conditions blocks have a different syntax:

(pre|post) <name> {
	statement+
}


I think the $pre/post syntax only works for EOL operations and in the rest of languages the ETL style applies.

Please let us know if this works for you.

Regards,



Horacio Hoyos Rodriguez
EngD Student
University Of York
Re: No pre/post conditions in ETL? [message #900354 is a reply to message #900326] Mon, 06 August 2012 15:24 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 310
Registered: January 2010
Senior Member
Hi Horacio,

Yes, that's pretty much it. I'd like to point out a few things, though: the $pre/$post annotations and the pre/post blocks have quite different semantics.

$pre/$post annotations are for Boolean preconditions and postconditions, and will produce errors if they are violated. They are only available in .eol and .egl scripts, as I have gathered from a quick look at the source code.

However, pre/post blocks are simply EOL blocks that will be run before and after anything in the global scope of the script. These should work for ETL, ECL, EML, EPL and EVL scripts. EOL scripts don't need them. Other languages may allow them in their grammars, but I believe they don't really run those blocks.

Regards,
Antonio
Re: No pre/post conditions in ETL? [message #901831 is a reply to message #900354] Tue, 14 August 2012 17:36 Go to previous messageGo to next message
Horacio Hoyos is currently offline Horacio HoyosFriend
Messages: 156
Registered: October 2009
Senior Member

Antonio,

Thanks for clarifing this. Probably this should go into the Epsilon book somewhere Wink

Regards,


Horacio Hoyos Rodriguez
EngD Student
University Of York
Re: No pre/post conditions in ETL? [message #901857 is a reply to message #900354] Tue, 14 August 2012 19:09 Go to previous messageGo to next message
Fabian Hänsel is currently offline Fabian HänselFriend
Messages: 8
Registered: May 2012
Junior Member
Hi Horacio,
Hi Antonio,

Thank you both for your answers! (Sorry for the late reply)

> $pre/$post annotations are for Boolean preconditions and
> postconditions, and will produce errors if they are violated. They
> are only available in .eol and .egl scripts,

That's the use I've been looking for in ETL, but just to get a grasp on
Epsilon, I don't actually need them (though they might become handy in
the future).

> as I have gathered from a quick look at the source code.

Maybe first sentence introducing the pre/post condition in subsection
3.2.2 of the Epsilon book could be changed from

"A number of the pre and post executable annotations can be attached to
EOL operations to specifiy the pre- and post-conditions of the operation."

to

"A number of the pre and post executable annotations can be attached to
EOL (as well as EGL) operations to specifiy the pre- and post-conditions
of the operation."

to save other users from the same wrong expectation.

> However, pre/post blocks are simply EOL blocks that will be run
> before and after anything in the global scope of the script.

I'm already using these blocks, but as suggested and intended for a
completely different use from the above one.

Thanks again for your answers!

Best regards
Fabian
Re: No pre/post conditions in ETL? [message #902245 is a reply to message #901857] Thu, 16 August 2012 14:02 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 310
Registered: January 2010
Senior Member
Hi Horacio, hi Fabian,

fabtagon . wrote on Tue, 14 August 2012 15:09

That's the use I've been looking for in ETL, but just to get a grasp on
Epsilon, I don't actually need them (though they might become handy in
the future).


It's a feature of EOL, which only EGL inherits, as it's the only language that also allows for user-defined operations. If you look at the others, they don't really allow for new operations: they define rules (Flock, ETL, ECL, EML, EPL) or invariants (EVL), which don't really work the same way.

fabtagon . wrote on Tue, 14 August 2012 15:09

Maybe first sentence introducing the pre/post condition in subsection
3.2.2 of the Epsilon book could be changed from

"A number of the pre and post executable annotations can be attached to
EOL operations to specifiy the pre- and post-conditions of the operation."

to

"A number of the pre and post executable annotations can be attached to
EOL (as well as EGL) operations to specifiy the pre- and post-conditions
of the operation."

to save other users from the same wrong expectation.


Thanks for the suggestion Smile. However, perhaps it may be too soon in the book to mention EGL (which is described in a later chapter). In any case, I've updated the book so it specifically mentions that EGL operations also support $pre/$post/@cached and that the pre/post blocks in the other languages should not be confused with the $pre/$post annotations. Would that be enough?

To keep things simple, the book doesn't mention ERL, which is the superset of EOL that ETL, EVL, EML, ECL and EPL are based on and that defines the infamous pre/post blocks Wink. It's not big enough to merit its own chapter, though.

fabtagon . wrote on Tue, 14 August 2012 15:09

Thanks again for your answers!


You're both welcome!
Antonio
Re: No pre/post conditions in ETL? [message #902462 is a reply to message #902245] Fri, 17 August 2012 17:47 Go to previous messageGo to next message
Fabian Hänsel is currently offline Fabian HänselFriend
Messages: 8
Registered: May 2012
Junior Member
On 16.08.2012 16:02, Antonio Garcia-Dominguez wrote:

> Thanks for the suggestion :). However, perhaps it may be too soon in the
> book to mention EGL (which is described in a later chapter). In any
> case, I've updated the book so it specifically mentions that EGL
> operations also support $pre/$post/@cached and that the pre/post blocks
> in the other languages should not be confused with the $pre/$post
> annotations. Would that be enough?

Agreed ;-)

Have a nice weekend
Fabian
Re: No pre/post conditions in ETL? [message #902919 is a reply to message #901857] Tue, 21 August 2012 07:43 Go to previous message
Horacio Hoyos is currently offline Horacio HoyosFriend
Messages: 156
Registered: October 2009
Senior Member

Fabian,

In ETL, an the other languages that support the pre/post block, you can get the boolean precondition/postcondition to work if you use the "throw()" operation. At least I remember a post of the forums talking about it. I think it works similar to a throw exception in java. So you can test for conditions in your pre/post blocks and throw an exception that will interrupt the ExL execution and give you a sound message of what went wrong.

Personally I believe that it would be better to create EVL rules to validate your input model(s) so that you can guarantee that the ExL rules will generate 'correct' output model(s).

Antonio,

Thanks for adding this information into the book.

Regards,


Horacio Hoyos Rodriguez
EngD Student
University Of York
Previous Topic:Editing models using ModeLink
Next Topic:org.eclipse.epsilon.commons installation problem
Goto Forum:
  


Current Time: Mon Dec 22 18:34:38 GMT 2014

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

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