Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Running / Interpret the DSL
Running / Interpret the DSL [message #798439] Tue, 14 February 2012 17:48 Go to next message
Eclipse UserFriend
[new to xtext - so please bare with me]
OK, so now I have a simple defined DSL with all the features that one can
expect from an IDE!
But how can I re-use this generated infrastructure to actually execute / run
/ interpret my langauge files?
Preferably I would like to be able to execute both from within Eclipse and
from a command line set-up.

Any hint trick suggestion greatly appreciated.

Peter
Re: Running / Interpret the DSL [message #798488 is a reply to message #798439] Tue, 14 February 2012 18:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13412
Registered: July 2009
Senior Member
Hi,

welcome to Xtext.
your question is very unspecific so it is hard to give an answer.
here are some options

(1) you can call your processor when saving the model file e.g. using an IXtextBuilderParticipant
(2) you can call your processor explicitely e.g. like it is done for this code generator http://christiandietrich.wordpress.com/2011/10/15/xtext-calling-the-generator-from-a-context-menu/
(3) process your models standalone with a mwe2 workflow or via java app as described here: http://wiki.eclipse.org/Xtext/FAQ#How_do_I_load_my_model_in_a_standalone_Java_application.C2.A0.3F

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Running / Interpret the DSL [message #798580 is a reply to message #798488] Tue, 14 February 2012 21:27 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Thanks for prompt reply.

Here is want I want to achive:
- when in Eclipse and working in the XText generated editor / environment :
having the abilty to press a Run button to execute the code in the editor
and to get the output in the Eclipse Console
- when in command line mode (comamnd shell): enter java -cp mydsl.jar
mydsl.dsl (where mydsl.dsl is a text file with my 'code'), output to stdout

Pretty much like when you develop java code in Eclipse, you can run it
directly in the IDE, but you can also run the code at command prompt.

I would prefer it I can maintain the generated xtext plug-in structure and
simply do a export of the jar file (to mydsl.jar in my sample above).

Is it possible to achive this with xtext (run from Eclipse, run standalone
with the same plug-ins)? If not how can I make it in another way?

I did have a quick peek into the
http://wiki.eclipse.org/Xtext/FAQ#How_do_I_load_my_model_in_a_standalone_Java_application.C2.A0.3F
article and was
a bit surprised that the model defintion must be loaded. I would have
thought that all symbols etc where compiled into java code. - agian I'm new
to xtext / antlr etc.




//Peter





"Christian Dietrich" <forums-noreply@eclipse.org> skrev i meddelandet
news:jheaue$ts1$1@news.eclipse.org...
> Hi,
>
> welcome to Xtext.
> your question is very unspecific so it is hard to give an answer.
> here are some options
>
> (1) you can call your processor when saving the model file e.g. using an
> IXtextBuilderParticipant (2) you can call your processor explicitely e.g.
> like it is done for this code generator
> http://christiandietrich.wordpress.com/2011/10/15/xtext-calling-the-generator-from-a-context-menu/
> (3) process your models standalone with a mwe2 workflow or via java app as
> described here:
> http://wiki.eclipse.org/Xtext/FAQ#How_do_I_load_my_model_in_a_standalone_Java_application.C2.A0.3F
>
> ~Christian
Re: Running / Interpret the DSL [message #798593 is a reply to message #798580] Tue, 14 February 2012 21:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13412
Registered: July 2009
Senior Member
Hi,

it is a common pratice in eclipse to split between runtime/standalone and ui.
never the less it should be no problem to achieve this.

your point on the example from the wiki i do not understand.
what do you mean with "model defintion must be loaded"

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Running / Interpret the DSL [message #798623 is a reply to message #798580] Tue, 14 February 2012 22:47 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
I did exactly what you are after in the Eclipse b3 project - I
implemented running/interpreting in several different ways - running the
dirty state in the editor, running from dialogs/wizards (passing in
parameters), and much more.

There is a "run" menu extension IIRC in one of the ui components that
serves as an entry point into the functionality.

- henrik

On 2012-14-02 22:27, Peter S Eden wrote:
> Hi,
>
> Thanks for prompt reply.
>
> Here is want I want to achive:
> - when in Eclipse and working in the XText generated editor / environment :
> having the abilty to press a Run button to execute the code in the editor
> and to get the output in the Eclipse Console
> - when in command line mode (comamnd shell): enter java -cp mydsl.jar
> mydsl.dsl (where mydsl.dsl is a text file with my 'code'), output to stdout
>
> Pretty much like when you develop java code in Eclipse, you can run it
> directly in the IDE, but you can also run the code at command prompt.
>
> I would prefer it I can maintain the generated xtext plug-in structure and
> simply do a export of the jar file (to mydsl.jar in my sample above).
>
> Is it possible to achive this with xtext (run from Eclipse, run standalone
> with the same plug-ins)? If not how can I make it in another way?
>
> I did have a quick peek into the
> http://wiki.eclipse.org/Xtext/FAQ#How_do_I_load_my_model_in_a_standalone_Java_application.C2.A0.3F
> article and was
> a bit surprised that the model defintion must be loaded. I would have
> thought that all symbols etc where compiled into java code. - agian I'm new
> to xtext / antlr etc.
>
>
>
>
> //Peter
>
>
>
>
>
> "Christian Dietrich"<forums-noreply@eclipse.org> skrev i meddelandet
> news:jheaue$ts1$1@news.eclipse.org...
>> Hi,
>>
>> welcome to Xtext.
>> your question is very unspecific so it is hard to give an answer.
>> here are some options
>>
>> (1) you can call your processor when saving the model file e.g. using an
>> IXtextBuilderParticipant (2) you can call your processor explicitely e.g.
>> like it is done for this code generator
>> http://christiandietrich.wordpress.com/2011/10/15/xtext-calling-the-generator-from-a-context-menu/
>> (3) process your models standalone with a mwe2 workflow or via java app as
>> described here:
>> http://wiki.eclipse.org/Xtext/FAQ#How_do_I_load_my_model_in_a_standalone_Java_application.C2.A0.3F
>>
>> ~Christian
>
>
Re: Running / Interpret the DSL [message #799411 is a reply to message #798593] Wed, 15 February 2012 21:23 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
I was just a bit confused, but now I realize that the model is actually the
file with my language statments inside.

Peter


"Christian Dietrich" <forums-noreply@eclipse.org> skrev i meddelandet
news:jhekv6$h8i$1@news.eclipse.org...
> Hi,
>
> it is a common pratice in eclipse to split between runtime/standalone and
> ui.
> never the less it should be no problem to achieve this.
>
> your point on the example from the wiki i do not understand.
> what do you mean with "model defintion must be loaded"
>
> ~Christian
Re: Running / Interpret the DSL [message #811351 is a reply to message #799411] Fri, 02 March 2012 08:24 Go to previous messageGo to next message
Sergey K is currently offline Sergey KFriend
Messages: 2
Registered: March 2012
Junior Member
Hi Peter

From your question:
>> Here is want I want to achive:
>> - when in Eclipse and working in the XText generated editor / environment :
>> having the abilty to press a Run button to execute the code in the editor
>> and to get the output in the Eclipse Console

Honestly, I didn't understand from this topic - is it possible or not ?
and if it is possible - how to do this?

PS I understand that I can add generated src-gen to project and execute generated java classes as usual. But these action will be executed by DSL end-developer, and it will be great to hide this routine from his.
End-developer who uses DSL hasn't care about java routine (I mean adding src-gen to his own project and execute generated java classes) - He should have deals just with DSL and can execute it.

Regards,
Sergey

[Updated on: Fri, 02 March 2012 08:33]

Report message to a moderator

Re: Running / Interpret the DSL [message #811352 is a reply to message #811351] Fri, 02 March 2012 08:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13412
Registered: July 2009
Senior Member
Hi,

if you divide this into two parts
(1) running a generator/interpreter via button
(2) redirecting log to a eclipse console

it is possible
for (1) have a look at http://christiandietrich.wordpress.com/2011/10/15/xtext-calling-the-generator-from-a-context-menu/
for (2) which is not Xtext specific google (or bing or whatever) is your friend.

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Running / Interpret the DSL [message #813504 is a reply to message #811352] Mon, 05 March 2012 10:49 Go to previous message
Sergey K is currently offline Sergey KFriend
Messages: 2
Registered: March 2012
Junior Member
Thank you,
I just added JDT part (build and execution for generated code) and my task is resolved.
Previous Topic:[Xtext 1] How to serialize inter-model cross references, or, how to automatically generate input sta
Next Topic:M2M transformation reports
Goto Forum:
  


Current Time: Mon Mar 30 17:25:42 GMT 2020

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

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

Back to the top