aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-02-05 05:02:35 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-02-05 05:02:35 +0800
commit426f9a286071714de61accd04a13ce9d2446ba30 (patch)
treebc682b079d87eca481b5816a5aace2e6df7bfe32
parentdca5f7b57bb5b535930d437c806f48a25cf6b569 (diff)
downloaddexon-solidity-426f9a286071714de61accd04a13ce9d2446ba30.tar
dexon-solidity-426f9a286071714de61accd04a13ce9d2446ba30.tar.gz
dexon-solidity-426f9a286071714de61accd04a13ce9d2446ba30.tar.bz2
dexon-solidity-426f9a286071714de61accd04a13ce9d2446ba30.tar.lz
dexon-solidity-426f9a286071714de61accd04a13ce9d2446ba30.tar.xz
dexon-solidity-426f9a286071714de61accd04a13ce9d2446ba30.tar.zst
dexon-solidity-426f9a286071714de61accd04a13ce9d2446ba30.zip
Tests for ether subdenominations. Work in progress
-rw-r--r--AST.cpp8
-rw-r--r--Parser.cpp2
-rw-r--r--Token.h1
3 files changed, 7 insertions, 4 deletions
diff --git a/AST.cpp b/AST.cpp
index f0c60e05..307168ed 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -599,10 +599,10 @@ Literal::Literal(Location const& _location, Token::Value _token,
Token::Value _sub):
PrimaryExpression(_location), m_token(_token), m_value(_value)
{
- solAssert(_sub == Token::ILLEGAL || _sub == Token::ETH_SUB_WEI ||
- _sub == Token::ETH_SUB_SZABO || _sub == Token::ETH_SUB_FINNEY ||
- _sub == Token::ETH_SUB_ETHER, "Illegal Token::Value given to Literal ctor");
- m_subDenomination =static_cast<Literal::ethSubDenomination>(_sub);
+ if(Token::isEtherSubdenomination(_sub))
+ m_subDenomination = static_cast<Literal::ethSubDenomination>(_sub);
+ else
+ m_subDenomination = Literal::ethSubDenomination::NONE;
}
void Literal::checkTypeRequirements()
diff --git a/Parser.cpp b/Parser.cpp
index 739bbdd6..6449ba93 100644
--- a/Parser.cpp
+++ b/Parser.cpp
@@ -694,6 +694,8 @@ ASTPointer<Expression> Parser::parsePrimaryExpression()
case Token::NUMBER:
nextToken = m_scanner->peekNextToken();
case Token::STRING_LITERAL:
+ if (Token::isEtherSubdenomination(nextToken))
+ m_scanner->next();
nodeFactory.markEndPosition();
expression = nodeFactory.createNode<Literal>(token, getLiteralAndAdvance(), nextToken);
break;
diff --git a/Token.h b/Token.h
index 7b960825..f2beefd9 100644
--- a/Token.h
+++ b/Token.h
@@ -383,6 +383,7 @@ public:
static bool isCountOp(Value op) { return op == INC || op == DEC; }
static bool isShiftOp(Value op) { return (SHL <= op) && (op <= SHR); }
static bool isVisibilitySpecifier(Value op) { return op == PUBLIC || op == PRIVATE || op == PROTECTED; }
+ static bool isEtherSubdenomination(Value op) { return op == ETH_SUB_WEI || op == ETH_SUB_SZABO || op == ETH_SUB_FINNEY || op == Token::ETH_SUB_ETHER; }
// Returns a string corresponding to the JS token string
// (.e., "<" for the token LT) or NULL if the token doesn't