clang API Documentation
00001 //===--- CommentBriefParser.h - Dumb comment parser -------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines a very simple Doxygen comment parser. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 00015 #ifndef LLVM_CLANG_AST_COMMENTBRIEFPARSER_H 00016 #define LLVM_CLANG_AST_COMMENTBRIEFPARSER_H 00017 00018 #include "clang/AST/CommentLexer.h" 00019 00020 namespace clang { 00021 namespace comments { 00022 00023 /// A very simple comment parser that extracts "a brief description". 00024 /// 00025 /// Due to a variety of comment styles, it considers the following as "a brief 00026 /// description", in order of priority: 00027 /// \li a \\brief or \\short command, 00028 /// \li the first paragraph, 00029 /// \li a \\result or \\return or \\returns paragraph. 00030 class BriefParser { 00031 Lexer &L; 00032 00033 const CommandTraits &Traits; 00034 00035 /// Current lookahead token. 00036 Token Tok; 00037 00038 SourceLocation ConsumeToken() { 00039 SourceLocation Loc = Tok.getLocation(); 00040 L.lex(Tok); 00041 return Loc; 00042 } 00043 00044 public: 00045 BriefParser(Lexer &L, const CommandTraits &Traits); 00046 00047 /// Return the best "brief description" we can find. 00048 std::string Parse(); 00049 }; 00050 00051 } // end namespace comments 00052 } // end namespace clang 00053 00054 #endif 00055