$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2006-11-07 22:34:10
 
Andreas,
> I need some advice regarding Wave. What I want to do is to 
> operate with Wave on a token stream and extract the token 
> stream representing macro calls after expansion. The twist is 
> that I want the token stream after expansion to have the 
> positions that another preprocessor would see on the already 
> expanded output from Wave. E.g:
> #define MACRO_CALL int x;
> int main(){
>      MACRO
> };
> 
> Exands into
> #line 2
> int main(){
>      int x;
> };
> 
> Where 'int x' should have a position of line 3 instead of 
> line 1 after expansion. I also want the column number to 
> represent what we see on line 3 instead of what we see on 
> line 1. Is this possible ?
Ok, I've added a new pp hook (what else? :-P) to Wave:
///////////////////////////////////////////////////////////////////////////
//
//  The function 'generated_token' will be called by the library whenever a
//  token is about to be returned from the library.
//
//  The parameter 'ctx' is a reference to the context object used for 
//  instantiating the preprocessing iterators by the user.
//
//  The parameter 't' is the token about to be returned from the library.
//  This function may alter the token, but in this case it must be 
//  implemented with a corresponding signature: 
//
//      Token const&
//      generated_token(Context const& ctx, Token& t);
//
//  which makes it possible to modify the token in place.
//
//  The default behavior is to return the token passed as the parameter 
//  without modification.
//  
///////////////////////////////////////////////////////////////////////////
    template <typename Context, typename Token>
    Token const&
    generated_token(Context const& ctx, Token const& t)
    { return t; }
This should help solving your problem.
To show how this hook function may help you I added a new sample
'real_positions' to Wave demonstrating its use. Everything is in the Boost
CVS::HEAD.
HTH
Regards Hartmut