mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Factoring forward slash scanning out to its own function
This commit is contained in:
parent
0cdacde3b9
commit
1da53d1681
85
Scanner.cpp
85
Scanner.cpp
@ -326,9 +326,52 @@ Token::Value Scanner::scanMultiLineDocComment()
|
|||||||
return Token::COMMENT_LITERAL;
|
return Token::COMMENT_LITERAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Token::Value Scanner::scanSlash()
|
||||||
|
{
|
||||||
|
int firstSlashPosition = getSourcePos();
|
||||||
|
advance();
|
||||||
|
if (m_char == '/')
|
||||||
|
{
|
||||||
|
if (!advance()) /* double slash comment directly before EOS */
|
||||||
|
return Token::WHITESPACE;
|
||||||
|
else if (m_char == '/')
|
||||||
|
{
|
||||||
|
// doxygen style /// comment
|
||||||
|
Token::Value comment;
|
||||||
|
m_nextSkippedComment.location.start = firstSlashPosition;
|
||||||
|
comment = scanSingleLineDocComment();
|
||||||
|
m_nextSkippedComment.location.end = getSourcePos();
|
||||||
|
m_nextSkippedComment.token = comment;
|
||||||
|
return Token::WHITESPACE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return skipSingleLineComment();
|
||||||
|
}
|
||||||
|
else if (m_char == '*')
|
||||||
|
{
|
||||||
|
// doxygen style /** natspec comment
|
||||||
|
if (!advance()) /* slash star comment before EOS */
|
||||||
|
return Token::WHITESPACE;
|
||||||
|
else if (m_char == '*')
|
||||||
|
{
|
||||||
|
Token::Value comment;
|
||||||
|
m_nextSkippedComment.location.start = firstSlashPosition;
|
||||||
|
comment = scanMultiLineDocComment();
|
||||||
|
m_nextSkippedComment.location.end = getSourcePos();
|
||||||
|
m_nextSkippedComment.token = comment;
|
||||||
|
return Token::WHITESPACE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return skipMultiLineComment();
|
||||||
|
}
|
||||||
|
else if (m_char == '=')
|
||||||
|
return selectToken(Token::ASSIGN_DIV);
|
||||||
|
else
|
||||||
|
return Token::DIV;
|
||||||
|
}
|
||||||
|
|
||||||
void Scanner::scanToken()
|
void Scanner::scanToken()
|
||||||
{
|
{
|
||||||
int savedPosition;
|
|
||||||
m_nextToken.literal.clear();
|
m_nextToken.literal.clear();
|
||||||
m_nextSkippedComment.literal.clear();
|
m_nextSkippedComment.literal.clear();
|
||||||
Token::Value token;
|
Token::Value token;
|
||||||
@ -429,45 +472,7 @@ void Scanner::scanToken()
|
|||||||
break;
|
break;
|
||||||
case '/':
|
case '/':
|
||||||
// / // /* /=
|
// / // /* /=
|
||||||
savedPosition = getSourcePos();
|
token = scanSlash();
|
||||||
advance();
|
|
||||||
if (m_char == '/')
|
|
||||||
{
|
|
||||||
if (!advance()) /* double slash comment directly before EOS */
|
|
||||||
token = Token::WHITESPACE;
|
|
||||||
else if (m_char == '/')
|
|
||||||
{
|
|
||||||
Token::Value comment;
|
|
||||||
m_nextSkippedComment.location.start = savedPosition;
|
|
||||||
comment = scanSingleLineDocComment();
|
|
||||||
m_nextSkippedComment.location.end = getSourcePos();
|
|
||||||
m_nextSkippedComment.token = comment;
|
|
||||||
token = Token::WHITESPACE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
token = skipSingleLineComment();
|
|
||||||
}
|
|
||||||
else if (m_char == '*')
|
|
||||||
{
|
|
||||||
// /** doxygent style natspec comment
|
|
||||||
if (!advance()) /* slash star comment before EOS */
|
|
||||||
token = Token::WHITESPACE;
|
|
||||||
else if (m_char == '*')
|
|
||||||
{
|
|
||||||
Token::Value comment;
|
|
||||||
m_nextSkippedComment.location.start = savedPosition;
|
|
||||||
comment = scanMultiLineDocComment();
|
|
||||||
m_nextSkippedComment.location.end = getSourcePos();
|
|
||||||
m_nextSkippedComment.token = comment;
|
|
||||||
token = Token::WHITESPACE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
token = skipMultiLineComment();
|
|
||||||
}
|
|
||||||
else if (m_char == '=')
|
|
||||||
token = selectToken(Token::ASSIGN_DIV);
|
|
||||||
else
|
|
||||||
token = Token::DIV;
|
|
||||||
break;
|
break;
|
||||||
case '&':
|
case '&':
|
||||||
// & && &=
|
// & && &=
|
||||||
|
@ -194,6 +194,8 @@ private:
|
|||||||
Token::Value scanString();
|
Token::Value scanString();
|
||||||
Token::Value scanSingleLineDocComment();
|
Token::Value scanSingleLineDocComment();
|
||||||
Token::Value scanMultiLineDocComment();
|
Token::Value scanMultiLineDocComment();
|
||||||
|
/// Scans a slash '/' and depending on the characters returns the appropriate token
|
||||||
|
Token::Value scanSlash();
|
||||||
|
|
||||||
/// Scans an escape-sequence which is part of a string and adds the
|
/// Scans an escape-sequence which is part of a string and adds the
|
||||||
/// decoded character to the current literal. Returns true if a pattern
|
/// decoded character to the current literal. Returns true if a pattern
|
||||||
|
Loading…
Reference in New Issue
Block a user