[cfe-dev] Adding comment callback for documentation tools

Cédric Venet cedric.venet at laposte.net
Thu Oct 23 09:56:58 PDT 2008


Adding information in comment is useful for documentation purpose or for
 adding information/metadata for others tools like formal proof or DSL
code generator...

Actually, there isn't (AFAIK) a facility to extract the comment and the
AST at the same time.

Since managing comment token in the parser is to complex (they can
appear everywhere) I propose that the lexer or the preprocessor use
callback to inform the client that he encoutered a comment.

For example, for doxygen like tools, the callback would check if the
comment is a documentation one, and if so, store it for later use. Once
the AST complete, it would walk the def and associate the corresponding
comment (or the other way around).

Does this seems good, any other idea? alternatively, the lexer/PP could
create a list of comment token.

The callback could be added to clang::PPCallbacks. It is the best place
, isn't it?

This modification would have zero cost for classical use since lexer
already has a condition keep comment. It would only had a conditionnal
in the PP when a comment token is consumed.

If this is ok, I will prepare a patch.



More information about the cfe-dev mailing list