diff options
author | chriseth <chris@ethereum.org> | 2018-02-16 23:55:21 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-02-22 22:17:30 +0800 |
commit | 388718b59f604c944be6816ba50068014e563fb0 (patch) | |
tree | 0a3c4bf2b04a6aaba2c4beb40252617384159662 /libsolidity/parsing/Parser.cpp | |
parent | 8fc9535d43df26001f7b34488d073c06fc4fd358 (diff) | |
download | dexon-solidity-388718b59f604c944be6816ba50068014e563fb0.tar.gz dexon-solidity-388718b59f604c944be6816ba50068014e563fb0.tar.zst dexon-solidity-388718b59f604c944be6816ba50068014e563fb0.zip |
Introduce emit statement.
Diffstat (limited to 'libsolidity/parsing/Parser.cpp')
-rw-r--r-- | libsolidity/parsing/Parser.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index e306e21b..8c97f55f 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -897,7 +897,9 @@ ASTPointer<Statement> Parser::parseStatement() case Token::Assembly: return parseInlineAssembly(docString); case Token::Identifier: - if (m_insideModifier && m_scanner->currentLiteral() == "_") + if (m_scanner->currentLiteral() == "emit") + statement = parseEmitStatement(docString); + else if (m_insideModifier && m_scanner->currentLiteral() == "_") { statement = ASTNodeFactory(*this).createNode<PlaceholderStatement>(docString); m_scanner->next(); @@ -1015,6 +1017,38 @@ ASTPointer<ForStatement> Parser::parseForStatement(ASTPointer<ASTString> const& ); } +ASTPointer<EmitStatement> Parser::parseEmitStatement(ASTPointer<ASTString> const& _docString) +{ + ASTNodeFactory nodeFactory(*this); + m_scanner->next(); + ASTNodeFactory eventCallNodeFactory(*this); + + if (m_scanner->currentToken() != Token::Identifier) + fatalParserError("Expected event name or path."); + + vector<ASTPointer<PrimaryExpression>> path; + while (true) + { + path.push_back(parseIdentifier()); + if (m_scanner->currentToken() != Token::Period) + break; + m_scanner->next(); + }; + + auto eventName = expressionFromIndexAccessStructure(path, {}); + expectToken(Token::LParen); + + vector<ASTPointer<Expression>> arguments; + vector<ASTPointer<ASTString>> names; + std::tie(arguments, names) = parseFunctionCallArguments(); + eventCallNodeFactory.markEndPosition(); + nodeFactory.markEndPosition(); + expectToken(Token::RParen); + auto eventCall = eventCallNodeFactory.createNode<FunctionCall>(eventName, arguments, names); + auto statement = nodeFactory.createNode<EmitStatement>(_docString, eventCall); + return statement; +} + ASTPointer<Statement> Parser::parseSimpleStatement(ASTPointer<ASTString> const& _docString) { RecursionGuard recursionGuard(*this); |