Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » about C macro
about C macro [message #1069203] Mon, 15 July 2013 12:02 Go to next message
Yueming Hong is currently offline Yueming HongFriend
Messages: 87
Registered: April 2013
Member
HI,
My language needs to use the C type macro and inclusion.
And the macro is very complex, does anyone have idea to do this or have done it before?
Maybe it stupid to define macro in Xtext, is there any alternative?
Sharing your idea would be pretty much helpful to me.

Thanks
Re: about C macro [message #1069229 is a reply to message #1069203] Mon, 15 July 2013 13:10 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

[Yes it's stupid, but...]

The CPP is an overlay language. Implementing two woven languages is very
hard/impossible, particularly if you accurately respect the nested
lexical substition of CPP.

If you are determined to implement it yourself, you should implement the
two languages as two distinct layers. One CPP grammar for text to
preprocessed-text translation and another for preprocessed-text to model.

Many C/C++ tools have an ability to run just the preprocessor pass, so
you may be better off leveraging an existing implementation of at least
the CPP.

Regards

Ed Willink

On 15/07/2013 13:02, Yueming Hong wrote:
> HI,
> My language needs to use the C type macro and inclusion.
> And the macro is very complex, does anyone have idea to do this or
> have done it before?
> Maybe it stupid to define macro in Xtext, is there any alternative?
> Sharing your idea would be pretty much helpful to me.
>
> Thanks
Re: about C macro [message #1069231 is a reply to message #1069203] Mon, 15 July 2013 13:19 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2013-15-07 14:02, Yueming Hong wrote:
> HI,
> My language needs to use the C type macro and inclusion.
> And the macro is very complex, does anyone have idea to do this or have
> done it before?
> Maybe it stupid to define macro in Xtext, is there any alternative?
> Sharing your idea would be pretty much helpful to me.
>
> Thanks

The only advice I can think of is "Run for the hills".

Have not heard of anyone that has implemented support for "C macros", or
"C includes" with Xtext. If possible to make it work at all in a way
that is not irritating to users it is going to be complex and expensive
to implement.

There are older posts in this forum on the topic with more description
of the issues involved.

I would instead try to change the actual language to directly support
something that is sane (i.e. not use C include/macros at all).

Regards
- henrik
Re: about C macro [message #1069350 is a reply to message #1069231] Mon, 15 July 2013 18:11 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
I have never seen a working implementation of such macros in Xtext too.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:<language>.xtextbin not found
Next Topic:about grammar
Goto Forum:
  


Current Time: Sat Apr 20 04:22:27 GMT 2024

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

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

Back to the top