diff options
author | chriseth <chris@ethereum.org> | 2018-10-09 20:17:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-09 20:17:11 +0800 |
commit | 547b26d46462663b49631d55cf32dc10094eb4d4 (patch) | |
tree | f127a02462dfaa9f3b81b0a844de81f119b16514 /libsolidity | |
parent | 2547caf896b2d36e743ccd0a4c9cd420779786e1 (diff) | |
parent | 4bcd89105cf294d65443cbc7bfe2aaffd571f6d3 (diff) | |
download | dexon-solidity-547b26d46462663b49631d55cf32dc10094eb4d4.tar.gz dexon-solidity-547b26d46462663b49631d55cf32dc10094eb4d4.tar.zst dexon-solidity-547b26d46462663b49631d55cf32dc10094eb4d4.zip |
Merge pull request #5124 from lazaridiscom/1802-hex-error-reporting
use Token type for hex error, draft re #1802
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/parsing/Parser.cpp | 3 | ||||
-rw-r--r-- | libsolidity/parsing/Scanner.cpp | 6 | ||||
-rw-r--r-- | libsolidity/parsing/Token.h | 2 |
3 files changed, 8 insertions, 3 deletions
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 1228b833..b390459a 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -1554,6 +1554,9 @@ ASTPointer<Expression> Parser::parsePrimaryExpression() expression = nodeFactory.createNode<TupleExpression>(components, isArray); break; } + case Token::IllegalHex: + fatalParserError("Expected even number of hex-nibbles within double-quotes."); + break; default: if (Token::isElementaryTypeName(token)) { diff --git a/libsolidity/parsing/Scanner.cpp b/libsolidity/parsing/Scanner.cpp index 9a7f85cb..87d7c535 100644 --- a/libsolidity/parsing/Scanner.cpp +++ b/libsolidity/parsing/Scanner.cpp @@ -612,7 +612,7 @@ void Scanner::scanToken() if (m_char == '"' || m_char == '\'') token = scanHexString(); else - token = Token::Illegal; + token = Token::IllegalHex; } } else if (isDecimalDigit(m_char)) @@ -736,11 +736,11 @@ Token::Value Scanner::scanHexString() { char c = m_char; if (!scanHexByte(c)) - return Token::Illegal; + return Token::IllegalHex; addLiteralChar(c); } if (m_char != quote) - return Token::Illegal; + return Token::IllegalHex; literal.complete(); advance(); // consume quote return Token::StringLiteral; diff --git a/libsolidity/parsing/Token.h b/libsolidity/parsing/Token.h index 73c85482..8ecc850a 100644 --- a/libsolidity/parsing/Token.h +++ b/libsolidity/parsing/Token.h @@ -261,6 +261,8 @@ namespace solidity \ /* Illegal token - not able to scan. */ \ T(Illegal, "ILLEGAL", 0) \ + /* Illegal hex token */ \ + T(IllegalHex, "ILLEGAL_HEX", 0) \ \ /* Scanner-internal use only. */ \ T(Whitespace, NULL, 0) |