in reply to Re: C++ header parser
in thread C++ header parser

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 ?

Replies are listed 'Best First'.
Re^3: C++ header parser
by Joost (Canon) on Dec 17, 2007 at 19:58 UTC
      Hah, somebody does read my blog sometimes. :}
      I'm working on this right now. hparse at http://gist.github.com/395160 c++ would need some more love, certainly. This is just the first simple start. But funcs and structs are correctly dumped.
Re^3: C++ header parser
by almut (Canon) on Dec 17, 2007 at 20:03 UTC

    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.