Parsing #IF Directive

Hi,
I need to write a script which parses #ifdef directive.

I'd need to support different types as below.

My object is to detect the FLAG out of the different #if appearances, and tell whether is negate condition or not.

Then, I should output TRUE or FALSE accordingly.

1. #if defined FLAG
2. #if (defined FLAG)
3. #if defined (FLAG)
4. #ifdef FLAG
5. #ifdef (FLAG)
6. #ifndef (FLAG)
7. #if !defined(FLAG)

etc.

How would you approach this problem?
Last edited on
Take a peek at preprocessor's source?
Yes, however the script will not have this input, only a certain source file will be given.

I'll however know whether FLAG is defined or not.
look for #define FLAG ?
Hi,
I'm sorry for not explaining my objective correctly.

I edited the post, adding a line which explains the objective:

My object is to detect the FLAG out of the different #if appearances, and tell whether is negate condition or not.
Topic archived. No new replies allowed.