azaria has asked for the wisdom of the Perl Monks concerning the following question:

I need a header file parser that extracts function and type names and dumps them to text file, any expirence idea ? Thanks Azaria

Replies are listed 'Best First'.
Re: C++ header parser
by almut (Canon) on Dec 17, 2007 at 18:53 UTC

    Maybe something like ctags?

      I should explain my question better, I have a C++ header file, I would like to write a parser which parse this files and genrate a text file for all struct enum etc ... even if there is instances. Any idea ?

        Have you looked at the ctags docs to see what it can do, or better yet, tried to run it on one of your header files to see what output it produces, and how far that is away from what you need?

        From your current description, ctags still sounds like a good fit: it can parse C++ header files, and can create a text output file with info about the structs, enums, etc. found in the header files. The only problem is that you don't have to write it yourself ;) — But if you ask me, I'd rather avoid having to write a parser for anything as complex as C++...

        If the ctags output isn't exactly what you need, you can still postprocess it using Perl, but in this case the hard work has already been done.

        To give people a clearer idea of what you need, it almost always helps to supply some sample in- and output, i.e. post a sample header file together with the output that you expect to be created from that input.

Re: C++ header parser
by ForgotPasswordAgain (Vicar) on Dec 17, 2007 at 20:00 UTC
      You could try the web archive: I was able to get a copy of perceps version 3.4.1; I haven't figured out how to use it yet. I also found cppTree.pl who's author appears to be Ron Savage (it mentions perceps).
      -- Ian Tegebo