mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Some well-formedness checks for the Yul AST.
This commit is contained in:
1 parent
c13b5280c1
commit
19be6cd818
5 files changed
+51
-4
No files matched your search
@@ -110,3 +110,26 @@ string dev::getChecksummedAddress(string const& _addr)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool dev::isValidHex(string const& _string)
|
||||
{
|
||||
if (_string.substr(0, 2) != "0x")
|
||||
return false;
|
||||
if (_string.find_first_not_of("0123456789abcdefABCDEF", 2) != string::npos)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dev::isValidDecimal(string const& _string)
|
||||
{
|
||||
if (_string.empty())
|
||||
return false;
|
||||
if (_string == "0")
|
||||
return true;
|
||||
// No leading zeros
|
||||
if (_string.front() == '0')
|
||||
return false;
|
||||
if (_string.find_first_not_of("0123456789") != string::npos)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Block a user