Xtext interpreter to instantiate EMF Object [message #922747] |
Tue, 25 September 2012 05:40  |
Eclipse User |
|
|
|
Hello,
I have problem that I'm trying to solve using Xtext (I already have a working PoC in Groovy):
I have a huge meta model EMF, and a Xtext grammar generated from it.
The problem is that the resulting DSL is too complex for the user.
What I would like to do is, create a new grammar from scratch, that would describe a subset of the generated DSL and some specific keywords and have some kind of interpreter that would actually create EMF objects.
Example :
Wanted language:
Person (name="John" children+="Toto")
Existing language (mapping 1-1 with EMF Objects)
Person {
name = "John",
children {
Person{
name = "Toto"
}
}
}
Thank you.
Charles
|
|
|
|
|
|
|
|
|
Re: Xtext interpreter to instantiate EMF Object [message #940163 is a reply to message #940063] |
Thu, 11 October 2012 07:15  |
Eclipse User |
|
|
|
On 2012-11-10 11:21, Charles Bonneau wrote:
> Hello again,
> I've implemented 2 Proof of Concept to iterate over the model and
> evaluating it. One using the Switch generated by EMF:
>
> Class MyPersonSwitch extends PersonSwitch<bigModel.Person> {
> bigModel.Person casePerson (Person o){
> bigModel.Person p = bigModelFactory.eINSTANCE.createPerson();
> p.setName(o.getName());
> for (String name : o.getChildren()){
> bigModel.Person child = bigModelFactory.eINSTANCE.createPerson();
> child .setName(name);
> p.getChildren().add(child);
> }
> return p;
> } }
>
> and the other one using the PolymorphicDispatcher from Xtext as in
> cloudsmith/geppetto.
>
>
> From your point of view what is the best approach ?
The switch from EMF may run faster since it is not using reflection, but
it is not as flexible.
- henrik
|
|
|
Powered by
FUDForum. Page generated in 0.05961 seconds