mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
stylistic change, and got lexical cast to work with an iterator range
This commit is contained in:
parent
58e07151e3
commit
b8bcb706e9
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <libsolidity/parsing/Token.h>
|
#include <libsolidity/parsing/Token.h>
|
||||||
|
#include <boost/range/iterator_range.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -108,11 +109,11 @@ char const Token::m_tokenType[] =
|
|||||||
{
|
{
|
||||||
TOKEN_LIST(KT, KK)
|
TOKEN_LIST(KT, KK)
|
||||||
};
|
};
|
||||||
unsigned Token::extractUnsigned(string::const_iterator const& _begin, string::const_iterator const& _end)
|
unsigned Token::extractUnsigned(string::const_iterator _begin, string::const_iterator _end)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
unsigned short m = boost::lexical_cast<unsigned short>(string(_begin, _end));
|
unsigned short m = boost::lexical_cast<unsigned short>(boost::make_iterator_range(_begin, _end));
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
catch(const boost::bad_lexical_cast &)
|
catch(const boost::bad_lexical_cast &)
|
||||||
@ -146,8 +147,8 @@ tuple<Token::Value, unsigned short, unsigned short> Token::fromIdentifierOrKeywo
|
|||||||
}
|
}
|
||||||
else if (keyword == Token::UFixed || keyword == Token::Fixed)
|
else if (keyword == Token::UFixed || keyword == Token::Fixed)
|
||||||
{
|
{
|
||||||
auto positionN = find_if_not(positionX + 1, _literal.end(), ::isdigit);
|
auto positionN = find_if_not(positionX++, _literal.end(), ::isdigit);
|
||||||
unsigned short n = extractUnsigned(positionX + 1, positionN);
|
unsigned short n = extractUnsigned(positionX++, positionN);
|
||||||
if (
|
if (
|
||||||
0 < m + n &&
|
0 < m + n &&
|
||||||
m + n <= 256 &&
|
m + n <= 256 &&
|
||||||
|
@ -308,7 +308,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// @returns 0 on error (invalid digit or number too large)
|
// @returns 0 on error (invalid digit or number too large)
|
||||||
static unsigned extractUnsigned(std::string::const_iterator const& _begin, std::string::const_iterator const& _end);
|
static unsigned extractUnsigned(std::string::const_iterator _begin, std::string::const_iterator _end);
|
||||||
// @returns the keyword with name @a _name or Token::Identifier of no such keyword exists.
|
// @returns the keyword with name @a _name or Token::Identifier of no such keyword exists.
|
||||||
static Token::Value keywordByName(std::string const& _name);
|
static Token::Value keywordByName(std::string const& _name);
|
||||||
static char const* const m_name[NUM_TOKENS];
|
static char const* const m_name[NUM_TOKENS];
|
||||||
|
Loading…
Reference in New Issue
Block a user