From ab9dec320a034a0b9aacd5f8944b48de609d2fe8 Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 30 Jan 2015 21:43:19 +0100 Subject: [PATCH] Fix: No parameters for event. --- Parser.cpp | 23 +++++++++++------------ Parser.h | 3 +++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Parser.cpp b/Parser.cpp index 7ce0f0748..d2e888a8d 100644 --- a/Parser.cpp +++ b/Parser.cpp @@ -222,12 +222,7 @@ ASTPointer Parser::parseFunctionDefinition(bool _isPublic, A returnParameters = parseParameterList(permitEmptyParameterList); } else - { - // create an empty parameter list at a zero-length location - ASTNodeFactory nodeFactory(*this); - nodeFactory.setLocationEmpty(); - returnParameters = nodeFactory.createNode(vector>()); - } + returnParameters = createEmptyParameterList(); ASTPointer block = parseBlock(); nodeFactory.setEndPositionFromNode(block); bool const c_isConstructor = (_contractName && *name == *_contractName); @@ -285,12 +280,7 @@ ASTPointer Parser::parseModifierDefinition() if (m_scanner->getCurrentToken() == Token::LPAREN) parameters = parseParameterList(); else - { - // create an empty parameter list at a zero-length location - ASTNodeFactory nodeFactory(*this); - nodeFactory.setLocationEmpty(); - parameters = nodeFactory.createNode(vector>()); - } + parameters = createEmptyParameterList(); ASTPointer block = parseBlock(); nodeFactory.setEndPositionFromNode(block); return nodeFactory.createNode(name, docstring, parameters, block); @@ -308,6 +298,8 @@ ASTPointer Parser::parseEventDefinition() ASTPointer parameters; if (m_scanner->getCurrentToken() == Token::LPAREN) parameters = parseParameterList(true, true); + else + parameters = createEmptyParameterList(); nodeFactory.markEndPosition(); expectToken(Token::SEMICOLON); return nodeFactory.createNode(name, docstring, parameters); @@ -771,6 +763,13 @@ ASTPointer Parser::getLiteralAndAdvance() return identifier; } +ASTPointer Parser::createEmptyParameterList() +{ + ASTNodeFactory nodeFactory(*this); + nodeFactory.setLocationEmpty(); + return nodeFactory.createNode(vector>()); +} + ParserError Parser::createParserError(string const& _description) const { return ParserError() << errinfo_sourceLocation(Location(getPosition(), getPosition(), getSourceName())) diff --git a/Parser.h b/Parser.h index 69478c81e..413a2711e 100644 --- a/Parser.h +++ b/Parser.h @@ -97,6 +97,9 @@ private: ASTPointer getLiteralAndAdvance(); ///@} + /// Creates an empty ParameterList at the current location (used if parameters can be omitted). + ASTPointer createEmptyParameterList(); + /// Creates a @ref ParserError exception and annotates it with the current position and the /// given @a _description. ParserError createParserError(std::string const& _description) const;