Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » C++ code generation with Xtext
C++ code generation with Xtext [message #648120] Tue, 11 January 2011 10:16 Go to next message
Igor  is currently offline Igor Friend
Messages: 7
Registered: January 2011
Junior Member
Hello! I'm just learning basics of Xtext and want to know what is needed for generating C++ code from DSL programs created in Xtext? Does one need to integrate a tool EMF4CPP (and possibly replace original EMF with it) or there are other methods?

Sorry for possible duplicating. I've searched like 30 pages of the forum and haven't found anything looking alike.

Best Regards!
Re: C++ code generation with Xtext [message #648123 is a reply to message #648120] Tue, 11 January 2011 10:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hello Igor,

Xtext does not come with a predefined C++ Generator. You can take a Template Engine / Code Generator like Xpand or Acceleo and write the Templates that produce the .cpp files yourself.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: C++ code generation with Xtext [message #648137 is a reply to message #648123] Tue, 11 January 2011 11:54 Go to previous messageGo to next message
Igor  is currently offline Igor Friend
Messages: 7
Registered: January 2011
Junior Member
Thank you Christian! Maybe you could provide me with some simple example of Xpand C++ template file?
Re: C++ code generation with Xtext [message #648141 is a reply to message #648137] Tue, 11 January 2011 12:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

here a simple template for the hello world xtext sample project
(copy & paste from wikipedia)

«IMPORT org::xtext::example::mydsl::myDsl»

«EXTENSION templates::Extensions»

«DEFINE main FOR Greeting-»
«FILE name+".cpp"-»
#include <iostream>
#include <ostream>
 
int main() 
{
   std::cout << "Hallo «name»!" << std::endl;
}

«ENDFILE-»
«ENDDEFINE»



~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: C++ code generation with Xtext [message #648146 is a reply to message #648141] Tue, 11 January 2011 13:35 Go to previous messageGo to next message
Igor  is currently offline Igor Friend
Messages: 7
Registered: January 2011
Junior Member
Thanks again! I wonder is it Wikipedia or Eclipsepedia because I still can't find this tutorial:(
Re: C++ code generation with Xtext [message #648153 is a reply to message #648146] Tue, 11 January 2011 14:12 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi, i just copied a cpp helloworld from wikipedia C++ article since i do not know cpp

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Problem with maven artifacts
Next Topic:How to relate an externel model with my textual model created with xtext
Goto Forum:
  


Current Time: Fri Apr 26 05:07:04 GMT 2024

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

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

Back to the top