[TCS] Examples that convert .tcs file to model [message #17718] |
Thu, 22 February 2007 16:40 |
Eclipse User |
|
|
|
Originally posted by: paul.gribben.gmail.com
Hi, sorry if I've used the wrong group for this question.
I'm looking for any working example that converts a source .tcs file into
a TCS conformant model file. I'd also be interested to know whether TCS is
good choice for converting from models to concrete text (I won't need to
go from text to model), or should I use another approach?
|
|
|
|
|
Re: [TCS] Examples that convert .tcs file to model [message #18471 is a reply to message #17739] |
Fri, 23 February 2007 10:05 |
Eclipse User |
|
|
|
Originally posted by: paul.gribben.gmail.com
Thanks for this sample Freddy, it works fine.
I've extended my project copy by defining a metamodel for the AddressBook
by handcrafting an AddressBook.km3 (reverse-engineered from the
AddressBook.tcs, is there a more clever way to produce the metamodel?).
I've then successfully extracted a model file (AddressBook1.ecore) to a
text file (AddressBook1.out) using the ant task am3.saveModel (with
extractor embedded element).
I then tried to transform the text file back to a model file using the
am3.loadModel with injector approach, but without success as follows:
<target name="text2model" depends="loadModels">
<am3.loadModel modelHandler="EMF" name="M" metamodel="AddressBook.tcs"
path="${path}output/AddressBook1.out">
<injector name="ebnf">
<param name="name" value="TCS"/>
<classpath>
<pathelement location="${path}TCS/TCS-importer.jar" />
</classpath>
</injector>
</am3.loadModel>
<am3.saveModel model="M"
path="${path}output/GeneratedAddressBook1.ecore"/>
</target>
... where metamodel AddressBook.tcs is defined to be the
AddressBook.tcs.ecore file.
When I execute this I get:
text2model:
[am3.loadModel] Loading of model M
[am3.loadModel] no type named 'ConcreteSyntax' in metamodel
'AddressBook.tcs'
[am3.loadModel] java.lang.NullPointerException
[am3.loadModel] at
org.atl.engine.repositories.emf4atl.ASMEMFModel.newModelElem ent(ASMEMFModel.java:206)
[am3.loadModel] at
org.atl.engine.vm.nativelib.ASMModel.newModelElement(ASMMode l.java:74)
[am3.loadModel] at
org.atl.engine.vm.nativelib.ASMModel.newModelElement(ASMMode l.java:62)
(stack continues...)
I've examined the AddressBook.tcs.ecore and it does contain the
ConcreteSyntax type, so I'm a bit confused.
Again, any help would be greatly appreciated.
Thanks
Paul
|
|
|
Re: [TCS] Examples that convert .tcs file to model [message #18510 is a reply to message #18471] |
Fri, 23 February 2007 14:14 |
Eclipse User |
|
|
|
Originally posted by: Hugo.Bruneliere.univ-nantes.fr
Hi Paul,
Paul Gribben a écrit :
> Thanks for this sample Freddy, it works fine.
>
> I've extended my project copy by defining a metamodel for the
> AddressBook by handcrafting an AddressBook.km3 (reverse-engineered from
> the AddressBook.tcs, is there a more clever way to produce the
> metamodel?). I've then successfully extracted a model file
You could define your metamodel directly in KM3 (which is a Domain
Specific Language or DSL for defining metamodels) and then automatically
transform it into other formats such as Ecore for example.
> (AddressBook1.ecore) to a text file (AddressBook1.out) using the ant
> task am3.saveModel (with extractor embedded element).
>
> I then tried to transform the text file back to a model file using the
> am3.loadModel with injector approach, but without success as follows:
>
> <target name="text2model" depends="loadModels">
> <am3.loadModel modelHandler="EMF" name="M" metamodel="AddressBook.tcs"
> path="${path}output/AddressBook1.out">
> <injector name="ebnf">
> <param name="name" value="TCS"/>
> <classpath>
> <pathelement location="${path}TCS/TCS-importer.jar" />
> </classpath>
> </injector>
> </am3.loadModel>
I think the error comes from the value of the "metamodel" parameter of
the am3.loadModel task. For instance, it may be metamodel="AddressBook"
if you already have loaded the AddressBook metamodel like this:
<am3.loadModel modelHandler="EMF" name="AddressBook" metamodel="MOF"
path="AddressBook.ecore" />
Regards,
Hugo
>
> <am3.saveModel model="M"
> path="${path}output/GeneratedAddressBook1.ecore"/>
> </target>
>
> .. where metamodel AddressBook.tcs is defined to be the
> AddressBook.tcs.ecore file.
>
> When I execute this I get:
> text2model:
> [am3.loadModel] Loading of model M
> [am3.loadModel] no type named 'ConcreteSyntax' in metamodel
> 'AddressBook.tcs'
> [am3.loadModel] java.lang.NullPointerException
> [am3.loadModel] at
> org.atl.engine.repositories.emf4atl.ASMEMFModel.newModelElem ent(ASMEMFModel.java:206)
>
> [am3.loadModel] at
> org.atl.engine.vm.nativelib.ASMModel.newModelElement(ASMMode l.java:74)
> [am3.loadModel] at
> org.atl.engine.vm.nativelib.ASMModel.newModelElement(ASMMode l.java:62)
> (stack continues...)
>
> I've examined the AddressBook.tcs.ecore and it does contain the
> ConcreteSyntax type, so I'm a bit confused.
>
> Again, any help would be greatly appreciated.
>
> Thanks
> Paul
>
--
--------------------------------------------------------
Hugo Bruneliere - R&D Engineer
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssiniere
44322 Nantes Cedex 3 - France
office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
EMail: Hugo.Bruneliere@univ-nantes.fr
http://www.sciences.univ-nantes.fr/lina/atl/
--------------------------------------------------------
|
|
|
Re: [TCS] Examples that convert .tcs file to model [message #18527 is a reply to message #18510] |
Fri, 23 February 2007 15:49 |
Eclipse User |
|
|
|
Originally posted by: paul.gribben.gmail.com
Hugo,
Thanks for your reply. Unfortunately changing the metamodel as you
suggested has resulted in the same type of error (no type named
'ConcreteSyntax' in metamodel 'AddressBook').
I suspect the injector is expecting to find the TCS metamodel. If that's
the case then I wonder how I can load a text file using my metamodel.
Paul
|
|
|
Re: [TCS] Examples that convert .tcs file to model [message #18603 is a reply to message #18471] |
Mon, 26 February 2007 22:11 |
Eclipse User |
|
|
|
Originally posted by: freddy.allilaire.univ-nantes.fr
Hi Paul,
Paul Gribben a écrit :
> Thanks for this sample Freddy, it works fine.
>
> I've extended my project copy by defining a metamodel for the
> AddressBook by handcrafting an AddressBook.km3 (reverse-engineered from
> the AddressBook.tcs, is there a more clever way to produce the
> metamodel?).
The normal process is to create first your metamodel ;-)
> I've then successfully extracted a model file
> (AddressBook1.ecore) to a text file (AddressBook1.out) using the ant
> task am3.saveModel (with extractor embedded element).
>
> I then tried to transform the text file back to a model file using the
> am3.loadModel with injector approach, but without success as follows:
>
> <target name="text2model" depends="loadModels">
> <am3.loadModel modelHandler="EMF" name="M" metamodel="AddressBook.tcs"
> path="${path}output/AddressBook1.out">
> <injector name="ebnf">
> <param name="name" value="TCS"/>
> <classpath>
> <pathelement location="${path}TCS/TCS-importer.jar" />
> </classpath>
> </injector>
> </am3.loadModel>
>
> <am3.saveModel model="M"
> path="${path}output/GeneratedAddressBook1.ecore"/>
> </target>
>
> .. where metamodel AddressBook.tcs is defined to be the
> AddressBook.tcs.ecore file.
>
In this case (text to model), you will need to generate and to use a
"specific" AddressBook injector (i.e. AddressBook-importer.jar).
I have created a complete TCS use case for AddressBook available here:
http://www.eclipse.org/gmt/am3/tcs/download/TCSSample.zip
And I have also started a tutorial:
http://wiki.eclipse.org/index.php/TCS/TCS_Toolkit_Tutorial
For the moment, this wiki page is only a stub. But I hope this can help
you :-)
Regards,
Freddy.
> When I execute this I get:
> text2model:
> [am3.loadModel] Loading of model M
> [am3.loadModel] no type named 'ConcreteSyntax' in metamodel
> 'AddressBook.tcs'
> [am3.loadModel] java.lang.NullPointerException
> [am3.loadModel] at
> org.atl.engine.repositories.emf4atl.ASMEMFModel.newModelElem ent(ASMEMFModel.java:206)
>
> [am3.loadModel] at
> org.atl.engine.vm.nativelib.ASMModel.newModelElement(ASMMode l.java:74)
> [am3.loadModel] at
> org.atl.engine.vm.nativelib.ASMModel.newModelElement(ASMMode l.java:62)
> (stack continues...)
>
> I've examined the AddressBook.tcs.ecore and it does contain the
> ConcreteSyntax type, so I'm a bit confused.
>
> Again, any help would be greatly appreciated.
>
> Thanks
> Paul
>
|
|
|
Powered by
FUDForum. Page generated in 0.03796 seconds