aboutsummaryrefslogtreecommitdiffstats
path: root/Scanner.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2014-11-28 01:57:50 +0800
committerLefteris Karapetsas <lefteris@refu.co>2014-11-28 01:57:50 +0800
commite11e651929aaffe23d03b706c6770f92a57af6a6 (patch)
treea894081ede7ab5599d04db326be27619ff4d8684 /Scanner.cpp
parent6ddfebafae2ec419ea40cd1907a700ba9812593c (diff)
downloaddexon-solidity-e11e651929aaffe23d03b706c6770f92a57af6a6.tar.gz
dexon-solidity-e11e651929aaffe23d03b706c6770f92a57af6a6.tar.zst
dexon-solidity-e11e651929aaffe23d03b706c6770f92a57af6a6.zip
Solidity work for documentation strings
- Still a work in progress - Parser now properly gets each function's doc comment - Small changes in the scanner - Multiline comments are considered
Diffstat (limited to 'Scanner.cpp')
-rw-r--r--Scanner.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/Scanner.cpp b/Scanner.cpp
index dd18a320..c40d98af 100644
--- a/Scanner.cpp
+++ b/Scanner.cpp
@@ -180,10 +180,26 @@ Token::Value Scanner::skipSingleLineComment()
/// For the moment this function simply consumes a single line triple slash doc comment
Token::Value Scanner::scanDocumentationComment()
{
- LiteralScope literal(this);
+ LiteralScope literal(this, LITERAL_TYPE_COMMENT);
advance(); //consume the last '/'
- while (!isSourcePastEndOfInput() && !isLineTerminator(m_char))
+ while (!isSourcePastEndOfInput())
{
+ if (isLineTerminator(m_char))
+ {
+ // check if next line is also a documentation comment
+ skipWhitespace();
+ if (m_source.get(0) == '/' &&
+ m_source.get(1) == '/' &&
+ m_source.get(2) == '/' &&
+ !m_source.isPastEndOfInput(3))
+ {
+ m_source.advanceBy(3);
+ addCommentLiteralChar('\n');
+ }
+ else
+ break; // next line is not a documentation comment, we are done
+
+ }
addCommentLiteralChar(m_char);
advance();
}
@@ -474,7 +490,7 @@ Token::Value Scanner::scanString()
{
char const quote = m_char;
advance(); // consume quote
- LiteralScope literal(this);
+ LiteralScope literal(this, LITERAL_TYPE_STRING);
while (m_char != quote && !isSourcePastEndOfInput() && !isLineTerminator(m_char))
{
char c = m_char;
@@ -505,7 +521,7 @@ void Scanner::scanDecimalDigits()
Token::Value Scanner::scanNumber(char _charSeen)
{
enum { DECIMAL, HEX, BINARY } kind = DECIMAL;
- LiteralScope literal(this);
+ LiteralScope literal(this, LITERAL_TYPE_NUMBER);
if (_charSeen == '.')
{
// we have already seen a decimal point of the float
@@ -758,7 +774,7 @@ Token::Value Scanner::scanIdentifierOrKeyword()
{
if (asserts(isIdentifierStart(m_char)))
BOOST_THROW_EXCEPTION(InternalCompilerError());
- LiteralScope literal(this);
+ LiteralScope literal(this, LITERAL_TYPE_STRING);
addLiteralCharAndAdvance();
// Scan the rest of the identifier characters.
while (isIdentifierPart(m_char))
@@ -777,6 +793,14 @@ char CharStream::advanceAndGet()
return get();
}
+void CharStream::advanceBy(size_t _chars)
+{
+ if (asserts(!isPastEndOfInput(_chars)))
+ BOOST_THROW_EXCEPTION(InternalCompilerError());
+
+ m_pos += _chars;
+}
+
char CharStream::rollback(size_t _amount)
{
if (asserts(m_pos >= _amount))