[cfe-dev] Regarding parsing of comment in Clang
Arpit Sancheti
arpit.sancheti2002 at gmail.com
Fri Aug 2 04:58:18 PDT 2013
Respected,
> Current comment parsing can only pick up comments that:
> 1. immediately precede a declaration
> 2. have special starting sequence: /// for line comments and /** ...
> */ for block comments.
> (2) is easy to correct
can you tell me how it can be done and also does writing the function
ASTContext::getCommentForDecl(
) in the our parser will retrieve the comment or something else is also to
be done.
Thanking you
-- surbhi
On Fri, Aug 2, 2013 at 11:40 AM, Dmitri Gribenko <gribozavr at gmail.com>wrote:
> On Thu, Aug 1, 2013 at 10:59 PM, Arpit Sancheti
> <arpit.sancheti2002 at gmail.com> wrote:
> > Sir, what I want to ask you is how to approach to this problem. What did
> you
> > do to parse comments and generate AST with them?
>
> Current comment parsing can only pick up comments that:
> 1. immediately precede a declaration
> 2. have special starting sequence: /// for line comments and /** ...
> */ for block comments.
>
> (2) is easy to correct, but (1) is an architectural limitation.
> Documentation comments can only be attached to a declaration. You
> also need to attach comments to statements. You will need to
> implement this yourself. See the ASTContext::getCommentForDecl() API.
>
> After you get the "raw" (unparsed) comment you need to parse it. Just
> write a normal recursive-descent parser for comment contents.
> Documentation comment parsing is very Doxygen-specific, it handles
> Doxygen escape sequences and so on -- I think it is easier to write a
> parser for ASCL from scratch than to repurpose the documenation
> parser.
>
> > It would be very kind of you if you will reply to this asap.
>
> Please send further questions to cfe-dev so that the community can
> benefit from the answers.
>
> 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-dev/attachments/20130802/28b4bbbf/attachment.html>
More information about the cfe-dev
mailing list