aboutsummaryrefslogtreecommitdiffstats
path: root/Scanner.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2014-12-18 01:53:18 +0800
committerLefteris Karapetsas <lefteris@refu.co>2014-12-18 22:03:45 +0800
commitd3234c51b9de3548bef5a2afd0fc55851fce43d7 (patch)
tree16cd0a7d1fd260e0e278df1ac27ec07cadea7355 /Scanner.cpp
parenta98afc8eaa20146359dd212fc2eb0bd0fe18d893 (diff)
downloaddexon-solidity-d3234c51b9de3548bef5a2afd0fc55851fce43d7.tar.gz
dexon-solidity-d3234c51b9de3548bef5a2afd0fc55851fce43d7.tar.zst
dexon-solidity-d3234c51b9de3548bef5a2afd0fc55851fce43d7.zip
Work in progress for /** ... */ natspec comments
- Work in progress on the scanner for recognizing the second type of doxygen comments for Natspec.
Diffstat (limited to 'Scanner.cpp')
-rw-r--r--Scanner.cpp58
1 files changed, 54 insertions, 4 deletions
diff --git a/Scanner.cpp b/Scanner.cpp
index 1a21149a..2e9b7b45 100644
--- a/Scanner.cpp
+++ b/Scanner.cpp
@@ -219,7 +219,7 @@ Token::Value Scanner::skipSingleLineComment()
return Token::WHITESPACE;
}
-Token::Value Scanner::scanDocumentationComment()
+Token::Value Scanner::scanSingleLineDocComment()
{
LiteralScope literal(this, LITERAL_TYPE_COMMENT);
advance(); //consume the last '/'
@@ -250,7 +250,6 @@ Token::Value Scanner::scanDocumentationComment()
Token::Value Scanner::skipMultiLineComment()
{
- solAssert(m_char == '*', "");
advance();
while (!isSourcePastEndOfInput())
{
@@ -270,6 +269,43 @@ Token::Value Scanner::skipMultiLineComment()
return Token::ILLEGAL;
}
+Token::Value Scanner::scanMultiLineDocComment()
+{
+ LiteralScope literal(this, LITERAL_TYPE_COMMENT);
+ bool endFound = false;
+
+ advance(); //consume the last '*'
+ while (!isSourcePastEndOfInput())
+ {
+ // skip starting '*' in multiine comments
+ if (isLineTerminator(m_char))
+ {
+ skipWhitespace();
+ if (!m_source.isPastEndOfInput(2) && m_source.get(1) == '*' && m_source.get(2) != '/')
+ {
+ addCommentLiteralChar('\n');
+ m_char = m_source.advanceAndGet(3);
+ }
+ else
+ addCommentLiteralChar('\n');
+ }
+
+ if (!m_source.isPastEndOfInput(1) && m_source.get(0) == '*' && m_source.get(1) == '/')
+ {
+ m_source.advanceAndGet(2);
+ endFound = true;
+ break;
+ }
+ addCommentLiteralChar(m_char);
+ advance();
+ }
+ literal.complete();
+ if (!endFound)
+ return Token::ILLEGAL;
+ else
+ return Token::COMMENT_LITERAL;
+}
+
void Scanner::scanToken()
{
m_nextToken.literal.clear();
@@ -381,7 +417,7 @@ void Scanner::scanToken()
{
Token::Value comment;
m_nextSkippedComment.location.start = getSourcePos();
- comment = scanDocumentationComment();
+ comment = scanSingleLineDocComment();
m_nextSkippedComment.location.end = getSourcePos();
m_nextSkippedComment.token = comment;
token = Token::WHITESPACE;
@@ -390,7 +426,21 @@ void Scanner::scanToken()
token = skipSingleLineComment();
}
else if (m_char == '*')
- token = skipMultiLineComment();
+ {
+ if (!advance()) /* slash star comment before EOS */
+ token = Token::WHITESPACE;
+ else if (m_char == '*')
+ {
+ Token::Value comment;
+ m_nextSkippedComment.location.start = getSourcePos();
+ 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