Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Code generator for Smalljava example
Code generator for Smalljava example [message #1690311] Thu, 26 March 2015 14:34 Go to next message
Som 2015 is currently offline Som 2015Friend
Messages: 16
Registered: March 2015
Junior Member
Hello all

I was wondering whether there is a code generator for Smalljava example of the book, to generate actual Java code from the examples.

Thanks
Re: Code generator for Smalljava example [message #1690313 is a reply to message #1690311] Thu, 26 March 2015 14:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13876
Registered: July 2009
Senior Member
No there is not. but it should not be too much work to create one

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 26 March 2015 14:38]

Report message to a moderator

Re: Code generator for Smalljava example [message #1690314 is a reply to message #1690313] Thu, 26 March 2015 14:41 Go to previous messageGo to next message
Som 2015 is currently offline Som 2015Friend
Messages: 16
Registered: March 2015
Junior Member
Thanks, in fact I am trying to make one. When it comes to generate code from expressions, I do not know how to access information about statements within the body of the methods. Can you give an example?

public class «it.name» {
«FOR m:it.members»
«IF m instanceof SJField»
«m.access.literal» «m.type.name» «m.name»;
«ELSE»
«IF m instanceof SJMethod»
«m.access.literal» «m.type.name» «m.name» (
«FOR p:m.params»
«p.type.name» «p.name» ,
«ENDFOR»

) {
«FOR s: m.body.statements»
//Can you give an example how to generate code for one statement....
«ENDFOR»
}
«ENDIF»
Re: Code generator for Smalljava example [message #1690316 is a reply to message #1690314] Thu, 26 March 2015 14:48 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13876
Registered: July 2009
Senior Member
Hi have a look at the dispatch methods in Xtend


def dispatch toJavaStatement(SJVariableDeclaration it) '''
//TODO
'''
def dispatch toJavaStatement(SJReturn it) '''
return «expression.toJavaStatement»;
'''
def dispatch toJavaStatement(SJStringConstant it) '''
"«value»"
'''
//TODO other SJExpressions

def dispatch toJavaStatement(SJIfStatement it) '''
//TODO
'''


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:cann't reference the instance in jar file or classpath model
Next Topic:Logical expressions within XExpressionOrVarDeclaration
Goto Forum:
  


Current Time: Sun Apr 11 05:25:10 GMT 2021

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

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

Back to the top