mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #1016 from ethereum/reserved
Report the usage of reserved keywords more nicely
This commit is contained in:
commit
462fc84e53
@ -47,7 +47,17 @@ void ParserBase::expectToken(Token::Value _value)
|
|||||||
Token::Value tok = m_scanner->currentToken();
|
Token::Value tok = m_scanner->currentToken();
|
||||||
if (tok != _value)
|
if (tok != _value)
|
||||||
{
|
{
|
||||||
if (Token::isElementaryTypeName(tok)) //for the sake of accuracy in reporting
|
if (Token::isReservedKeyword(tok))
|
||||||
|
{
|
||||||
|
fatalParserError(
|
||||||
|
string("Expected token ") +
|
||||||
|
string(Token::name(_value)) +
|
||||||
|
string(" got reserved keyword '") +
|
||||||
|
string(Token::name(tok)) +
|
||||||
|
string("'")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (Token::isElementaryTypeName(tok)) //for the sake of accuracy in reporting
|
||||||
{
|
{
|
||||||
ElementaryTypeNameToken elemTypeName = m_scanner->currentElementaryTypeNameToken();
|
ElementaryTypeNameToken elemTypeName = m_scanner->currentElementaryTypeNameToken();
|
||||||
fatalParserError(
|
fatalParserError(
|
||||||
|
@ -293,6 +293,7 @@ public:
|
|||||||
static bool isLocationSpecifier(Value op) { return op == Memory || op == Storage; }
|
static bool isLocationSpecifier(Value op) { return op == Memory || op == Storage; }
|
||||||
static bool isEtherSubdenomination(Value op) { return op == SubWei || op == SubSzabo || op == SubFinney || op == SubEther; }
|
static bool isEtherSubdenomination(Value op) { return op == SubWei || op == SubSzabo || op == SubFinney || op == SubEther; }
|
||||||
static bool isTimeSubdenomination(Value op) { return op == SubSecond || op == SubMinute || op == SubHour || op == SubDay || op == SubWeek || op == SubYear; }
|
static bool isTimeSubdenomination(Value op) { return op == SubSecond || op == SubMinute || op == SubHour || op == SubDay || op == SubWeek || op == SubYear; }
|
||||||
|
static bool isReservedKeyword(Value op) { return (Abstract <= op && op <= TypeOf); }
|
||||||
|
|
||||||
// @returns a string corresponding to the JS token string
|
// @returns a string corresponding to the JS token string
|
||||||
// (.e., "<" for the token LT) or NULL if the token doesn't
|
// (.e., "<" for the token LT) or NULL if the token doesn't
|
||||||
|
Loading…
Reference in New Issue
Block a user