2012-08-09 08:03:17 +08:00
|
|
|
//===--- CommentCommandTraits.cpp - Comment command properties --*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/AST/CommentCommandTraits.h"
|
|
|
|
#include "llvm/ADT/StringSwitch.h"
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace comments {
|
|
|
|
|
|
|
|
// TODO: tablegen
|
|
|
|
|
2012-08-17 04:16:11 +08:00
|
|
|
bool CommandTraits::isVerbatimBlockCommand(StringRef StartName,
|
2012-08-09 08:03:17 +08:00
|
|
|
StringRef &EndName) const {
|
2012-08-17 04:16:11 +08:00
|
|
|
const char *Result = llvm::StringSwitch<const char *>(StartName)
|
2012-08-09 08:03:17 +08:00
|
|
|
.Case("code", "endcode")
|
|
|
|
.Case("verbatim", "endverbatim")
|
|
|
|
.Case("htmlonly", "endhtmlonly")
|
|
|
|
.Case("latexonly", "endlatexonly")
|
|
|
|
.Case("xmlonly", "endxmlonly")
|
|
|
|
.Case("manonly", "endmanonly")
|
|
|
|
.Case("rtfonly", "endrtfonly")
|
|
|
|
|
|
|
|
.Case("dot", "enddot")
|
|
|
|
.Case("msc", "endmsc")
|
|
|
|
|
|
|
|
.Case("f$", "f$") // Inline LaTeX formula
|
|
|
|
.Case("f[", "f]") // Displayed LaTeX formula
|
|
|
|
.Case("f{", "f}") // LaTeX environment
|
|
|
|
|
|
|
|
.Default(NULL);
|
|
|
|
|
|
|
|
if (Result) {
|
|
|
|
EndName = Result;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (VerbatimBlockCommandVector::const_iterator
|
|
|
|
I = VerbatimBlockCommands.begin(),
|
|
|
|
E = VerbatimBlockCommands.end();
|
|
|
|
I != E; ++I)
|
2012-08-17 04:16:11 +08:00
|
|
|
if (I->StartName == StartName) {
|
2012-08-09 08:03:17 +08:00
|
|
|
EndName = I->EndName;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CommandTraits::isVerbatimLineCommand(StringRef Name) const {
|
2012-08-10 02:20:29 +08:00
|
|
|
bool Result = isDeclarationCommand(Name) || llvm::StringSwitch<bool>(Name)
|
2012-08-09 08:03:17 +08:00
|
|
|
.Case("defgroup", true)
|
|
|
|
.Case("ingroup", true)
|
|
|
|
.Case("addtogroup", true)
|
|
|
|
.Case("weakgroup", true)
|
|
|
|
.Case("name", true)
|
|
|
|
|
|
|
|
.Case("section", true)
|
|
|
|
.Case("subsection", true)
|
|
|
|
.Case("subsubsection", true)
|
|
|
|
.Case("paragraph", true)
|
|
|
|
|
|
|
|
.Case("mainpage", true)
|
|
|
|
.Case("subpage", true)
|
|
|
|
.Case("ref", true)
|
|
|
|
|
|
|
|
.Default(false);
|
|
|
|
|
|
|
|
if (Result)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
for (VerbatimLineCommandVector::const_iterator
|
|
|
|
I = VerbatimLineCommands.begin(),
|
|
|
|
E = VerbatimLineCommands.end();
|
|
|
|
I != E; ++I)
|
|
|
|
if (I->Name == Name)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-08-10 02:20:29 +08:00
|
|
|
bool CommandTraits::isDeclarationCommand(StringRef Name) const {
|
|
|
|
return llvm::StringSwitch<bool>(Name)
|
|
|
|
// Doxygen commands.
|
|
|
|
.Case("fn", true)
|
|
|
|
.Case("var", true)
|
|
|
|
.Case("property", true)
|
|
|
|
.Case("typedef", true)
|
|
|
|
|
|
|
|
.Case("overload", true)
|
|
|
|
|
|
|
|
// HeaderDoc commands.
|
|
|
|
.Case("class", true)
|
|
|
|
.Case("interface", true)
|
|
|
|
.Case("protocol", true)
|
|
|
|
.Case("category", true)
|
|
|
|
.Case("template", true)
|
|
|
|
.Case("function", true)
|
|
|
|
.Case("method", true)
|
|
|
|
.Case("callback", true)
|
|
|
|
.Case("var", true)
|
|
|
|
.Case("const", true)
|
|
|
|
.Case("constant", true)
|
|
|
|
.Case("property", true)
|
|
|
|
.Case("struct", true)
|
|
|
|
.Case("union", true)
|
|
|
|
.Case("typedef", true)
|
|
|
|
.Case("enum", true)
|
|
|
|
|
|
|
|
.Default(false);
|
|
|
|
}
|
|
|
|
|
2012-08-17 04:16:11 +08:00
|
|
|
void CommandTraits::addVerbatimBlockCommand(StringRef StartName,
|
2012-08-09 08:03:17 +08:00
|
|
|
StringRef EndName) {
|
|
|
|
VerbatimBlockCommand VBC;
|
2012-08-17 04:16:11 +08:00
|
|
|
VBC.StartName = StartName;
|
2012-08-09 08:03:17 +08:00
|
|
|
VBC.EndName = EndName;
|
|
|
|
VerbatimBlockCommands.push_back(VBC);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CommandTraits::addVerbatimLineCommand(StringRef Name) {
|
|
|
|
VerbatimLineCommand VLC;
|
|
|
|
VLC.Name = Name;
|
|
|
|
VerbatimLineCommands.push_back(VLC);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end namespace comments
|
|
|
|
} // end namespace clang
|
|
|
|
|