1 //===--- CommentParser.h - Doxygen comment parser ---------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the Doxygen comment parser.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_AST_COMMENT_PARSER_H
15 #define LLVM_CLANG_AST_COMMENT_PARSER_H
17 #include "clang/AST/Comment.h"
18 #include "clang/AST/CommentLexer.h"
19 #include "clang/AST/CommentSema.h"
20 #include "clang/Basic/Diagnostic.h"
21 #include "llvm/Support/Allocator.h"
29 /// Doxygen comment parser.
31 Parser(const Parser &) LLVM_DELETED_FUNCTION;
32 void operator=(const Parser &) LLVM_DELETED_FUNCTION;
34 friend class TextTokenRetokenizer;
40 /// Allocator for anything that goes into AST nodes.
41 llvm::BumpPtrAllocator &Allocator;
43 /// Source manager for the comment being parsed.
44 const SourceManager &SourceMgr;
46 DiagnosticsEngine &Diags;
48 DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) {
49 return Diags.Report(Loc, DiagID);
52 const CommandTraits &Traits;
54 /// Current lookahead token. We can safely assume that all tokens are from
55 /// a single source file.
58 /// A stack of additional lookahead tokens.
59 SmallVector<Token, 8> MoreLATokens;
62 if (MoreLATokens.empty())
65 Tok = MoreLATokens.back();
66 MoreLATokens.pop_back();
70 void putBack(const Token &OldTok) {
71 MoreLATokens.push_back(Tok);
75 void putBack(ArrayRef<Token> Toks) {
79 MoreLATokens.push_back(Tok);
80 for (const Token *I = &Toks.back(),
83 MoreLATokens.push_back(*I);
89 bool isTokBlockCommand() {
90 return (Tok.is(tok::backslash_command) || Tok.is(tok::at_command)) &&
91 Traits.getCommandInfo(Tok.getCommandID())->IsBlockCommand;
95 Parser(Lexer &L, Sema &S, llvm::BumpPtrAllocator &Allocator,
96 const SourceManager &SourceMgr, DiagnosticsEngine &Diags,
97 const CommandTraits &Traits);
99 /// Parse arguments for \\param command.
100 void parseParamCommandArgs(ParamCommandComment *PC,
101 TextTokenRetokenizer &Retokenizer);
103 /// Parse arguments for \\tparam command.
104 void parseTParamCommandArgs(TParamCommandComment *TPC,
105 TextTokenRetokenizer &Retokenizer);
107 void parseBlockCommandArgs(BlockCommandComment *BC,
108 TextTokenRetokenizer &Retokenizer,
111 BlockCommandComment *parseBlockCommand();
112 InlineCommandComment *parseInlineCommand();
114 HTMLStartTagComment *parseHTMLStartTag();
115 HTMLEndTagComment *parseHTMLEndTag();
117 BlockContentComment *parseParagraphOrBlockCommand();
119 VerbatimBlockComment *parseVerbatimBlock();
120 VerbatimLineComment *parseVerbatimLine();
121 BlockContentComment *parseBlockContent();
122 FullComment *parseFullComment();
125 } // end namespace comments
126 } // end namespace clang