Boost logo

Boost Users :

Subject: [Boost-users] [boost::wave] Hooks not called for conditionals
From: Alden King (apking_at_[hidden])
Date: 2010-08-27 13:22:31


I am currently working on a project that uses Wave to pre-process and tokenize C/C++ code, but I am not getting everything that I expect from the preprocessing hooks. We use the preprocessing hooks to extract data about false-branches, macro calls and macro expansions so this is a major roadblock for us.

I am trying to extract information about the true and false branch of
   #if 1
   int foo;
   #elif 0
   float foo;
   #else
   struct { } foo;
   #endif
The first #if is seen by 'found_directive'. If that returns false, then I get
   #ifint foo;
   #eliffloat foo;
   #else
   struct { } foo;
   #endif
Note that it skips the newline after the #if and #elif and that it doesn't reveal their conditions. If it returns true, then 'evaluated_conditional_expression also gets called and I get
   #if 1 // [Taken]
   int foo;
   #elif0
   float foo;
   struct { } foo;
Without the #else directive, the #endif directive, and the whitespace between #elif and it's condition.

My problem is that the false branch is not seen by either function (the endif also has trouble sometimes). I therefore expected all tokens in the false branch to be processed by 'may_skip_whitespace' or 'skipped_token', but that is not the case.

Could you please help me to find our how to get the tokens from the false branch of the conditional expression using the preprocessing hooks?

I've attached my wave test program and a sample input file.

Thanks.






Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net