Fix for sol scanner where empty multiline comment became Natspec comment

This commit is contained in:
Lefteris Karapetsas 2015-01-05 16:37:43 +01:00
parent 7b3f0e549d
commit b4712773d3
2 changed files with 17 additions and 7 deletions

View File

@ -285,8 +285,6 @@ Token::Value Scanner::scanMultiLineDocComment()
bool endFound = false; bool endFound = false;
bool charsAdded = false; bool charsAdded = false;
advance(); //consume the last '*' at /**
skipWhitespaceExceptLF();
while (!isSourcePastEndOfInput()) while (!isSourcePastEndOfInput())
{ {
//handle newlines in multline comments //handle newlines in multline comments
@ -353,12 +351,23 @@ Token::Value Scanner::scanSlash()
if (!advance()) /* slash star comment before EOS */ if (!advance()) /* slash star comment before EOS */
return Token::WHITESPACE; return Token::WHITESPACE;
else if (m_char == '*') else if (m_char == '*')
{
advance(); //consume the last '*' at /**
skipWhitespaceExceptLF();
// special case of a closed normal multiline comment
if (!m_source.isPastEndOfInput() && m_source.get(0) == '/')
{
advance(); //skip the closing slash
}
else // we actually have a multiline documentation comment
{ {
Token::Value comment; Token::Value comment;
m_nextSkippedComment.location.start = firstSlashPosition; m_nextSkippedComment.location.start = firstSlashPosition;
comment = scanMultiLineDocComment(); comment = scanMultiLineDocComment();
m_nextSkippedComment.location.end = getSourcePos(); m_nextSkippedComment.location.end = getSourcePos();
m_nextSkippedComment.token = comment; m_nextSkippedComment.token = comment;
}
return Token::WHITESPACE; return Token::WHITESPACE;
} }
else else

View File

@ -119,6 +119,7 @@ public:
{ {
return m_currentToken.token; return m_currentToken.token;
} }
Location getCurrentLocation() const { return m_currentToken.location; } Location getCurrentLocation() const { return m_currentToken.location; }
std::string const& getCurrentLiteral() const { return m_currentToken.literal; } std::string const& getCurrentLiteral() const { return m_currentToken.literal; }
///@} ///@}