aboutsummaryrefslogtreecommitdiffstats
path: root/Scanner.h
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2014-11-21 22:35:17 +0800
committerchriseth <c@ethdev.com>2014-11-21 22:35:17 +0800
commitc7b933b4db826e21ea46de6ee2c60d49f512afcc (patch)
treea0b92b759a2492ca3a949fcd738cb0181b597be5 /Scanner.h
parent3ba9649ddea6559bc0dc266dab51136e467e49b8 (diff)
parent3b16ffa8aba740f8e67dd38d34a015a8498f615b (diff)
downloaddexon-solidity-c7b933b4db826e21ea46de6ee2c60d49f512afcc.tar
dexon-solidity-c7b933b4db826e21ea46de6ee2c60d49f512afcc.tar.gz
dexon-solidity-c7b933b4db826e21ea46de6ee2c60d49f512afcc.tar.bz2
dexon-solidity-c7b933b4db826e21ea46de6ee2c60d49f512afcc.tar.lz
dexon-solidity-c7b933b4db826e21ea46de6ee2c60d49f512afcc.tar.xz
dexon-solidity-c7b933b4db826e21ea46de6ee2c60d49f512afcc.tar.zst
dexon-solidity-c7b933b4db826e21ea46de6ee2c60d49f512afcc.zip
Merge pull request #524 from LefterisJP/sol_parse_comments
Solidity scanner taking documentation comments into account
Diffstat (limited to 'Scanner.h')
-rw-r--r--Scanner.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/Scanner.h b/Scanner.h
index 997365f3..5dfe7a33 100644
--- a/Scanner.h
+++ b/Scanner.h
@@ -116,19 +116,28 @@ public:
/// Resets the scanner as if newly constructed with _input as input.
void reset(CharStream const& _source);
- /// Returns the next token and advances input.
+ /// Returns the next token and advances input
Token::Value next();
///@{
///@name Information about the current token
/// Returns the current token
- Token::Value getCurrentToken() { return m_current_token.token; }
+ Token::Value getCurrentToken()
+ {
+ return m_current_token.token;
+ }
Location getCurrentLocation() const { return m_current_token.location; }
std::string const& getCurrentLiteral() const { return m_current_token.literal; }
///@}
///@{
+ ///@name Information about the current comment token
+ Location getCurrentCommentLocation() const { return m_skipped_comment.location; }
+ std::string const& getCurrentCommentLiteral() const { return m_skipped_comment.literal; }
+ ///@}
+
+ ///@{
///@name Information about the next token
/// Returns the next token without advancing input.
@@ -146,7 +155,7 @@ public:
///@}
private:
- // Used for the current and look-ahead token.
+ /// Used for the current and look-ahead token and comments
struct TokenDesc
{
Token::Value token;
@@ -158,6 +167,7 @@ private:
///@name Literal buffer support
inline void startNewLiteral() { m_next_token.literal.clear(); }
inline void addLiteralChar(char c) { m_next_token.literal.push_back(c); }
+ inline void addCommentLiteralChar(char c) { m_next_skipped_comment.literal.push_back(c); }
inline void dropLiteral() { m_next_token.literal.clear(); }
inline void addLiteralCharAndAdvance() { addLiteralChar(m_char); advance(); }
///@}
@@ -171,8 +181,9 @@ private:
bool scanHexByte(char& o_scannedByte);
- /// Scans a single JavaScript token.
- void scanToken();
+ /// Scans a single Solidity token. Returns true if the scanned token was
+ /// a skipped documentation comment. False in all other cases.
+ bool scanToken();
/// Skips all whitespace and @returns true if something was skipped.
bool skipWhitespace();
@@ -184,6 +195,7 @@ private:
Token::Value scanIdentifierOrKeyword();
Token::Value scanString();
+ Token::Value scanDocumentationComment();
/// Scans an escape-sequence which is part of a string and adds the
/// decoded character to the current literal. Returns true if a pattern
@@ -194,6 +206,9 @@ private:
int getSourcePos() { return m_source.getPos(); }
bool isSourcePastEndOfInput() { return m_source.isPastEndOfInput(); }
+ TokenDesc m_skipped_comment; // desc for current skipped comment
+ TokenDesc m_next_skipped_comment; // desc for next skiped comment
+
TokenDesc m_current_token; // desc for current token (as returned by Next())
TokenDesc m_next_token; // desc for next token (one token look-ahead)