aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/parsing/Parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/parsing/Parser.cpp')
-rw-r--r--libsolidity/parsing/Parser.cpp36
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);