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

Dmitri Gribenko gribozavr at gmail.com
Thu Jul 5 17:30:05 PDT 2012


On Thu, Jul 5, 2012 at 2:30 PM, Douglas Gregor <dgregor at apple.com> wrote:
>
> On 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.
>
> This patch is looking great. I have a few comments below; feel free to commit after addressing those, and I'll take a look at the result as a post-commit review.

Thank you for the review.  Committed (with fixes) r159789, r159790.

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