mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Introduce RightArrow (->) token in the scanner
This commit is contained in:
parent
fdc4142b2c
commit
4e5b403c37
@ -15,6 +15,7 @@ Compiler Features:
|
||||
Bugfixes:
|
||||
* AST: Remove ``null`` member values also when the compiler is used in standard-json-mode.
|
||||
* Optimizer: Keep side-effects of ``x`` in ``byte(a, shr(b, x))`` even if the constants ``a`` and ``b`` would make the expression zero unconditionally. This optimizer rule is very hard if not impossible to trigger in a way that it can result in invalid code, though.
|
||||
* Scanner: Fix bug where whitespace would be allowed within the ``->`` token (e.g. ``function f() - > x {}`` becomes invalid in inline assembly and Yul).
|
||||
* SMTChecker: Fix internal error in BMC function inlining.
|
||||
* SMTChecker: Fix internal error on array implicit conversion.
|
||||
* SMTChecker: Fix internal error on fixed bytes index access.
|
||||
|
@ -112,6 +112,7 @@ Semicolon: ';';
|
||||
Period: '.';
|
||||
Conditional: '?';
|
||||
Arrow: '=>';
|
||||
RightArrow: '->';
|
||||
|
||||
Assign: '=';
|
||||
AssignBitOr: '|=';
|
||||
@ -283,9 +284,7 @@ YulRParen: ')';
|
||||
YulAssign: ':=';
|
||||
YulPeriod: '.';
|
||||
YulComma: ',';
|
||||
// TODO: remove whitespace workaround once the parser disallows it.
|
||||
//@doc:name ->
|
||||
YulArrow: '->' | '-' YulWS+ '>';
|
||||
YulArrow: '->';
|
||||
|
||||
/**
|
||||
* Yul identifiers consist of letters, dollar signs, underscores and numbers, but may not start with a number.
|
||||
|
@ -563,12 +563,14 @@ void Scanner::scanToken()
|
||||
token = Token::Add;
|
||||
break;
|
||||
case '-':
|
||||
// - -- -=
|
||||
// - -- -= ->
|
||||
advance();
|
||||
if (m_char == '-')
|
||||
token = selectToken(Token::Dec);
|
||||
else if (m_char == '=')
|
||||
token = selectToken(Token::AssignSub);
|
||||
else if (m_char == '>')
|
||||
token = selectToken(Token::RightArrow);
|
||||
else
|
||||
token = Token::Sub;
|
||||
break;
|
||||
|
@ -84,6 +84,7 @@ namespace solidity::langutil
|
||||
T(Period, ".", 0) \
|
||||
T(Conditional, "?", 3) \
|
||||
T(Arrow, "=>", 0) \
|
||||
T(RightArrow, "->", 0) \
|
||||
\
|
||||
/* Assignment operators. */ \
|
||||
/* IsAssignmentOp() relies on this block of enum values being */ \
|
||||
|
@ -401,10 +401,9 @@ FunctionDefinition Parser::parseFunctionDefinition()
|
||||
expectToken(Token::Comma);
|
||||
}
|
||||
expectToken(Token::RParen);
|
||||
if (currentToken() == Token::Sub)
|
||||
if (currentToken() == Token::RightArrow)
|
||||
{
|
||||
expectToken(Token::Sub);
|
||||
expectToken(Token::GreaterThan);
|
||||
expectToken(Token::RightArrow);
|
||||
while (true)
|
||||
{
|
||||
funDef.returnVariables.emplace_back(parseTypedName());
|
||||
|
@ -782,8 +782,7 @@ BOOST_AUTO_TEST_CASE(yul_function)
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Comma);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::RParen);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Sub);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::GreaterThan);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::RightArrow);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Comma);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier);
|
||||
@ -797,8 +796,7 @@ BOOST_AUTO_TEST_CASE(yul_function)
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Comma);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::RParen);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Sub);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::GreaterThan);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::RightArrow);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Comma);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier);
|
||||
|
@ -5,7 +5,7 @@ contract C {
|
||||
|
||||
function asmfun(a, b, c) -> x, y, z {
|
||||
x := g(a)
|
||||
function g(r) - > s {
|
||||
function g(r) -> s {
|
||||
s := mul(r, r)
|
||||
}
|
||||
y := g(b)
|
||||
|
@ -5,4 +5,6 @@ contract C {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// ParserError 2314: (87-88): Expected '{' but got '-'
|
||||
|
@ -1,4 +1,6 @@
|
||||
{
|
||||
function f (a, b , c ) - > y,x,z {
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// ParserError 2314: (30-31): Expected '{' but got '-'
|
||||
|
Loading…
Reference in New Issue
Block a user