Parsing C Preprocessor files

Paul McGuire ptmcg at
Wed Jun 23 15:58:04 CEST 2004

"Bram Stolk" <bram at> wrote in message
news:20040623140151.6b8863f2 at
> 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 .  The examples include a
file, 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