Log in

View Full Version : win32 c processor only needed


OHPen
April 4th, 2008, 11:08
Hi all,

actually I'm working on a project where i have to process a non c file with with a typical standard c preprocessor in order to rename some strings, etc.
the file i have to process is a java source file.

i just want to merge "#define"-declarations with the java source file and afterwards the preprocessor should do the replace work for me and produce a new java source file with renamed methods, fields, etc.

i know that i could use cpp with the according switch but i would prefare a standalone console tool, to simplify the process.

any ideas what i could use on a standard win32 system ?

thx in advance,

OHPen

Silver
April 4th, 2008, 13:11
If I'm understanding you right you need to tokenize and extract from a source file. Sounds like you want a lexer like Flex? You'll have to do some coding but if you already know how to use a lexer it'll be much faster.

http://flex.sourceforge.net/

OHPen
April 5th, 2008, 15:42
@silver: thx for your reply. it would be no problem to write my own tokenizer and so it would also be no problem to use an tokenizer or as you said a lexer.
But this is far to much for the simple problem i have to solve.

A "#define"-Mechanism would do it fast enough for me. I will use this solution because it produces the smallest amount of work for me. its more a search'n'replace problem than a tokenizing problem.

you surely agree that a preprocessor is pretty good adequat for this job.

the problem is now only to find a small c preprocess which is able to handle file up to 8000 lines of code. nothing more.

i hope someone know such a preprocessor, would be really great.
if not so then i will use the preprocess from gnu, which is not so good (cpp).

cu

OHPen

fr33ke
April 6th, 2008, 10:56
sed?
http://gnuwin32.sourceforge.net/packages/sed.htm

evlncrn8
April 6th, 2008, 23:19
python might be a good candidate too...

OHPen
April 7th, 2008, 02:37
Thanks for all replies

But as i said before i really want to use an c-preprocessor. it's not only because i want, i also because i would have to make changes to our build system when i would use new software. and if there would be a c-preprocessor we probably already have it intregrated somewhere

Anyway, i decided to use cpp now:

By using this command line parameters i achieve what it want:

cpp -E test.java -o test2.java -P

It wasn't obvious that it is so simple. So this solution will do it for me,

thanks,

OHPen