Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Generating c code with xtext(I need a simple example that shows how to)
Generating c code with xtext [message #1266423] Fri, 07 March 2014 12:39 Go to next message
Antonis P. is currently offline Antonis P.Friend
Messages: 4
Registered: March 2014
Junior Member
Hello all,
I want to generate c code from a dsl.
I can't find somewhere resources that shows a way to generate something following my
requirements which I will analyse in the following lines.

In the following lines I will give more informations:
Lets say that I have the following dsl program.
a; b; c; //three statements
and for those statements I want to generate an other program with the statements
A; B; C. And I want this file to have an extention ".c".
How can I do that?


What I sould write where the dots are?

override void doGenerate(Resource resource, IFileSystemAccess fsa) {
// fsa.generateFile(..........???????..............)

}

Thanks.
Re: Generating c code with xtext [message #1266519 is a reply to message #1266423] Fri, 07 March 2014 15:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi I am not sure if I get your question.
I assume you don't use xbase.

Generating code is generating text. So it does not matter if you
generate a test.java or a test.c or a test.h file or whether these
files contain java or c or something else

Did you do the Xtext tutorials from the docs generating code? If you
need specific help you should at least share your grammar.
Regards Christian

--
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: Generating c code with xtext [message #1266735 is a reply to message #1266519] Fri, 07 March 2014 22:26 Go to previous messageGo to next message
Antonis P. is currently offline Antonis P.Friend
Messages: 4
Registered: March 2014
Junior Member
Thanks.
Lets say that I want to generate text A;B;C in my example, which is independent of the original dsl code a;b;c
And I want to generate just one file (not many as in one example I have seen).
To do it more concrete lets say that I want to always generate the following peace of code
(*independent of what the dsl user have writen.)

#include <stdio.h>
int main() {
return 0;
}

How can I do it? If I knew that, I beleive that I could make a start.

Thanks a lot
Antonis.

[Updated on: Fri, 07 March 2014 22:29]

Report message to a moderator

Re: Generating c code with xtext [message #1266736 is a reply to message #1266735] Fri, 07 March 2014 22:29 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
HI,

i still do not get your point ?!?

fsa.generateFile("xyz.c",'''
#include <stdio.h>
int main() {
return 0;
}
''')



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:create DSL with xText for mobile development
Next Topic:Creating an update site with the sdk
Goto Forum:
  


Current Time: Thu Apr 25 15:38:22 GMT 2024

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

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

Back to the top