Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Infer questions(Some useful questions about JvmModelInferrer)
icon5.gif  Infer questions [message #996507] Wed, 02 January 2013 08:50 Go to next message
Tommaso De Sica is currently offline Tommaso De SicaFriend
Messages: 131
Registered: March 2012
Location: Italy
Senior Member

Happy new year everyone!

I'm going to write an inferrer for my dsl and I have some questions that I could not solve with only the help of documentation.

First one:
I need to create static void main() from a feature: how can I add static with .toMethod()?

Second one:
Suppose I have a rule in my dsl like this:
Sequence:
	'SEQ' name=ID '{'
		statements+=Statement*
	'}'
;


Where Statement:
Statement:
	Sequence | others...
;


Sequence must be mapped to a void method and the body of that method is composed from the traslation of statements.
But the problem is this: when inside a Sequence I'll find another Sequence I have to create a method for the new sequence and add a call in super sequence.

For example:
SEQ first {
   instructions...
   SEQ second {
      other instructions....
   }
   instructions...
}


Must generate:
void first(){
   instructions(translated)...
   second();
   instructions(translated)...
}
void second(){
   other instructions(translated)...
}


Is it possible to realize it?

Very thank you, and have a good new year!
Re: Infer questions [message #996662 is a reply to message #996507] Wed, 02 January 2013 16:32 Go to previous messageGo to next message
Tommaso De Sica is currently offline Tommaso De SicaFriend
Messages: 131
Registered: March 2012
Location: Italy
Senior Member

Second question solved. Wink
Re: Infer questions [message #996673 is a reply to message #996662] Wed, 02 January 2013 16:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
members += f.toMethod(f.name, f.type) [
documentation = f.documentation
for (p : f.params) {
parameters += p.toParameter(p.name, p.parameterType)
}
body = f.body
^static = true
]


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Infer questions [message #996967 is a reply to message #996673] Thu, 03 January 2013 10:01 Go to previous messageGo to next message
Tommaso De Sica is currently offline Tommaso De SicaFriend
Messages: 131
Registered: March 2012
Location: Italy
Senior Member

Thanks!

But how can I create custom parameter type: I need to create String[] type for args
Re: Infer questions [message #996970 is a reply to message #996967] Thu, 03 January 2013 10:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

the class TypeReferences is helpful for such things (for creating arrays as well als for "get type by classname")


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Infer questions [message #997097 is a reply to message #996507] Thu, 03 January 2013 16:41 Go to previous messageGo to next message
Tommaso De Sica is currently offline Tommaso De SicaFriend
Messages: 131
Registered: March 2012
Location: Italy
Senior Member

Thanks again !

A little curiosity: my previous Xtext project doesn't use Xbase and generates C code. Do you think is possible to write a debugger for it?
Re: Infer questions [message #997112 is a reply to message #997097] Thu, 03 January 2013 18:30 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2013-03-01 17:41, Tommaso De Sica wrote:
> Thanks again !
>
> A little curiosity: my previous Xtext project doesn't use Xbase and
> generates C code. Do you think is possible to write a debugger for it?

I assume it would be possible, but the question is how easy it is. You
need to look at how the C debugger works in Eclipse.

Regards
- henrik
Re: Infer questions [message #997165 is a reply to message #996507] Fri, 04 January 2013 08:49 Go to previous messageGo to next message
Tommaso De Sica is currently offline Tommaso De SicaFriend
Messages: 131
Registered: March 2012
Location: Italy
Senior Member

And is it possible to debug a dsl that generate java code without using of Xbase?

In this way I can create a simulation environment in java for debug dsl and then (if all is ok), generate the C code.
Re: Infer questions [message #997169 is a reply to message #997165] Fri, 04 January 2013 09:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Everything is possible. It is just a matter Of effort you have To
invest (or what you do (not) get for free)

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Infer questions [message #997195 is a reply to message #997165] Fri, 04 January 2013 11:55 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2013-04-01 9:49, Tommaso De Sica wrote:
> And is it possible to debug a dsl that generate java code without using
> of Xbase?
>
> In this way I can create a simulation environment in java for debug dsl
> and then (if all is ok), generate the C code.
If you write an evaluator, and use the support in the Eclipse debugger
to write a debugger for an interpreter, then it is a moderate effort. If
you want to also step through called java logic in a seamless way, then
it is harder.

- henrik
Re: Infer questions [message #997874 is a reply to message #997165] Tue, 08 January 2013 23:02 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 01/04/2013 09:49 AM, Tommaso De Sica wrote:
> And is it possible to debug a dsl that generate java code without using
> of Xbase?
>
> In this way I can create a simulation environment in java for debug dsl
> and then (if all is ok), generate the C code.

Although I didn't make further experiments, in this project

https://github.com/LorenzoBettini/Xtext-Buckminster-Example

the grammar derives from Xbase, but basically does not use its rules
https://github.com/LorenzoBettini/Xtext-Buckminster-Example/blob/master/org.xtext.example.hellobuck/src/org/xtext/example/hellobuck/HelloBuck.xtext

(the DSL in this example is pretty stupid, since that was not the final
subject :)

it then uses the inferrer to generate Java code (you can use it also if
you don't use elements from Xbase):

https://github.com/LorenzoBettini/Xtext-Buckminster-Example/blob/master/org.xtext.example.hellobuck/src/org/xtext/example/hellobuck/jvmmodel/HelloBuckJvmModelInferrer.xtend

since the generation relies on the inferrer you should get also
debugging functionalities, but they are limited, I guess, to the Java
elements you map to your model elements, and for generated Java methods
you will have to deal with trace functionalities yourself (probably
taking inspiration from XbaseCompiler).

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: Infer questions [message #997933 is a reply to message #997165] Wed, 09 January 2013 02:28 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2013-04-01 9:49, Tommaso De Sica wrote:
> And is it possible to debug a dsl that generate java code without using
> of Xbase?
>
> In this way I can create a simulation environment in java for debug dsl
> and then (if all is ok), generate the C code.

Reading Lorenzos reply, I realized I may have misunderstood your question.
What is it you want to debug? The evaluation of the DSL model, or the
parsing/construction of the model (as done by Xtext). Or put
differently, do you want users of your DSL to be able to debug what they
have written, or do you want to debug the grammar (and model)?

Regards
- henrik
Previous Topic:Using toIterable.FindFirst in Generator
Next Topic:Content Assist stops working
Goto Forum:
  


Current Time: Wed Apr 24 18:13:07 GMT 2024

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

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

Back to the top