extract c/cpp include file with regular expression

tiefeng wu icebergwtf at gmail.com
Thu Jul 23 12:36:53 EDT 2009


2009/7/24 Philip Semanchuk <philip at semanchuk.com>:
>
> I know this will sound like a sarcastic comment, but it is sincere: my
> suggestion is that if you want to parse C/C++ (or Python, or Perl, or
> Fortran, etc.), use a real parser, not regexes unless you're willing to
> sacrifice some accuracy. Sooner or later you'll come across some code that
> your regexes won't handle, like this --
>
> #ifdef FOO_BAR
> #include <this.h>
> /* #else */
> #include <that.h>
> #endif
>
>
> Parsing code is difficult...
>
I understand your point, thanks for your suggestion, Philip. And I've
met the problem like in your example
The reason I choose regex because I barely know about "real parser",
for me it still in some "dark area" :)
But I'll find something to learn.

tiefeng wu
2009-07-23



More information about the Python-list mailing list