Generic preprocessor: How to use for any kind of file?
I was wondering if someone uses a generic preprocessor for manipulating text files. The idea came up, as Java does not have a preprocessor, but I'd like to have conditional code compilation, etc. Now, taking that idea further, I might as well use a generic preprocessor for any kind of files that need frequent editing, but all edits are in a similar manner. Now, there's good ol' m4 which I'd like to use as I use the C-preprocessor and there is GPP, that one however, stopped being developed in 2007. I'd like some suggestions which preprocessor is preferable, if possible, it should take directives the same way C-preprocessor takes them #define SOMETHING. Since m4 doesn't use sigils or something, it might collide with other code, when m4 is the way to go, I'd need advice on how to prefix every directive with a sigil or a different prefix or something.
Most C/C++ compilers allow you to just run the preprocessor and save the output, and can be used on generic input. (for Visual C++, I blieve the option is /P) But remember the preprocessors cause as many problems as they solve. The designers of both C++ and Java have tried hard to eliminate the need for using the preprocessor. For example, in Java, code like this: if (true) CallThis(); else DoNotCallThis(); will just generate code for the CallThis() call and not generate code for the condition or the else branch. (This is not a quality of Implementation issue --- it is a requirement of the Java language definition).
For a 'sigil', use m4's command line option -P to add prefix m4_ to all built-in m4 macros. You then have m4_define, m4_divert, etc.
C++ precompiler conditionally include code
DDK preprocessor directives
Preprocessor, Postprocessor, Geometric Processor and NC processor
Gfortran pre-processor directives for Different Operating systems
Good data set for Pre-processing
IDE inserts incorrect #include statement
Save string in C preprocessor
Fortran preprocessing with Portland compiler
Making a macro expansion dependent on its arguments
How to set ISPP defines based on default Inno Setup variables?
standalone C++ preprocessor
Annotations in OCaml
Obtaining the include paths cpp searches
Test for empty macro definition
m4 does not obey expansion?
Detect compilation on Bada OS