summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/CommentBriefParser.cpp
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2012-08-09 00:03:17 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2012-08-09 00:03:17 +0000
commitca7f80ada0d3bb905572d5711111bb3ac2fec434 (patch)
tree66f31ce77fe5d331251a62453f45fcda8729d061 /clang/lib/AST/CommentBriefParser.cpp
parent5fbbc5bfe86f03a9b400757d3a91585f00225c83 (diff)
downloadbcm5719-llvm-ca7f80ada0d3bb905572d5711111bb3ac2fec434.tar.gz
bcm5719-llvm-ca7f80ada0d3bb905572d5711111bb3ac2fec434.zip
Comment parsing: extract TableGen'able pieces into new CommandTraits class.
llvm-svn: 161548
Diffstat (limited to 'clang/lib/AST/CommentBriefParser.cpp')
-rw-r--r--clang/lib/AST/CommentBriefParser.cpp28
1 files changed, 9 insertions, 19 deletions
diff --git a/clang/lib/AST/CommentBriefParser.cpp b/clang/lib/AST/CommentBriefParser.cpp
index 22209c097fd..0aebc1e4e3d 100644
--- a/clang/lib/AST/CommentBriefParser.cpp
+++ b/clang/lib/AST/CommentBriefParser.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/CommentBriefParser.h"
+#include "clang/AST/CommentCommandTraits.h"
#include "llvm/ADT/StringSwitch.h"
namespace clang {
@@ -39,19 +40,13 @@ void cleanupBrief(std::string &S) {
S.resize(O - S.begin());
}
+} // unnamed namespace
-bool isBlockCommand(StringRef Name) {
- return llvm::StringSwitch<bool>(Name)
- .Cases("brief", "short", true)
- .Cases("result", "return", "returns", true)
- .Cases("author", "authors", true)
- .Case("pre", true)
- .Case("post", true)
- .Cases("param", "arg", true)
- .Case("tparam", true)
- .Default(false);
+BriefParser::BriefParser(Lexer &L, const CommandTraits &Traits) :
+ L(L), Traits(Traits) {
+ // Get lookahead token.
+ ConsumeToken();
}
-} // unnamed namespace
std::string BriefParser::Parse() {
std::string FirstParagraphOrBrief;
@@ -72,18 +67,18 @@ std::string BriefParser::Parse() {
if (Tok.is(tok::command)) {
StringRef Name = Tok.getCommandName();
- if (Name == "brief" || Name == "short") {
+ if (Traits.isBriefCommand(Name)) {
FirstParagraphOrBrief.clear();
InBrief = true;
ConsumeToken();
continue;
}
- if (Name == "result" || Name == "return" || Name == "returns") {
+ if (Traits.isReturnsCommand(Name)) {
InReturns = true;
ReturnsParagraph += "Returns ";
}
// Block commands implicitly start a new paragraph.
- if (isBlockCommand(Name)) {
+ if (Traits.isBlockCommand(Name)) {
// We found an implicit paragraph end.
InFirstParagraph = false;
if (InBrief)
@@ -121,11 +116,6 @@ std::string BriefParser::Parse() {
return ReturnsParagraph;
}
-BriefParser::BriefParser(Lexer &L) : L(L) {
- // Get lookahead token.
- ConsumeToken();
-}
-
} // end namespace comments
} // end namespace clang
OpenPOWER on IntegriCloud