[ATL]String expression to ATL model [message #59338] |
Fri, 24 August 2007 13:30 |
Eclipse User |
|
|
|
Originally posted by: enzofesta.hotmail.com
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
|
|
|
Re: [ATL][TCS] String expression to ATL model [message #61674 is a reply to message #59338] |
Mon, 10 September 2007 16:03 |
Frédéric Jouault Messages: 572 Registered: July 2009 |
Senior Member |
|
|
Hello,
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
http://wiki.eclipse.org/AM3_Ant_Tasks#Task_am3.loadModel
Here is the code of this example.
<am3.loadModel modelHandler="EMF" name="IN" metamodel="KM3"
path="/org.eclipse.am3.zoos.atlantic/Amble.km3">
<injector name="ebnf">
<param name="name" value="KM3" />
</injector>
</am3.loadModel>
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
"oclExpression".
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 {}
else
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.
Regards,
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
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03514 seconds