Max Motovilov wrote:
I have a simple problem: wave warnings (specifically, macro re-definition) are reported as exceptions thrown from [potentially, any of, at least I don't yet know better] the methods of pp_iterator. It is very simple to catch one and print a message, however I can't figure out how to recover after one.
Can't seem to find any mention of error recovery in documentation, tried some variations of last_known_good_iterator (store a copy before every increment, restore back to known copy in exception handler) -- it recovers simple cases but on more complex files there appears to be internal state corruption. Also, even when this recovery works, it leaves macro in the pre-redefinition state whereas the usual cpp policy is to allow redefinition and print a warning.
I thought of using a preventive strategy -- undefine the existing macro from a policy method -- but unfortunately the exception is thrown before defined_macro() is called.
Looks like it's time to ask the owners of the library: how do I do this? :-)
You hit the nail on the head (like we Germans say). Wave currently doesn't really support error recovery. The main focus of Wave was conformance and not usability. Adding error recovery is one of my high priority tasks for Wave, but I'm not sure yet how to design this. I'm afraid I don't have any better answer for you. Regards Hartmut