Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Model manipulation with ANTLR transformatons.
Model manipulation with ANTLR transformatons. [message #428117] Wed, 11 March 2009 11:28 Go to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hi there,

I would like to ask some advise, on what I want to accomplish.

I have defined a scripting language in ANTLR, which when executed should
perform operations on an EMF model. (Taking a feature, doing some
operation changing the feature value and storing it back in the EMF
model). This script DSL is a simplified version of java with basic
constructs.

My approach is to let the generated ANTLR parser generate templates
(Using ANTLR StringTemplate), which can be used to generate code which
can query and update the EMF model.

But what should this code be?, I am thinking about generating OCL or EMF
queries or even accessing the model with reflections. My question is:

- Has anyone gone this path before?
- What would be the best option OCL or EMF Queries? (Performance,
functionality wise..?).


Note: The reason, I use an ANTLR parser, is that the user can write the
scripts from within the application, which the grammar parser will
process and execute in runtime. (So the scripts are not part of the
build and very dynamic). The fact these are long sequences of
operations, I don't see the alternative of using OCL. Or perhaps SQL
could be used to query the DB directly, but this would be an ugly hack,
sidetracking EMF completely for Operations.

Any thoughts on this?
Thank you.
Re: Model manipulation with ANTLR transformatons. [message #428122 is a reply to message #428117] Wed, 11 March 2009 12:21 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Christophe,

Comments below.


Christophe Bouhier wrote:
> Hi there,
>
> I would like to ask some advise, on what I want to accomplish.
>
> I have defined a scripting language in ANTLR, which when executed should
> perform operations on an EMF model. (Taking a feature, doing some
> operation changing the feature value and storing it back in the EMF
> model). This script DSL is a simplified version of java with basic
> constructs.
>
> My approach is to let the generated ANTLR parser generate templates
> (Using ANTLR StringTemplate), which can be used to generate code which
> can query and update the EMF model.
>
> But what should this code be?, I am thinking about generating OCL or
> EMF queries or even accessing the model with reflections. My question
> is:
>
> - Has anyone gone this path before?
> - What would be the best option OCL or EMF Queries? (Performance,
> functionality wise..?).
I think EMF Query is not a good choice.
>
>
> Note: The reason, I use an ANTLR parser, is that the user can write
> the scripts from within the application, which the grammar parser will
> process and execute in runtime.
Have you looked into Xtext?
> (So the scripts are not part of the build and very dynamic). The fact
> these are long sequences of operations, I don't see the alternative of
> using OCL. Or perhaps SQL
> could be used to query the DB directly, but this would be an ugly hack,
> sidetracking EMF completely for Operations.
Have you considered interpreting your representation of the script
directly. That's effectively what OCL does...
>
> Any thoughts on this?
> Thank you.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Model manipulation with ANTLR transformatons. [message #428125 is a reply to message #428122] Wed, 11 March 2009 13:31 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
I didn't know about XText, It looks tough the intent, is to generate a
model from a DSL. I am not generating a model, but acting on it. The
XText grammar looks very similar to ANTLR, perhaps a derivate?
Overall it's probably a good choice, to get started quickly.

Thanks for pointing this out!

Cheers Christophe



Ed Merks wrote:
> Christophe,
>
> Comments below.
>
>
> Christophe Bouhier wrote:
>> Hi there,
>>
>> I would like to ask some advise, on what I want to accomplish.
>>
>> I have defined a scripting language in ANTLR, which when executed should
>> perform operations on an EMF model. (Taking a feature, doing some
>> operation changing the feature value and storing it back in the EMF
>> model). This script DSL is a simplified version of java with basic
>> constructs.
>>
>> My approach is to let the generated ANTLR parser generate templates
>> (Using ANTLR StringTemplate), which can be used to generate code which
>> can query and update the EMF model.
>>
>> But what should this code be?, I am thinking about generating OCL or
>> EMF queries or even accessing the model with reflections. My question
>> is:
>>
>> - Has anyone gone this path before?
>> - What would be the best option OCL or EMF Queries? (Performance,
>> functionality wise..?).
> I think EMF Query is not a good choice.
>>
>>
>> Note: The reason, I use an ANTLR parser, is that the user can write
>> the scripts from within the application, which the grammar parser will
>> process and execute in runtime.
> Have you looked into Xtext?
>> (So the scripts are not part of the build and very dynamic). The fact
>> these are long sequences of operations, I don't see the alternative of
>> using OCL. Or perhaps SQL
>> could be used to query the DB directly, but this would be an ugly hack,
>> sidetracking EMF completely for Operations.
> Have you considered interpreting your representation of the script
> directly. That's effectively what OCL does...
>>
>> Any thoughts on this?
>> Thank you.
Re: Model manipulation with ANTLR transformatons. [message #428126 is a reply to message #428125] Wed, 11 March 2009 13:41 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Christophe,

But the point is that if you map your DSL onto a model, then you'll be
able to interpret that model against an EMF model. After all, what's
OCL doing. It's mapping a textual DSL onto a model (the OCL model) and
then interpreting that model against some other Ecore/UML model. It
sounds like that's exactly what you're doing, although you're thinking
about mapping your script "model" onto another model, like OCL or Java,
rather than interpreting it directly.


Christophe Bouhier wrote:
> I didn't know about XText, It looks tough the intent, is to generate a
> model from a DSL. I am not generating a model, but acting on it. The
> XText grammar looks very similar to ANTLR, perhaps a derivate?
> Overall it's probably a good choice, to get started quickly.
>
> Thanks for pointing this out!
>
> Cheers Christophe
>
>
>
> Ed Merks wrote:
>> Christophe,
>>
>> Comments below.
>>
>>
>> Christophe Bouhier wrote:
>>> Hi there,
>>>
>>> I would like to ask some advise, on what I want to accomplish.
>>>
>>> I have defined a scripting language in ANTLR, which when executed
>>> should
>>> perform operations on an EMF model. (Taking a feature, doing some
>>> operation changing the feature value and storing it back in the EMF
>>> model). This script DSL is a simplified version of java with basic
>>> constructs.
>>>
>>> My approach is to let the generated ANTLR parser generate templates
>>> (Using ANTLR StringTemplate), which can be used to generate code
>>> which can query and update the EMF model.
>>>
>>> But what should this code be?, I am thinking about generating OCL or
>>> EMF queries or even accessing the model with reflections. My
>>> question is:
>>>
>>> - Has anyone gone this path before?
>>> - What would be the best option OCL or EMF Queries? (Performance,
>>> functionality wise..?).
>> I think EMF Query is not a good choice.
>>>
>>>
>>> Note: The reason, I use an ANTLR parser, is that the user can write
>>> the scripts from within the application, which the grammar parser
>>> will process and execute in runtime.
>> Have you looked into Xtext?
>>> (So the scripts are not part of the build and very dynamic). The
>>> fact these are long sequences of operations, I don't see the
>>> alternative of using OCL. Or perhaps SQL
>>> could be used to query the DB directly, but this would be an ugly hack,
>>> sidetracking EMF completely for Operations.
>> Have you considered interpreting your representation of the script
>> directly. That's effectively what OCL does...
>>>
>>> Any thoughts on this?
>>> Thank you.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Model manipulation with ANTLR transformatons. [message #428164 is a reply to message #428126] Thu, 12 March 2009 11:04 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Ed,

Get your point.

I have looked a bit into OCL, and it's indeed what I need for the query
part. Still I can't ask the users of my applications to write scripts in
OCL directly. (It has to be more like a general purpose language).
Also OCL can't write to the model it seems. (I want side effects!), so
OCL is out for this it seems.

Ed, I need to ask you a much simpler question. After my reading and
understanding of all the various tools of the last couple of days.

I have a model and I want to read and write to it (When and where is not
known at compilation time). It seems the only option is transforming to
java code? Isn't there some sort of SQL to talk to EMF based models?
(Something I can transform to from my simple grammar?

Thanks for all your help. Cheers Christophe


Ed Merks wrote:
> Christophe,
>
> But the point is that if you map your DSL onto a model, then you'll be
> able to interpret that model against an EMF model. After all, what's
> OCL doing. It's mapping a textual DSL onto a model (the OCL model) and
> then interpreting that model against some other Ecore/UML model. It
> sounds like that's exactly what you're doing, although you're thinking
> about mapping your script "model" onto another model, like OCL or Java,
> rather than interpreting it directly.
>
>
> Christophe Bouhier wrote:
>> I didn't know about XText, It looks tough the intent, is to generate a
>> model from a DSL. I am not generating a model, but acting on it. The
>> XText grammar looks very similar to ANTLR, perhaps a derivate?
>> Overall it's probably a good choice, to get started quickly.
>>
>> Thanks for pointing this out!
>>
>> Cheers Christophe
>>
>>
>>
>> Ed Merks wrote:
>>> Christophe,
>>>
>>> Comments below.
>>>
>>>
>>> Christophe Bouhier wrote:
>>>> Hi there,
>>>>
>>>> I would like to ask some advise, on what I want to accomplish.
>>>>
>>>> I have defined a scripting language in ANTLR, which when executed
>>>> should
>>>> perform operations on an EMF model. (Taking a feature, doing some
>>>> operation changing the feature value and storing it back in the EMF
>>>> model). This script DSL is a simplified version of java with basic
>>>> constructs.
>>>>
>>>> My approach is to let the generated ANTLR parser generate templates
>>>> (Using ANTLR StringTemplate), which can be used to generate code
>>>> which can query and update the EMF model.
>>>>
>>>> But what should this code be?, I am thinking about generating OCL or
>>>> EMF queries or even accessing the model with reflections. My
>>>> question is:
>>>>
>>>> - Has anyone gone this path before?
>>>> - What would be the best option OCL or EMF Queries? (Performance,
>>>> functionality wise..?).
>>> I think EMF Query is not a good choice.
>>>>
>>>>
>>>> Note: The reason, I use an ANTLR parser, is that the user can write
>>>> the scripts from within the application, which the grammar parser
>>>> will process and execute in runtime.
>>> Have you looked into Xtext?
>>>> (So the scripts are not part of the build and very dynamic). The
>>>> fact these are long sequences of operations, I don't see the
>>>> alternative of using OCL. Or perhaps SQL
>>>> could be used to query the DB directly, but this would be an ugly hack,
>>>> sidetracking EMF completely for Operations.
>>> Have you considered interpreting your representation of the script
>>> directly. That's effectively what OCL does...
>>>>
>>>> Any thoughts on this?
>>>> Thank you.
Re: Model manipulation with ANTLR transformatons. [message #428171 is a reply to message #428164] Thu, 12 March 2009 14:34 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030404000801030200060900
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Christophe,

Comments below.

Christophe Bouhier wrote:
> Ed,
>
> Get your point.
>
> I have looked a bit into OCL, and it's indeed what I need for the
> query part. Still I can't ask the users of my applications to write
> scripts in OCL directly. (It has to be more like a general purpose
> language). Also OCL can't write to the model it seems. (I want side
> effects!), so OCL is out for this it seems.
>
> Ed, I need to ask you a much simpler question. After my reading and
> understanding of all the various tools of the last couple of days.
>
> I have a model and I want to read and write to it (When and where is
> not known at compilation time). It seems the only option is
> transforming to java code?
EMF supports dynamic models for which there is no generated code. When
working via the EObject/Ecore API, it doesn't matter if there is
generated code behind it.

http://www.ibm.com/developerworks/library/os-eclipse-dynamic emf/
http://www.devx.com/Java/Article/29093/0/page/1

In the Sample Ecore Editor, just trying invoking "Create Dynamic
Instance..." on any EClass...
> Isn't there some sort of SQL to talk to EMF based models?
EObject is the way to "talk to" any modeled instance. Additional query
mechanisms can be built on that layer.
> (Something I can transform to from my simple grammar?
I keep thinking your notation should be represented as a model and then
interpretted dynamically again the EMF reflective API (like is done for
OCL). I recall on the e4 mailing list someone saying that had EMF Rhino
integration...
>
> Thanks for all your help. Cheers Christophe
>
>
> Ed Merks wrote:
>> Christophe,
>>
>> But the point is that if you map your DSL onto a model, then you'll
>> be able to interpret that model against an EMF model. After all,
>> what's OCL doing. It's mapping a textual DSL onto a model (the OCL
>> model) and then interpreting that model against some other Ecore/UML
>> model. It sounds like that's exactly what you're doing, although
>> you're thinking about mapping your script "model" onto another model,
>> like OCL or Java, rather than interpreting it directly.
>>
>>
>> Christophe Bouhier wrote:
>>> I didn't know about XText, It looks tough the intent, is to generate
>>> a model from a DSL. I am not generating a model, but acting on it.
>>> The XText grammar looks very similar to ANTLR, perhaps a derivate?
>>> Overall it's probably a good choice, to get started quickly.
>>>
>>> Thanks for pointing this out!
>>>
>>> Cheers Christophe
>>>
>>>
>>>
>>> Ed Merks wrote:
>>>> Christophe,
>>>>
>>>> Comments below.
>>>>
>>>>
>>>> Christophe Bouhier wrote:
>>>>> Hi there,
>>>>>
>>>>> I would like to ask some advise, on what I want to accomplish.
>>>>>
>>>>> I have defined a scripting language in ANTLR, which when executed
>>>>> should
>>>>> perform operations on an EMF model. (Taking a feature, doing some
>>>>> operation changing the feature value and storing it back in the
>>>>> EMF model). This script DSL is a simplified version of java with
>>>>> basic constructs.
>>>>>
>>>>> My approach is to let the generated ANTLR parser generate
>>>>> templates (Using ANTLR StringTemplate), which can be used to
>>>>> generate code which can query and update the EMF model.
>>>>>
>>>>> But what should this code be?, I am thinking about generating OCL
>>>>> or EMF queries or even accessing the model with reflections. My
>>>>> question is:
>>>>>
>>>>> - Has anyone gone this path before?
>>>>> - What would be the best option OCL or EMF Queries? (Performance,
>>>>> functionality wise..?).
>>>> I think EMF Query is not a good choice.
>>>>>
>>>>>
>>>>> Note: The reason, I use an ANTLR parser, is that the user can
>>>>> write the scripts from within the application, which the grammar
>>>>> parser will process and execute in runtime.
>>>> Have you looked into Xtext?
>>>>> (So the scripts are not part of the build and very dynamic). The
>>>>> fact these are long sequences of operations, I don't see the
>>>>> alternative of using OCL. Or perhaps SQL
>>>>> could be used to query the DB directly, but this would be an ugly
>>>>> hack,
>>>>> sidetracking EMF completely for Operations.
>>>> Have you considered interpreting your representation of the script
>>>> directly. That's effectively what OCL does...
>>>>>
>>>>> Any thoughts on this?
>>>>> Thank you.

--------------030404000801030200060900
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Christophe,<br>
<br>
Comments below.<br>
<br>
Christophe Bouhier wrote:
<blockquote cite="mid:49B8EC24.601@gmail.com" type="cite">Ed,
<br>
<br>
Get your point.
<br>
<br>
I have looked a bit into OCL, and it's indeed what I need for the query
part. Still I can't ask the users of my applications to write scripts
in &nbsp;OCL directly. (It has to be more like a general purpose language).
Also OCL can't write to the model it seems. (I want side effects!), so
OCL is out for this it seems.
<br>
<br>
Ed, I need to ask you a much simpler question. After my reading and
understanding of all the various tools of the last couple of days.
<br>
<br>
I have a model and I want to read and write to it (When and where is
not known at compilation time). It seems the only option is
transforming to java code?</blockquote>
EMF supports dynamic models for which there is no generated code.&nbsp; When
working via the EObject/Ecore API, it doesn't matter if there is
generated code behind it.<br>
<blockquote><a
href=" http://www.ibm.com/developerworks/library/os-eclipse-dynamic emf/"> http://www.ibm.com/developerworks/library/os-eclipse-dynamic emf/</a><br>
<a href="http://www.devx.com/Java/Article/29093/0/page/1">http://www.devx.com/Java/Article/29093/0/page/1</a><br>
</blockquote>
In the Sample Ecore Editor, just trying invoking "Create Dynamic
Instance..." on any EClass...<br>
<blockquote cite="mid:49B8EC24.601@gmail.com" type="cite"> Isn't there
some sort of SQL to talk to EMF based models? </blockquote>
EObject is the way to "talk to" any modeled instance.&nbsp; Additional query
mechanisms can be built on that layer.<br>
<blockquote cite="mid:49B8EC24.601@gmail.com" type="cite">(Something I
can transform to from my simple grammar?
<br>
</blockquote>
I keep thinking your notation should be represented as a model and then
interpretted dynamically again the EMF reflective API (like is done for
OCL).&nbsp; I recall on the e4 mailing list someone saying that had EMF
Rhino integration...<br>
<blockquote cite="mid:49B8EC24.601@gmail.com" type="cite"><br>
Thanks for all your help. Cheers Christophe
<br>
<br>
<br>
Ed Merks wrote:
<br>
<blockquote type="cite">Christophe,
<br>
<br>
But the point is that if you map your DSL onto a model, then you'll be
able to interpret that model against an EMF model.&nbsp; After all, what's
OCL doing.&nbsp; It's mapping a textual DSL onto a model (the OCL model) and
then interpreting that model against some other Ecore/UML model.&nbsp; It
sounds like that's exactly what you're doing, although you're thinking
about mapping your script "model" onto another model, like OCL or Java,
rather than interpreting it directly.
<br>
<br>
<br>
Christophe Bouhier wrote:
<br>
<blockquote type="cite">I didn't know about XText, It looks tough
the intent, is to generate a model from a DSL. I am not generating a
model, but acting on it. The XText grammar looks very similar to ANTLR,
perhaps a derivate?
<br>
Overall it's probably a good choice, to get started quickly.
<br>
<br>
Thanks for pointing this out!
<br>
<br>
Cheers Christophe
<br>
<br>
<br>
<br>
Ed Merks wrote:
<br>
<blockquote type="cite">Christophe,
<br>
<br>
Comments below.
<br>
<br>
<br>
Christophe Bouhier wrote:
<br>
<blockquote type="cite">Hi there,
<br>
<br>
I would like to ask some advise, on what I want to accomplish.
<br>
<br>
I have defined a scripting language in ANTLR, which when executed
should
<br>
perform operations on an EMF model. (Taking a feature, doing some
operation changing the feature value and storing it back in the EMF
model). This script DSL is a simplified version of java with basic
constructs.
<br>
<br>
My approach is to let the generated ANTLR parser generate templates
(Using ANTLR StringTemplate), which can be used to generate code which
can query and update the EMF model.
<br>
<br>
But what should this code be?, I am thinking about generating OCL or
EMF&nbsp; queries or even accessing the model with reflections. My question
is:
<br>
<br>
- Has anyone gone this path before?
<br>
- What would be the best option OCL or EMF Queries? (Performance,
functionality wise..?).
<br>
</blockquote>
I think EMF Query is not a good choice.
<br>
<blockquote type="cite"><br>
<br>
Note: The reason, I use an ANTLR parser, is that the user can write the
scripts from within the application, which the grammar parser will
process and execute in runtime.
<br>
</blockquote>
Have you looked into Xtext?
<br>
<blockquote type="cite">(So the scripts are not part of the
build and very dynamic). The fact these are long sequences of
operations, I don't see the alternative of using OCL. Or perhaps SQL
<br>
could be used to query the DB directly, but this would be an ugly hack,
<br>
sidetracking EMF completely for Operations.
<br>
</blockquote>
Have you considered interpreting your representation of the script
directly.&nbsp;&nbsp; That's effectively what OCL does...
<br>
<blockquote type="cite"><br>
Any thoughts on this?
<br>
Thank you.
<br>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</body>
</html>

--------------030404000801030200060900--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Content assist for Text in GMF
Next Topic:[commercial, off-topic?] Need external review. Data models, meta-data and database integration for r
Goto Forum:
  


Current Time: Thu Apr 25 14:33:47 GMT 2024

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

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

Back to the top