
Andreas Sæbjørnsen wrote:
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 ?
IIUC you want to discard the information about the macro definition and make the token stream look like it was the original input stream. This is not possible with Wave as it is. My first thought was to use boost::transform_iterator on top of the wave iterators and to maintain a separate file position based on the tokens passed through it. But this doesn't work, because this iterator kicks in every time the transform_iterator is dereferenced, so you end up correcting the current file position each time. Clearly indirection doesn't work easily here... So I'm not sure yet, how to achieve this, but at least I have some ideas, at which points this could be injected into Wave. Please give me some more time to contemplate... Do you have any thought's on that? Regards Hartmut