[boost::wave] Hooks not called for conditionals

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.

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.
I started to look at your example and I realized there are definitely some inconsistencies esp. wrt calling the may_skip_token hook for newline characters following a conditional pp directive. These seem to be bugs I will look at asap. Moreover, there is a bug preventing Wave from calling the skipped_token hook for 'inactive' conditional pp directive tokens (this one I fixed in SVN). If you used the SVN version now, returning 'false' from the 'found_directive' should give you at least the missing directives. Please give me a day or two to fully understand what's currently going on. Regards Hartmut --------------- Meet me at BoostCon www.boostcon.com
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.
participants (2)
-
Alden King
-
Hartmut Kaiser