| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | #ifndef LLVM_CLANG_AST_COMMENTPARSER_H |
| 14 | #define |
| 15 | |
| 16 | #include "clang/AST/Comment.h" |
| 17 | #include "clang/AST/CommentLexer.h" |
| 18 | #include "clang/AST/CommentSema.h" |
| 19 | #include "clang/Basic/Diagnostic.h" |
| 20 | #include "llvm/Support/Allocator.h" |
| 21 | |
| 22 | namespace clang { |
| 23 | class SourceManager; |
| 24 | |
| 25 | namespace comments { |
| 26 | class CommandTraits; |
| 27 | |
| 28 | |
| 29 | class { |
| 30 | Parser(const Parser &) = delete; |
| 31 | void operator=(const Parser &) = delete; |
| 32 | |
| 33 | friend class TextTokenRetokenizer; |
| 34 | |
| 35 | Lexer &; |
| 36 | |
| 37 | Sema &; |
| 38 | |
| 39 | |
| 40 | llvm::BumpPtrAllocator &; |
| 41 | |
| 42 | |
| 43 | const SourceManager &; |
| 44 | |
| 45 | DiagnosticsEngine &; |
| 46 | |
| 47 | DiagnosticBuilder (SourceLocation Loc, unsigned DiagID) { |
| 48 | return Diags.Report(Loc, DiagID); |
| 49 | } |
| 50 | |
| 51 | const CommandTraits &; |
| 52 | |
| 53 | |
| 54 | |
| 55 | Token ; |
| 56 | |
| 57 | |
| 58 | SmallVector<Token, 8> ; |
| 59 | |
| 60 | void () { |
| 61 | if (MoreLATokens.empty()) |
| 62 | L.lex(Tok); |
| 63 | else |
| 64 | Tok = MoreLATokens.pop_back_val(); |
| 65 | } |
| 66 | |
| 67 | void (const Token &OldTok) { |
| 68 | MoreLATokens.push_back(Tok); |
| 69 | Tok = OldTok; |
| 70 | } |
| 71 | |
| 72 | void (ArrayRef<Token> Toks) { |
| 73 | if (Toks.empty()) |
| 74 | return; |
| 75 | |
| 76 | MoreLATokens.push_back(Tok); |
| 77 | MoreLATokens.append(Toks.rbegin(), std::prev(Toks.rend())); |
| 78 | |
| 79 | Tok = Toks[0]; |
| 80 | } |
| 81 | |
| 82 | bool isTokBlockCommand() { |
| 83 | return (Tok.is(tok::backslash_command) || Tok.is(tok::at_command)) && |
| 84 | Traits.getCommandInfo(Tok.getCommandID())->IsBlockCommand; |
| 85 | } |
| 86 | |
| 87 | public: |
| 88 | Parser(Lexer &L, Sema &S, llvm::BumpPtrAllocator &Allocator, |
| 89 | const SourceManager &SourceMgr, DiagnosticsEngine &Diags, |
| 90 | const CommandTraits &Traits); |
| 91 | |
| 92 | |
| 93 | void parseParamCommandArgs(ParamCommandComment *PC, |
| 94 | TextTokenRetokenizer &Retokenizer); |
| 95 | |
| 96 | |
| 97 | void parseTParamCommandArgs(TParamCommandComment *TPC, |
| 98 | TextTokenRetokenizer &Retokenizer); |
| 99 | |
| 100 | void parseBlockCommandArgs(BlockCommandComment *BC, |
| 101 | TextTokenRetokenizer &Retokenizer, |
| 102 | unsigned NumArgs); |
| 103 | |
| 104 | BlockCommandComment *parseBlockCommand(); |
| 105 | InlineCommandComment *parseInlineCommand(); |
| 106 | |
| 107 | HTMLStartTagComment *(); |
| 108 | HTMLEndTagComment *(); |
| 109 | |
| 110 | BlockContentComment *parseParagraphOrBlockCommand(); |
| 111 | |
| 112 | VerbatimBlockComment *(); |
| 113 | VerbatimLineComment *(); |
| 114 | BlockContentComment *(); |
| 115 | FullComment *(); |
| 116 | }; |
| 117 | |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | #endif |
| 122 | |
| 123 | |