data type rule - list [message #685923] |
Mon, 20 June 2011 19:11 |
Bruce L. Messages: 81 Registered: June 2011 |
Member |
|
|
Hi,
suppose a section of my grammar looks like this:
Vector3 :
'('FLOAT','FLOAT','FLOAT')';
terminal FLOAT returns ecore::EFloat : ('+'?|'-')('0'..'9')*'.'('0'..'9')+;
I'd like a Vector3 object to be some kind of a list.
I wrote my value converter that transforms the parsed string to a java::util::ArrayList<double>, and successfully registered it (thanks to Petter Graff and its blog)
Then I realized that my data type rule return an EString by default, whatever my value converter, so I added a returns:
Vector3 returns ecore::EJavaObject :
'('FLOAT','FLOAT','FLOAT')';
Is there any better way instead the hack of using an EJavaObject?
I mean, what is the preferred way to get lists out of some parser rule?
I'd like to be able to handle the data as a list in the xpand/xtend files, for code generation.
The ecore::EJavaObject works, I can see that in the generated java code there is 'Object', but how can I exploit this in the template file? I am not able to "import" java.util.List or similar.
I know there could be easier ways, like modelling a Vector3 with three properties x, y, z (and no list at all), but this is just an example; I'd like to learn how to proper exploit data type rules for "complex" types, from the grammar to the code generation step.
Thank you
B
|
|
|
|
|
Re: data type rule - list [message #686015 is a reply to message #685975] |
Tue, 21 June 2011 11:40 |
|
Hi,
the emf registry metamodel should be not nonger relevant if you use JavaBeansMetamodel (Default) in you Xpand Code generator.
this Generator then should work with the Java Class you assign to the Datatype. So in your case you may have to crate a own ecore model (+ generate its java classes) for you complex datatypes mapping to a java class that fulfils your requirements.
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Powered by
FUDForum. Page generated in 0.03873 seconds