Some well-formedness checks for the Yul AST.

This commit is contained in:
chriseth committed 2018-10-22 15:52:26 +02:00
1 parent c13b5280c1
commit 19be6cd818
5 files changed
+51 -4

No files matched your search

+23
View File
@@ -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;
}