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

Manuel Klimek klimek at google.com
Sat Jun 16 02:16:17 PDT 2012


On Fri, Jun 15, 2012 at 11:51 PM, Dmitri Gribenko <gribozavr at gmail.com>wrote:

> 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.
>

What I mean is that in your patch it looks like the doxygen-ness of the
comment is ingrained at the Sema level. Why not completely separate out the
parsing of comments design wise?

Cheers,
/Manuel


>
> 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>*/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120616/729d8313/attachment.html>


More information about the cfe-commits mailing list