Added support for parsing of missing doxygen commands. Now parser produces correct parse tree for every doxygen tag, at least for those included in the testcase. Also added the test with all the tags, even those that will be ignored later.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13322 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
34dc515a40
commit
4ce9f2361c
4 changed files with 401 additions and 17 deletions
|
|
@ -29,7 +29,10 @@ const int sectionIndicatorsSize = sizeof(sectionIndicators) / sizeof(*sectionInd
|
|||
|
||||
/* All of the doxygen commands divided up by how they are parsed */
|
||||
const char *simpleCommands[] = {
|
||||
"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%", "\"", ".", "::", "endcond"};
|
||||
"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%", "\"", ".", "::", "endcond",
|
||||
"callgraph", "callergraph", "showinitializer", "hideinitializer", "internal",
|
||||
"nosubgrouping", "public", "publicsection", "private", "privatesection",
|
||||
"protected", "protectedsection", "tableofcontents"};
|
||||
const int simpleCommandsSize = sizeof(simpleCommands) / sizeof(*simpleCommands);
|
||||
|
||||
const char *ignoredSimpleCommands[] = {
|
||||
|
|
@ -38,11 +41,12 @@ const int ignoredSimpleCommandsSize = sizeof(ignoredSimpleCommands) / sizeof(*ig
|
|||
|
||||
const char *commandWords[] = {
|
||||
"a", "b", "c", "e", "em", "p", "def", "enum", "package", "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include",
|
||||
"includelineno"};
|
||||
"includelineno", "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude", "extends", "implements", "memberof", "related",
|
||||
"relatedalso"};
|
||||
const int commandWordsSize = sizeof(commandWords) / sizeof(*commandWords);
|
||||
|
||||
const char *ignoredCommandWords[] = {
|
||||
"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"};
|
||||
"nothing at the moment"};
|
||||
const int ignoredCommandWordsSize = sizeof(ignoredCommandWords) / sizeof(*ignoredCommandWords);
|
||||
|
||||
const char *commandLines[] = {
|
||||
|
|
@ -56,7 +60,7 @@ const int ignoreCommandLinesSize = sizeof(ignoreCommandLines) / sizeof(*ignoreCo
|
|||
const char *commandParagraph[] = {
|
||||
"partofdescription", "result", "return", "returns", "remarks", "remark", "since", "test", "sa", "see", "pre", "post", "details", "invariant",
|
||||
"deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author", "authors", "cite",
|
||||
"copyright"};
|
||||
"copyright", "short"};
|
||||
const int commandParagraphSize = sizeof(commandParagraph) / sizeof(*commandParagraph);
|
||||
|
||||
const char *ignoreCommandParagraphs[] = {
|
||||
|
|
@ -64,7 +68,7 @@ const char *ignoreCommandParagraphs[] = {
|
|||
const int ignoreCommandParagraphsSize = sizeof(ignoreCommandParagraphs) / sizeof(*ignoreCommandParagraphs);
|
||||
|
||||
const char *commandEndCommands[] = {
|
||||
"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", "verbatim", "xmlonly", "link"};
|
||||
"htmlonly", "latexonly", "manonly", "xmlonly", "link", "rtfonly"};
|
||||
const int commandEndCommandsSize = sizeof(commandEndCommands) / sizeof(*commandEndCommands);
|
||||
|
||||
const char *commandWordParagraphs[] = {
|
||||
|
|
@ -72,7 +76,7 @@ const char *commandWordParagraphs[] = {
|
|||
const int commandWordParagraphsSize = sizeof(commandWordParagraphs) / sizeof(*commandWordParagraphs);
|
||||
|
||||
const char *commandWordLines[] = {
|
||||
"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"};
|
||||
"page", "subsection", "subsubsection", "section", "paragraph", "defgroup", "snippet", "mainpage"};
|
||||
const int commandWordLinesSize = sizeof(commandWordLines) / sizeof(*commandWordLines);
|
||||
|
||||
const char *commandWordOWordOWords[] = {
|
||||
|
|
@ -85,14 +89,14 @@ const int commandOWordsSize = sizeof(commandOWords) / sizeof(*commandOWords);
|
|||
|
||||
const char *commandErrorThrowings[] = {
|
||||
"annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header",
|
||||
"headerfilestd::list", "inherit", "l", "postheader", "private", "privatesection", "protected",
|
||||
"protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly",
|
||||
"endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endif", "else"};
|
||||
"headerfilestd::list", "inherit", "l", "postheader", "endcode", "enddot", "endmsc", "endhtmlonly",
|
||||
"endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endif", "else",
|
||||
"endrtfonly"};
|
||||
const int commandErrorThrowingsSize = sizeof(commandErrorThrowings) / sizeof(*commandErrorThrowings);
|
||||
|
||||
const char *commandUniques[] = {
|
||||
"xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li",
|
||||
"if", "ifnot", "elseif", "else", "mscfile"};
|
||||
"if", "ifnot", "elseif", "else", "mscfile", "code", "verbatim", "f{", "f[", "f$", "dot", "msc"};
|
||||
const int commandUniquesSize = sizeof(commandUniques) / sizeof(*commandUniques);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -227,11 +227,11 @@ std::list < Token >::iterator DoxygenParser::getEndOfSection(std::string theComm
|
|||
std::list < Token >::iterator DoxygenParser::getEndCommand(std::string theCommand, TokenList & tokList) {
|
||||
std::list < Token >::iterator endOfCommand = tokList.iteratorCopy();
|
||||
while (endOfCommand != tokList.end()) {
|
||||
endOfCommand++;
|
||||
if ((*endOfCommand).tokenType == COMMAND) {
|
||||
if (theCommand == (*endOfCommand).tokenString) {
|
||||
return endOfCommand;
|
||||
}
|
||||
endOfCommand++;
|
||||
}
|
||||
}
|
||||
//End command not found
|
||||
|
|
@ -263,7 +263,9 @@ int DoxygenParser::addCommandWord(std::string theCommand, TokenList & tokList, s
|
|||
cout << "Parsing " << theCommand << endl;
|
||||
std::string name = getNextWord(tokList);
|
||||
if (!name.empty()) {
|
||||
doxyList.push_back(DoxygenEntity(theCommand, name));
|
||||
std::list < DoxygenEntity > aNewList;
|
||||
aNewList.push_back(DoxygenEntity("plainstd::string", name));
|
||||
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
|
||||
return 1;
|
||||
} else
|
||||
tokList.printListError("No word followed " + theCommand + " command. Not added");
|
||||
|
|
@ -322,8 +324,15 @@ int DoxygenParser::ignoreCommandParagraph(std::string theCommand, TokenList & to
|
|||
int DoxygenParser::addCommandEndCommand(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
|
||||
if (noisy)
|
||||
cout << "Parsing " << theCommand << endl;
|
||||
std::string description = getStringTilEndCommand("end" + theCommand, tokList);
|
||||
doxyList.push_back(DoxygenEntity(theCommand, description));
|
||||
std::list < Token >::iterator endCommand = getEndCommand("end" + theCommand, tokList);
|
||||
if (endCommand == tokList.end()) {
|
||||
tokList.printListError("Expected end" + theCommand);
|
||||
return 0;
|
||||
}
|
||||
std::list < DoxygenEntity > aNewList;
|
||||
aNewList = parse(endCommand, tokList);
|
||||
tokList.next();
|
||||
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -398,6 +407,7 @@ int DoxygenParser::addCommandErrorThrow(std::string theCommand, TokenList & tokL
|
|||
}
|
||||
|
||||
int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
|
||||
static std::map<std::string, std::string> endCommands;
|
||||
std::list < DoxygenEntity > aNewList;
|
||||
if (theCommand == "arg" || theCommand == "li") {
|
||||
std::list < Token >::iterator endOfSection = getEndOfSection(theCommand, tokList);
|
||||
|
|
@ -524,6 +534,39 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList,
|
|||
aNewList.push_back(DoxygenEntity("plainstd::string", text));
|
||||
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
|
||||
}
|
||||
// \code ... \endcode
|
||||
// \verbatim ... \endverbatim
|
||||
// \dot dotcode \enddot
|
||||
// \msc msccode \endmsc
|
||||
// \f[ ... \f]
|
||||
// \f{ ... \f}
|
||||
// \f{env}{ ... \f}
|
||||
// \f$ ... \f$
|
||||
else if (theCommand == "code" || theCommand == "verbatim"
|
||||
|| theCommand == "dot" || theCommand == "msc"
|
||||
|| theCommand == "f[" || theCommand == "f{"
|
||||
|| theCommand == "f$") {
|
||||
if (!endCommands.size()) {
|
||||
// fill in static table of end commands
|
||||
endCommands["f["] = "f]";
|
||||
endCommands["f{"] = "f}";
|
||||
endCommands["f$"] = "f$";
|
||||
}
|
||||
if (noisy)
|
||||
cout << "Parsing " << theCommand << endl;
|
||||
|
||||
std::string endCommand;
|
||||
std::map <std::string, std::string>::iterator it;
|
||||
it = endCommands.find(theCommand);
|
||||
if (it != endCommands.end())
|
||||
endCommand = it->second;
|
||||
else
|
||||
endCommand = "end" + theCommand;
|
||||
|
||||
std::string content = getStringTilEndCommand(endCommand, tokList);
|
||||
aNewList.push_back(DoxygenEntity("plainstd::string", content));
|
||||
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
|
||||
}
|
||||
// \dotfile <file> ["caption"]
|
||||
// \mscfile <file> ["caption"]
|
||||
else if (theCommand == "dotfile" || theCommand == "mscfile") {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c
|
|||
string::size_type pos, lastPos = 0;
|
||||
string currentWord;
|
||||
while (true) {
|
||||
isPlainString = false;
|
||||
pos = doxygenComment.find_first_of("\t\n ", lastPos);
|
||||
if (pos == string::npos)
|
||||
pos = doxygenComment.size();
|
||||
|
|
@ -55,9 +56,7 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c
|
|||
|
||||
if (isPlainString) {
|
||||
// handle quoted words
|
||||
string::size_type qPos = currentWord.find('"', 0);
|
||||
if (qPos != string::npos) {
|
||||
lastPos += qPos;
|
||||
if (currentWord[0] == '"') {
|
||||
pos = doxygenComment.find_first_of("\"\n", lastPos + 1);
|
||||
if (pos == string::npos)
|
||||
pos = doxygenComment.size();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue