Make `abstract` keyword instead of reserved

This commit is contained in:
Mathias Baumann 2019-11-11 17:09:31 +01:00
parent 5b8ff78176
commit caa127e2a8
2 changed files with 5 additions and 4 deletions

View File

@ -143,6 +143,7 @@ namespace langutil
/* Inline Assembly Operators */ \
T(AssemblyAssign, ":=", 2) \
/* Keywords */ \
K(Abstract, "abstract", 0) \
K(Anonymous, "anonymous", 0) \
K(As, "as", 0) \
K(Assembly, "assembly", 0) \
@ -231,7 +232,6 @@ namespace langutil
T(Identifier, nullptr, 0) \
\
/* Keywords reserved for future use. */ \
K(Abstract, "abstract", 0) \
K(After, "after", 0) \
K(Alias, "alias", 0) \
K(Apply, "apply", 0) \
@ -313,7 +313,7 @@ namespace TokenTraits
constexpr bool isEtherSubdenomination(Token op) { return op == Token::SubWei || op == Token::SubSzabo || op == Token::SubFinney || op == Token::SubEther; }
constexpr bool isTimeSubdenomination(Token op) { return op == Token::SubSecond || op == Token::SubMinute || op == Token::SubHour || op == Token::SubDay || op == Token::SubWeek || op == Token::SubYear; }
constexpr bool isReservedKeyword(Token op) { return (Token::Abstract <= op && op <= Token::Unchecked); }
constexpr bool isReservedKeyword(Token op) { return (Token::After <= op && op <= Token::Unchecked); }
inline Token AssignmentToBinaryOp(Token op)
{

View File

@ -121,7 +121,7 @@ BOOST_AUTO_TEST_SUITE(SolidityParser)
BOOST_AUTO_TEST_CASE(reserved_keywords)
{
BOOST_CHECK(!TokenTraits::isReservedKeyword(Token::Identifier));
BOOST_CHECK(TokenTraits::isReservedKeyword(Token::Abstract));
BOOST_CHECK(TokenTraits::isReservedKeyword(Token::After));
BOOST_CHECK(TokenTraits::isReservedKeyword(Token::Unchecked));
BOOST_CHECK(!TokenTraits::isReservedKeyword(Token::Illegal));
}
@ -532,7 +532,6 @@ BOOST_AUTO_TEST_CASE(multiple_visibility_specifiers)
BOOST_AUTO_TEST_CASE(keyword_is_reserved)
{
auto keywords = {
"abstract",
"after",
"alias",
"apply",
@ -568,6 +567,8 @@ BOOST_AUTO_TEST_CASE(keyword_is_reserved)
"unchecked"
};
BOOST_CHECK_EQUAL(std::size(keywords), static_cast<int>(Token::Unchecked) - static_cast<int>(Token::After) + 1);
for (auto const& keyword: keywords)
{
auto text = std::string("contract ") + keyword + " {}";