Parsing C Preprocessor files

Paul McGuire ptmcg at austin.rr._bogus_.com
Wed Jun 23 15:58:04 CEST 2004


"Bram Stolk" <bram at nospam.sara.nl> wrote in message
news:20040623140151.6b8863f2 at pistache.sara.nl...
> Hi there,
>
> What could I use to parse CPP macros in Python?
> I tried the Parnassus Vaults, and python lib docs, but could not
> find a suitable module.
>
> Thanks,
>
>   Bram
>

Try pyparsing, at http://pyparsing.sourceforge.net .  The examples include a
file scanExamples.py, that does some simple C macro parsing.  This should be
pretty straightforward to adapt to matching #ifdef's and #endif's.

-- Paul
(I'm sure pyparsing is listed in Vaults of Parnassus.  Why did you think it
would not be applicable?)





More information about the Python-list mailing list