Skip to main content



      Home
Home » Modeling » TMF (Xtext) » C++ code generation with Xtext
C++ code generation with Xtext [message #648120] Tue, 11 January 2011 05:16 Go to next message
Eclipse UserFriend
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 05:36 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: C++ code generation with Xtext [message #648137 is a reply to message #648123] Tue, 11 January 2011 06:54 Go to previous messageGo to next message
Eclipse UserFriend
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 07:54 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: C++ code generation with Xtext [message #648146 is a reply to message #648141] Tue, 11 January 2011 08:35 Go to previous messageGo to next message
Eclipse UserFriend
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 09:12 Go to previous message
Eclipse UserFriend
Hi, i just copied a cpp helloworld from wikipedia C++ article since i do not know cpp

~Christian
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: Tue Jul 01 18:45:41 EDT 2025

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

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

Back to the top