Jump to content

  • Log In with Google      Sign In   
  • Create Account

Generic preprocessor tools


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 alnite   Crossbones+   -  Reputation: 2112

Like
0Likes
Like

Posted 27 September 2012 - 12:09 PM

Some languages are blessed with preprocessor directives, but there are other languages that don't have them for various reasons.

So then my question is this: Is there a generic preprocessor tools out there where you can inject a few rules, process any text files, and output the result to new text files.

If the file was a Java source code, and DEBUG was set to false, it would preprocess them like this:
//#if DEBUG
	 int var = 10 + debugValue;
//#else
	 int var = 10;
//#endif

Output:
//#if DEBUG
//	 int var = 10 + debugValue;
//#else
	 int var = 10;
//#endif

If it was Python:
##if DEBUG
	 var = 10 + debugValue
##else
	 var = 10;
##endif

Output:
##if DEBUG
#	 var = 10 + debugValue
##else
	 var = 10;
##endif

And as you can see, you can extend this to any programming languages or scripts (HTML, CSS, bash, anything) that don't support preprocessor directives natively but support comments. Alas, I can't find any good tools that can do this seemingly-straightforward task properly.

Edited by alnite, 27 September 2012 - 12:13 PM.


Sponsor:

#2 Bregma   Crossbones+   -  Reputation: 5187

Like
3Likes
Like

Posted 27 September 2012 - 02:27 PM

The C preprocessor will do that. It's almost universally available as a separate phase of the compiler or as a separate executable entirely. The C preprocessor has no clue about the C (or C++, or FORTRAN, or Java) language proper.

There have been many systems that leverage the C preprocessor to enhance other languages.
Stephen M. Webb
Professional Free Software Developer

#3 joew   Crossbones+   -  Reputation: 3667

Like
0Likes
Like

Posted 27 September 2012 - 04:51 PM

I've used https://github.com/bagder/fcpp in the past and I'd suggest checking it out.

#4 wqking   Members   -  Reputation: 756

Like
0Likes
Like

Posted 27 September 2012 - 11:03 PM

I heard M4 and saw some open source projects use it
http://en.wikipedia.org/wiki/M4_%28computer_language%29
I didn't use it before.

http://www.cpgf.org/
cpgf library -- free C++ open source library for reflection, serialization, script binding, callbacks, and meta data for OpenGL Box2D, SFML and Irrlicht.
v1.5.5 was released. Now supports tween and timeline for ease animation.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS