Changed quoted strings handling. Also not missing any doxygen commands now.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13563 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
cecc793782
commit
342bff6ec9
3 changed files with 52 additions and 48 deletions
|
|
@ -21,7 +21,7 @@ check(doxygen_translate_all_tags.function.__doc__, ''
|
||||||
''
|
''
|
||||||
' SomeLatexIndex '
|
' SomeLatexIndex '
|
||||||
''
|
''
|
||||||
' someGroupSome title '
|
' someGroup"Some title" '
|
||||||
''
|
''
|
||||||
' theAnchor'
|
' theAnchor'
|
||||||
''
|
''
|
||||||
|
|
@ -84,8 +84,8 @@ check(doxygen_translate_all_tags.function.__doc__, ''
|
||||||
' digraph example { '
|
' digraph example { '
|
||||||
' node [shape=record, fontname=Helvetica, fontsize=10]; '
|
' node [shape=record, fontname=Helvetica, fontsize=10]; '
|
||||||
''
|
''
|
||||||
' b [ label="class B" URL="\ref B"]; '
|
' b [ label="class B" URL=" B"]; '
|
||||||
' c [ label="class C" URL="\ref C"]; '
|
' c [ label="class C" URL=" C"]; '
|
||||||
' b -> c [ arrowhead="open", style="dashed" ]; '
|
' b -> c [ arrowhead="open", style="dashed" ]; '
|
||||||
' } '
|
' } '
|
||||||
''
|
''
|
||||||
|
|
@ -171,9 +171,9 @@ check(doxygen_translate_all_tags.function.__doc__, ''
|
||||||
' someThing'
|
' someThing'
|
||||||
''
|
''
|
||||||
' Sender,Receiver; '
|
' Sender,Receiver; '
|
||||||
' Sender->Receiver [label="Command()", URL="\ref '
|
' Sender->Receiver [label="Command()", URL=" '
|
||||||
' Receiver::Command()"]; '
|
' Receiver::Command()"]; '
|
||||||
' Sender<-Receiver [label="Ack()", URL="\ref '
|
' Sender<-Receiver [label="Ack()", URL=" '
|
||||||
' Ack()", ID="1"]; '
|
' Ack()", ID="1"]; '
|
||||||
''
|
''
|
||||||
' mscFile.mscThe caption'
|
' mscFile.mscThe caption'
|
||||||
|
|
@ -312,6 +312,7 @@ check(doxygen_translate_all_tags.function.__doc__, ''
|
||||||
''
|
''
|
||||||
' This will only appear in XML '
|
' This will only appear in XML '
|
||||||
''
|
''
|
||||||
|
' todo"Todo"Todo List'
|
||||||
''
|
''
|
||||||
' Here goes test of symbols: '
|
' Here goes test of symbols: '
|
||||||
' $@\&~<>#%".::'
|
' $@\&~<>#%".::'
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,23 @@ int DoxygenParser::commandBelongs(std::string theCommand) {
|
||||||
std::string DoxygenParser::getNextWord(TokenList & tokList) {
|
std::string DoxygenParser::getNextWord(TokenList & tokList) {
|
||||||
Token nextToken = tokList.peek();
|
Token nextToken = tokList.peek();
|
||||||
if (nextToken.tokenType == PLAINSTRING) {
|
if (nextToken.tokenType == PLAINSTRING) {
|
||||||
|
// handle quoted strings as words
|
||||||
|
if (nextToken.tokenString[0] == '"'
|
||||||
|
&& nextToken.tokenString[nextToken.tokenString.size() - 1] != '"') {
|
||||||
|
string word = nextToken.tokenString + " ";
|
||||||
nextToken = tokList.next();
|
nextToken = tokList.next();
|
||||||
|
while (true) {
|
||||||
|
string nextWord = getNextWord(tokList);
|
||||||
|
if (!nextWord.size()) // maybe report unterminated string error
|
||||||
|
return word;
|
||||||
|
word += nextWord;
|
||||||
|
if (word[word.size() - 1] == '"') // strip quotes
|
||||||
|
return word.substr(1, word.size() - 2);
|
||||||
|
word += " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tokList.next();
|
||||||
return nextToken.tokenString;
|
return nextToken.tokenString;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
|
@ -120,7 +136,6 @@ std::list < Token >::iterator DoxygenParser::getOneLine(TokenList & tokList) {
|
||||||
//endOfLine++;
|
//endOfLine++;
|
||||||
return endOfLine;
|
return endOfLine;
|
||||||
}
|
}
|
||||||
//cout << (* endOfLine).toString();
|
|
||||||
endOfLine++;
|
endOfLine++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -390,6 +405,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList,
|
||||||
aNewList.push_front(DoxygenEntity("plainstd::string", title));
|
aNewList.push_front(DoxygenEntity("plainstd::string", title));
|
||||||
aNewList.push_front(DoxygenEntity("plainstd::string", heading));
|
aNewList.push_front(DoxygenEntity("plainstd::string", heading));
|
||||||
aNewList.push_front(DoxygenEntity("plainstd::string", key));
|
aNewList.push_front(DoxygenEntity("plainstd::string", key));
|
||||||
|
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
// \ingroup (<groupname> [<groupname> <groupname>])
|
// \ingroup (<groupname> [<groupname> <groupname>])
|
||||||
|
|
|
||||||
|
|
@ -28,20 +28,25 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c
|
||||||
|
|
||||||
bool isPlainString = false;
|
bool isPlainString = false;
|
||||||
string::size_type pos, lastPos = 0;
|
string::size_type pos, lastPos = 0;
|
||||||
|
char prevChar = doxygenComment[lastPos];
|
||||||
string currentWord;
|
string currentWord;
|
||||||
while (true) {
|
while (true) {
|
||||||
isPlainString = false;
|
isPlainString = false;
|
||||||
pos = doxygenComment.find_first_of("\t\n ", lastPos);
|
pos = doxygenComment.find_first_of("\\@\t\n ", lastPos);
|
||||||
if (pos == string::npos)
|
if (pos == string::npos)
|
||||||
pos = doxygenComment.size();
|
pos = doxygenComment.size();
|
||||||
if (pos > lastPos) {
|
|
||||||
currentWord = doxygenComment.substr(lastPos, pos-lastPos);
|
currentWord = doxygenComment.substr(lastPos, pos-lastPos);
|
||||||
if (currentWord[0] == '\\' || currentWord[0] == '@') {
|
if (prevChar == '\n')
|
||||||
|
tokList.m_tokenList.push_back(Token(END_LINE, "\n"));
|
||||||
|
else if (prevChar == '\\' || prevChar == '@') {
|
||||||
// it's a doxygen command
|
// it's a doxygen command
|
||||||
currentWord = currentWord.substr(1, currentWord.length() - 1);
|
// hack to get commands like \\ or \@ or @\ or @@
|
||||||
|
if (doxygenComment[pos] == '@' || doxygenComment[pos] == '\\')
|
||||||
|
currentWord += doxygenComment[pos];
|
||||||
tokList.m_tokenList.push_back(Token(COMMAND, currentWord));
|
tokList.m_tokenList.push_back(Token(COMMAND, currentWord));
|
||||||
}
|
}
|
||||||
else if (currentWord[0] == '!' || currentWord[0] == '*' || currentWord[0] == '/') {
|
else if (currentWord.size() && (currentWord[0] == '!' || currentWord[0] == '*' || currentWord[0] == '/')) {
|
||||||
// check if it's one of the '!!!', '***', '///' of any length
|
// check if it's one of the '!!!', '***', '///' of any length
|
||||||
char c = currentWord[0];
|
char c = currentWord[0];
|
||||||
isPlainString = false;
|
isPlainString = false;
|
||||||
|
|
@ -54,31 +59,13 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c
|
||||||
else
|
else
|
||||||
isPlainString = true;
|
isPlainString = true;
|
||||||
|
|
||||||
if (isPlainString) {
|
if (isPlainString && currentWord.size())
|
||||||
// handle quoted words
|
|
||||||
if (currentWord[0] == '"') {
|
|
||||||
pos = doxygenComment.find_first_of("\"\n", lastPos + 1);
|
|
||||||
if (pos == string::npos)
|
|
||||||
pos = doxygenComment.size();
|
|
||||||
if (pos == doxygenComment.size() || doxygenComment[pos] != '"') {
|
|
||||||
// hack to print error message before the list is constructed
|
|
||||||
tokList.m_tokenListIter = tokList.m_tokenList.end();
|
|
||||||
tokList.printListError("Unterminated string");
|
|
||||||
}
|
|
||||||
// also strip quotes
|
|
||||||
currentWord = doxygenComment.substr(lastPos + 1, pos-lastPos-1);
|
|
||||||
}
|
|
||||||
if (currentWord.size())
|
|
||||||
tokList.m_tokenList.push_back(Token(PLAINSTRING, currentWord));
|
tokList.m_tokenList.push_back(Token(PLAINSTRING, currentWord));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
prevChar = doxygenComment[pos];
|
||||||
lastPos = pos + 1;
|
lastPos = pos + 1;
|
||||||
if (lastPos >= doxygenComment.size())
|
if (lastPos >= doxygenComment.size())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (doxygenComment[pos] == '\n')
|
|
||||||
tokList.m_tokenList.push_back(Token(END_LINE, "\n"));
|
|
||||||
}
|
}
|
||||||
tokList.m_tokenListIter = tokList.m_tokenList.begin();
|
tokList.m_tokenListIter = tokList.m_tokenList.begin();
|
||||||
return tokList;
|
return tokList;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue