Merge pull request #3382 from ethereum/julia-identifier-parser

Support some restricted tokens (return, byte, address) as identifier in Julia
This commit is contained in:
chriseth 2018-01-06 00:02:21 +01:00 committed by GitHub
commit bca01f8f68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View File

@ -3,6 +3,7 @@
Features:
* Limit the number of warnings raised for creating abstract contracts.
* Inline Assembly: Issue warning for using jump labels (already existed for jump instructions).
* Inline Assembly: Support some restricted tokens (return, byte, address) as identifiers in Julia mode.
* SMT Checker: If-else branch conditions are taken into account in the SMT encoding of the program
variables.

View File

@ -566,10 +566,16 @@ string Parser::expectAsmIdentifier()
string name = currentLiteral();
if (m_julia)
{
if (currentToken() == Token::Bool)
switch (currentToken())
{
case Token::Return:
case Token::Byte:
case Token::Address:
case Token::Bool:
advance();
return name;
default:
break;
}
}
else if (instructions().count(name))

View File

@ -196,6 +196,14 @@ BOOST_AUTO_TEST_CASE(empty_call)
CHECK_ERROR("{ () }", ParserError, "Literal or identifier expected.");
}
BOOST_AUTO_TEST_CASE(tokens_as_identifers)
{
BOOST_CHECK(successParse("{ let return:u256 := 1:u256 }"));
BOOST_CHECK(successParse("{ let byte:u256 := 1:u256 }"));
BOOST_CHECK(successParse("{ let address:u256 := 1:u256 }"));
BOOST_CHECK(successParse("{ let bool:u256 := 1:u256 }"));
}
BOOST_AUTO_TEST_CASE(lacking_types)
{
CHECK_ERROR("{ let x := 1:u256 }", ParserError, "Expected token Identifier got 'Assign'");