Skip to main content



      Home
Home » Modeling » TMF (Xtext) » How to transform my dsl to more target languages?
How to transform my dsl to more target languages? [message #1440633] Wed, 08 October 2014 12:26 Go to next message
Eclipse UserFriend
I would like to transform my dsl to more target languages (java, javascript, python..), something like this:

def dispatch void infer or doGenerate(...){
switch(temp){
javascript:{
//transform to javascript, mydsl.js
}
python:{
//transform to python, mydsl.py
}
java:{
//transform to java, mydsl.java
}
}
}

Does anyone have any ideas?

Thank you in advance,
Marko
Re: How to transform my dsl to more target languages? [message #1440656 is a reply to message #1440633] Wed, 08 October 2014 13:08 Go to previous messageGo to next message
Eclipse UserFriend
Hi you can call FSA.generateFile AS often as you want. For a starting point have a look at the xtext tutorial
Re: How to transform my dsl to more target languages? [message #1441117 is a reply to message #1440656] Thu, 09 October 2014 05:28 Go to previous messageGo to next message
Eclipse UserFriend
Thank you Christian,

I use xbase and I have MyDslJvmModelInferrer, how can I use and infer and doGenerate(fsa.generateFile) in same time?

I tried to write class MyDslGenerator.xtend with doGenerate method and bind it in MyDslRuntimeModule
public Class<? extends IGenerator> bindIGenerator() {
return MyDslGenerator.class;
}

After that, it generated code which is specified by doGenerate method but it didn't generate code specified by infer method.

Best regards,

Marko
Re: How to transform my dsl to more target languages? [message #1441129 is a reply to message #1441117] Thu, 09 October 2014 05:43 Go to previous messageGo to next message
Eclipse UserFriend
I'm using both the ModelInferrer and the ModelGenerator. To enable this I followed an article on rcpVision (www.rcp-vision.com/?p=1640). I removed the http, because I'm not allowed to post links other than to eclipse.org urls
Re: How to transform my dsl to more target languages? [message #1441156 is a reply to message #1441129] Thu, 09 October 2014 06:31 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

you can subclass JvmModelGenerator
Re: How to transform my dsl to more target languages? [message #1441541 is a reply to message #1441156] Thu, 09 October 2014 18:07 Go to previous messageGo to next message
Eclipse UserFriend
Thank you Tobias and Christian,
Tobias I followed that article but I have problem. Next code snippet

def compile(XExpression xExpression, ImportManager importManager) {
val result = new StringBuilderBasedAppendable(importManager)
xbaseCompiler.toJavaStatement(xExpression, result, true)
result
}
has error "Type mismatch: cannot convert from StringBuilderBasedAppendable to ITreeAppendable"

Christian, I think I didn't understand your reply.

Thank you on your reply in advance,

Marko



Re: How to transform my dsl to more target languages? [message #1441709 is a reply to message #1441541] Fri, 10 October 2014 00:24 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

the model that is created by the jvmmodelinferrer is translated into java source code by the jvmmodelgenerator.
so if you want to hook into that process you can subclass jvmmodelgenerator, hook into doGenerate and bind it as IGenerator.
Re: How to transform my dsl to more target languages? [message #1444846 is a reply to message #1441129] Tue, 14 October 2014 12:28 Go to previous message
Eclipse UserFriend
On 09/10/2014 11:43, Tobias Wink wrote:
> I'm using both the ModelInferrer and the ModelGenerator. To enable this
> I followed an article on rcpVision (www.rcp-vision.com/?p=1640). I
> removed the http, because I'm not allowed to post links other than to
> eclipse.org urls

Hi

I wrote that article, but that's rather old now, especially now that
Xbase evolved in such a way that the approach described in that article
does not work anymore :)

you should really implement the model inferrer so that the Xbase
typesystem works, and let the JvmModelGenerator do all the rest.

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
Previous Topic:Access AST generated in Xtexteditor
Next Topic:Concept to avoid lengthy generator steps?
Goto Forum:
  


Current Time: Sat Jul 05 04:30:27 EDT 2025

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

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

Back to the top