[cfe-commits] [PATCH] Structured comment parsing, retaining comments in AST

Dmitri Gribenko gribozavr at gmail.com
Fri Jun 15 14:51:23 PDT 2012


On Mon, Jun 11, 2012 at 8:48 AM, Manuel Klimek <klimek at google.com> wrote:
> Very high level remark:
> I guess the reason we don't try to associate declarations with comments in
> general in the AST and do the parsing of doxygen completely lazily (and
> perhaps by code that doesn't need to be part of the AST libraries at all) is
> the multi-declaration-spanning comment stuff?

If I understood your question correctly, there are a couple of reasons:
1. We don't want to do extra work during normal compilation.
2. Current parser is not prepared to handle tok::comment, so comments
should be extracted out of the token stream and handled separately.

If you mean "multi-declaration-spanning comment" = grouping declarations like:
/** @defgroup ... @{ */
decls...
/** @} */

I think that these structured comments should be properly treated as
an AST on their own, which has the following nodes:
* TU, which has Records, CommentGroups and Comments as children
* Comment, which has a parsed comment AST
* CommentGroup, which has Comments as children
* Record, which has CommentGroups, Comments and Records as children.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the cfe-commits mailing list