Boost logo

Boost Users :

Subject: Re: [Boost-users] [wave] How to enumerate all function declarations in a preprocessed header
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2009-05-10 11:37:38

> I'm trying to use booost.wave to parse some C headers and generate code
> for
> each function declaration found.
> How would you write code that identifies all function declarations?
> Is there any higher level structure that helps me finding this or do I
> need to
> create some state machine that matches the pattern for a function
> declaration
> from what's found in the token iterator?

Wave is a tokenizing preprocessor. That means all it can do is to return the
recognized C++ tokens as seen in the input stream. In order to make some
sense out of the token stream you need to write a parser matching the input
you're looking for. You might want to look at one of Wave's examples,
Hannibal, which is a partial C++ parser written using Spirit V1.8. In your
case a much simpler grammar should be sufficient, though, as you're looking
for function declarations only. Another pointer could be: Those guys were using
Spirit/Wave to instrument C++ code for template metaprogramming debugging

Regards Hartmut

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at