[llvm-commits] [PATCH] Comment AST and parser

Dmitri Gribenko gribozavr at gmail.com
Tue Jul 3 15:25:24 PDT 2012


Hello,

Here is a small patch to enable new[] on llvm::BumpPtrAllocator.

Please review.

Dmitri

On Tue, Jul 3, 2012 at 3:14 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
> Hello,
>
> The proposed patch implements AST classes for comments, a real parser
> for Doxygen comments and a very simple semantic analysis that just
> builds the AST.  It also includes some minor changes for lexer to pick
> up source locations I didn't think about before.
>
> I decided to model the comments AST along the ideas of HTML AST: block
> and inline content.
>
> * Block content is a paragraph or a command that has a paragraph as an
> argument or verbatim command.
> * Inline content is placed within some block.  Inline content includes
> plain text, inline commands and HTML as tag soup.
>
> Here are the AST nodes:
>
> $ cat include/clang/Basic/CommentNodes.td
> class Comment<bit abstract = 0> {
>   bit Abstract = abstract;
> }
>
> class DComment<Comment base, bit abstract = 0> : Comment<abstract> {
>   Comment Base = base;
> }
>
> def InlineContentComment : Comment<1>;
>   def TextComment : DComment<InlineContentComment>;
>   def InlineCommandComment : DComment<InlineContentComment>;
>   def HTMLTagComment : DComment<InlineContentComment, 1>;
>     def HTMLOpenTagComment : DComment<HTMLTagComment>;
>     def HTMLCloseTagComment : DComment<HTMLTagComment>;
>
> def BlockContentComment : Comment<1>;
>   def ParagraphComment : DComment<BlockContentComment>;
>   def BlockCommandComment : DComment<BlockContentComment>;
>     def ParamCommandComment : DComment<BlockCommandComment>;
>     def VerbatimBlockComment : DComment<BlockCommandComment>;
>     def VerbatimLineComment : DComment<BlockCommandComment>;
>
> def VerbatimBlockLineComment : Comment;
>
> def FullComment : Comment;
>
> More example ASTs attached.
>
> Not implemented in this patch:
> * a real iterator for Comment child nodes (but do we need one?)
> * diagnostics during parsing and semantic analysis;
> * finding and resolving declaration references in comment text;
> * TableGen-based generation of Doxygen command properties.
>
> Please review.
>
> 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>*/



-- 
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 --------------
A non-text attachment was scrubbed...
Name: comments-parser-llvm-v1.patch
Type: application/octet-stream
Size: 782 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120703/391ad5d5/attachment.obj>


More information about the llvm-commits mailing list