Corrects comment literal that span too long.

This commit is contained in:
Erik Kundt committed 2020-02-14 15:53:35 +01:00
1 parent b43751d65e
commit cfc70ede5c
2 files changed
+13 -9

No files matched your search

+11 -8
View File
@@ -306,19 +306,24 @@ bool Scanner::tryScanEndOfLine()
return false;
}
Token Scanner::scanSingleLineDocComment()
int Scanner::scanSingleLineDocComment()
{
LiteralScope literal(this, LITERAL_TYPE_COMMENT);
int endPosition = m_source->position();
advance(); //consume the last '/' at ///
skipWhitespaceExceptUnicodeLinebreak();
while (!isSourcePastEndOfInput())
{
endPosition = m_source->position();
if (tryScanEndOfLine())
{
// check if next line is also a documentation comment
skipWhitespace();
// Check if next line is also a single-line comment.
// If any whitespaces were skipped, use source position before.
if (!skipWhitespace())
endPosition = m_source->position();
if (!m_source->isPastEndOfInput(3) &&
m_source->get(0) == '/' &&
m_source->get(1) == '/' &&
@@ -338,7 +343,7 @@ Token Scanner::scanSingleLineDocComment()
advance();
}
literal.complete();
return Token::CommentLiteral;
return endPosition;
}
Token Scanner::skipMultiLineComment()
@@ -426,12 +431,10 @@ Token Scanner::scanSlash()
else if (m_char == '/')
{
// doxygen style /// comment
Token comment;
m_skippedComments[NextNext].location.start = firstSlashPosition;
m_skippedComments[NextNext].location.source = m_source;
comment = scanSingleLineDocComment();
m_skippedComments[NextNext].location.end = sourcePos();
m_skippedComments[NextNext].token = comment;
m_skippedComments[NextNext].token = Token::CommentLiteral;
m_skippedComments[NextNext].location.end = scanSingleLineDocComment();
return Token::Whitespace;
}
else
+2 -1
View File
@@ -229,7 +229,8 @@ private:
Token scanString();
Token scanHexString();
Token scanSingleLineDocComment();
/// Scans a single line comment and returns its corrected end position.
int scanSingleLineDocComment();
Token scanMultiLineDocComment();
/// Scans a slash '/' and depending on the characters returns the appropriate token
Token scanSlash();