Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Parsing code under inactive #if or #ifdef

Conditional compilation is very tricky to handle properly. It is not a matter of just letting the preprocessor output all the code from all paths through the code as this will generally result in incorrect code, and thus an unsuccessful parse (or at lesast, one filled with problem bindings).

Here is a presentation I gave at last year's summit on how we could handle this: http://wiki.eclipse.org/images/b/b3/Handling_Conditional_Compilation_In_CDT%E2%80%99s_Core.pdf

Beforewarned, doing this feature right would mean a lot of work. I think, in retrospect, that even my large estimates that I gave in that presentation were somewhat naive.

===========================

Chris Recoskie
Team Lead, IBM CDT Team
IBM Toronto
http://www.eclipse.org/cdt

Inactive hide details for "Dmitry Smirnov" <divis1969@xxxxxxxxx>"Dmitry Smirnov" <divis1969@xxxxxxxxx>


          "Dmitry Smirnov" <divis1969@xxxxxxxxx>
          Sent by: cdt-dev-bounces@xxxxxxxxxxx

          09/11/2008 08:58 AM

          Please respond to
          "CDT General developers list." <cdt-dev@xxxxxxxxxxx>

To

cdt-dev@xxxxxxxxxxx

cc


Subject

[cdt-dev] Parsing code under inactive #if or #ifdef

Hi,

I'm trying to use AST/PDOM for parsing a project in goal to build
browsable view of the code (outside of Eclipse, some set of WEB
pages).

For this purpose I would like to have inactive code to be parsed too.
As I can see, now this is prevented by CPreprocessor class. Method
executeIfdef() and other similar methods call
skipOverConditionalCode().

I would like to propose some enchancement for this. I believe some
scanner options could be added that changes default behaviour. If this
option is active, CPreprocessor will not call
skipOverConditionalCode() thus making parser to handle all the code.

I suppose, some methods should also be changed (like values of macro
defined inside active/inactive branches).

What do you think about such feature? Perhaps, CDT already have some
plans for similar enchancement?

I'm going to test this approach with CDT 5.0. If you have some
thoughts that could help me with it, please let me know.

Dmitry
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev

GIF image

GIF image

GIF image


Back to the top