Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMT (Generative Modeling Technologies) » Re: [ATL][TCS] String expression to ATL model
Re: [ATL][TCS] String expression to ATL model [message #607557] Mon, 10 September 2007 16:03
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member

Parsing an OCL expression into a model is the job of TCS, which is a GMT
component. I am therefore putting the GMT newsgroup in copy of this message.

You may use the AM3 ant tasks to invoke TCS.
See, for instance, the KM3 injection example at

Here is the code of this example.

<am3.loadModel modelHandler="EMF" name="IN" metamodel="KM3"
<injector name="ebnf">
<param name="name" value="KM3" />

Note that if you want to parse expressions only (i.e., not a complete
ATL program), then you need to specify this after a "-".
The production rule name is the class name with a lower case letter at
the beginning. Therefore, to parse an "OclExpression", it is

For intance:
<param name="name" value="ATL-oclExpression" />

If you need to invoke the ATL parser from within your transformation
(e.g., in a called rule), then you may make use of the inject operation:

String.inject(modelName : String, injectorName : String, parameters :
String) : OclAny

For instance:

'if s.contents.oclIsUndefined() then
Sequence {}
Sequence {s.contents.statement}
endif'.inject('OUT', 'ebnf2', 'ATL-oclExpression')

Note that 'ebnf2' is used here for historical reasons, whereas 'ebnf' is
used in the AM3 ant tasks.


Frédéric Jouault

Lorenzo wrote:
> Hello,
> I am working on a transformation that transform a TrML model to an ATL
> model using ATL language.
> During this transformation I need to transform String to ATL.
> An expression like
> if s.contents.oclIsUndefined() then
> Sequence {}
> else
> Sequence {s.contents.statement}
> endif
> I must transform it to
> <value xsi:type="ocl:IfExp" location="70:33-74:38">
> <thenExpression xsi:type="ocl:SequenceExp"
> location="71:41-71:52"/>
> <condition xsi:type="ocl:OperationCallExp"
> location="70:36-70:63" operationName="oclIsUndefined">
> <source xsi:type="ocl:NavigationOrAttributeCallExp"
> location="70:36-70:46" name="contents">
> <source xsi:type="ocl:VariableExp"
> location="70:36-70:37"
> referredVariable="/0/@elements.7/@inPattern/@elements.0"/>
> </source>
> </condition>
> <elseExpression xsi:type="ocl:SequenceExp"
> location="73:41-73:72">
> <elements xsi:type="ocl:NavigationOrAttributeCallExp"
> location="73:51-73:71" name="statement">
> <source xsi:type="ocl:NavigationOrAttributeCallExp"
> location="73:51-73:61" name="contents">
> <source xsi:type="ocl:VariableExp"
> location="73:51-73:52"
> referredVariable="/0/@elements.7/@inPattern/@elements.0"/>
> </source>
> </elements>
> </elseExpression>
> </value>
> I think that ATL injector can be useful. do you know where can I find
> atl injector sources that does the parsing of a String expression? And
> how can I use them in my atl file?
> If not, do you have another solution to do this transformation?
> Thanks a lot for your help,
> Best regards,
> Lorenzo
Previous Topic:Re: [ATL][TCS] String expression to ATL model
Next Topic:[OAW] Running java code from workflow
Goto Forum:

Current Time: Thu Nov 26 23:31:48 GMT 2015

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

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