From: Stefan S. <se...@sy...> - 2004-05-13 15:22:57
|
hi there, I'm currently looking into ways to enhance the ways the parser can collaborate with the preprocessor. I'm doing this in the context of my synopsis project, where I generate cross referenced source code which is easy to navigate and introspect (see http://synopsis.fresco.org/docs/Manual/occ/index.html for an example). One of the challenges there is that the exact locations in the file that should be linked isn't available to the parser, as macro expansion has already taken place. I thus use a special preprocessor that provides me with the information about macro definitions and macro calls, so I can 'reverse apply' them to the data stream. While preprocessing I create a set of 'SourceFile' objects that contain initially just these macro definitions plus links to each other reflecting the file inclusion dependencies. Later more stuff is put in when the C and C++ parsers are run. The problem I'm currently facing is related to the lookup of the SourceFile objects during the parsing. The parser (opencxx) can be queried for the 'current file and line number' associated with a ptree node. However, that's not quite enough: As a file could be included more than once, and worse, each time with a different set of macros defined [1], I need to track exactly which inclusion this file comes from. Just think about precompiled headers for a moment and all the challenges this implies... Has anybody already thought about this problem, in particular in the context of opencxx ? As I said, while my specific interest is synopsis right now, I'd really prefer to work on opencxx directly, as this work may be useful to others, too. Best regards, Stefan [1] My short term goal is to generate a full and correct reference manual for the boost project (http://www.boost.org), and if you'v already used boost before, you know what kind of challenge that means :-) |