Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Code generation from DSL(Lorenzo Bettini book)
Code generation from DSL [message #1862440] Tue, 05 December 2023 15:08 Go to next message
Franz Fehringer is currently offline Franz FehringerFriend
Messages: 7
Registered: December 2023
Junior Member
I have a very basic question for which i cannot easily find an answer with google and here it goes:
Starting with https://github.com/LorenzoBettini/packtpub-xtext-book-2nd-examples/tree/master/org.example.entities.parent i want to do the DSL to java generation from the command line using a mwe2 workflow.
There are DSL examples (MyModel.entities) in generatormain.tests and standalone.tests and there is a Xtend generator EntitiesGenerator extends AbstractGenerator. It is possible to execute the EntitiesGenerator in both test projects, but mwe2 is not used here.
Is this (doing the DSL instance(s) to Java translation in a mwe2 workflow) a reasonable target and how do i achieve it?
Re: Code generation from DSL [message #1862444 is a reply to message #1862440] Tue, 05 December 2023 16:08 Go to previous messageGo to next message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 162
Registered: February 2016
Senior Member
Hello Franz!

You might take a look at the following article to get some inspiration:

https://goto40.github.io/self-dsl/xtext_deploy_command_line/

Hope that helps!
Tamás
Re: Code generation from DSL [message #1862451 is a reply to message #1862444] Tue, 05 December 2023 18:25 Go to previous messageGo to next message
Franz Fehringer is currently offline Franz FehringerFriend
Messages: 7
Registered: December 2023
Junior Member
Hi Tamás, this is a nice overview, but most of it is already in the LB book/code and it does not answer my question: Is there a short best practice solution utilizing a mwe2 workflow?
In fact there is a solution, i could write a generator implementing IWorkflowComponent where the generator is entered through invoke().
But that does not look like "best practice", is there perhaps something utilizing the mwe2 clauses language=, fragment=, or something i do not fully understand as of now?
Re: Code generation from DSL [message #1862456 is a reply to message #1862451] Wed, 06 December 2023 03:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14738
Registered: July 2009
Senior Member
I am not sure if I can follow you. Why do you want to use a workflow

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Code generation from DSL [message #1862459 is a reply to message #1862456] Wed, 06 December 2023 08:30 Go to previous messageGo to next message
Franz Fehringer is currently offline Franz FehringerFriend
Messages: 7
Registered: December 2023
Junior Member
A workflow can be easily executed with both eclipse and maven. And i would be a little surprised if this were not possible. If making the Generator a IWorkflowComponent is the only way to go (apart from the "standard" non mwe2 ways), then the discussion ends here.
But is it true? I know there are several non mwe2 ways to execute the generator. But i am curious about the possible mwe2 case.
What about language=, fragment=, bean=, IXtextGeneratorFragment, GeneratorComponent ...
Any possibility to latch in among them? Can IXtextGeneratorFragment, GeneratorComponent be reused by language developers or are they "internal use" only?
Re: Code generation from DSL [message #1862461 is a reply to message #1862459] Wed, 06 December 2023 08:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14738
Registered: July 2009
Senior Member
you basically need to provide your workflow component.
or use org.eclipse.xtext.generator.GeneratorComponent

IXtextGeneratorFragment etc are for Xtext grammar file => Xtext language code.

what is the problem with
org.eclipse.xtext.generator.GeneratorComponent


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Wed, 06 December 2023 08:50]

Report message to a moderator

Re: Code generation from DSL [message #1862463 is a reply to message #1862461] Wed, 06 December 2023 09:36 Go to previous messageGo to next message
Franz Fehringer is currently offline Franz FehringerFriend
Messages: 7
Registered: December 2023
Junior Member
There is no problem with GeneratorComponent apart from the one that it is not completely clear to me how to use it. Do you have a (simple) example? How do i (in the https://github.com/LorenzoBettini/packtpub-xtext-book-2nd-examples/tree/master/org.example.entities.parent case) get from MyModel.entities to generated Java code with the help of GeneratorComponent ?

[Updated on: Wed, 06 December 2023 09:37]

Report message to a moderator

Re: Code generation from DSL [message #1862464 is a reply to message #1862463] Wed, 06 December 2023 09:46 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14738
Registered: July 2009
Senior Member
https://github.com/search?q=GeneratorComponent+path%3A*.mwe2&type=code

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Code generation from DSL [message #1862465 is a reply to message #1862464] Wed, 06 December 2023 10:10 Go to previous message
Franz Fehringer is currently offline Franz FehringerFriend
Messages: 7
Registered: December 2023
Junior Member
Thx, i will have a look at it.
Previous Topic:Creating an XText based Product
Next Topic:Identity preservation in Xtend
Goto Forum:
  


Current Time: Thu Dec 26 22:17:52 GMT 2024

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

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

Back to the top