Infer questions [message #996507] |
Wed, 02 January 2013 08:50 |
|
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 #997097 is a reply to message #996507] |
Thu, 03 January 2013 16:41 |
|
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 #997165 is a reply to message #996507] |
Fri, 04 January 2013 08:49 |
|
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 #997874 is a reply to message #997165] |
Tue, 08 January 2013 23:02 |
|
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
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
|
Powered by
FUDForum. Page generated in 0.04530 seconds