aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/ast')
-rw-r--r--libsolidity/ast/Types.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index 349a59d4..3dbbca91 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -39,6 +39,7 @@
#include <boost/range/algorithm/copy.hpp>
#include <boost/range/adaptor/sliced.hpp>
#include <boost/range/adaptor/transformed.hpp>
+#include <boost/algorithm/string.hpp>
#include <limits>
@@ -783,19 +784,22 @@ tuple<bool, rational> RationalNumberType::isValidLiteral(Literal const& _literal
rational value;
try
{
- auto expPoint = find(_literal.value().begin(), _literal.value().end(), 'e');
- if (expPoint == _literal.value().end())
- expPoint = find(_literal.value().begin(), _literal.value().end(), 'E');
+ ASTString valueString = _literal.value();
+ boost::erase_all(valueString, "_");// Remove underscore separators
- if (boost::starts_with(_literal.value(), "0x"))
+ auto expPoint = find(valueString.begin(), valueString.end(), 'e');
+ if (expPoint == valueString.end())
+ expPoint = find(valueString.begin(), valueString.end(), 'E');
+
+ if (boost::starts_with(valueString, "0x"))
{
// process as hex
- value = bigint(_literal.value());
+ value = bigint(valueString);
}
- else if (expPoint != _literal.value().end())
+ else if (expPoint != valueString.end())
{
// Parse mantissa and exponent. Checks numeric limit.
- tuple<bool, rational> mantissa = parseRational(string(_literal.value().begin(), expPoint));
+ tuple<bool, rational> mantissa = parseRational(string(valueString.begin(), expPoint));
if (!get<0>(mantissa))
return make_tuple(false, rational(0));
@@ -805,7 +809,7 @@ tuple<bool, rational> RationalNumberType::isValidLiteral(Literal const& _literal
if (value == 0)
return make_tuple(true, rational(0));
- bigint exp = bigint(string(expPoint + 1, _literal.value().end()));
+ bigint exp = bigint(string(expPoint + 1, valueString.end()));
if (exp > numeric_limits<int32_t>::max() || exp < numeric_limits<int32_t>::min())
return make_tuple(false, rational(0));
@@ -834,7 +838,7 @@ tuple<bool, rational> RationalNumberType::isValidLiteral(Literal const& _literal
else
{
// parse as rational number
- tuple<bool, rational> tmp = parseRational(_literal.value());
+ tuple<bool, rational> tmp = parseRational(valueString);
if (!get<0>(tmp))
return tmp;
value = get<1>(tmp);