diff options
author | Gav Wood <g@ethdev.com> | 2015-01-31 08:40:34 +0800 |
---|---|---|
committer | Gav Wood <g@ethdev.com> | 2015-01-31 08:40:34 +0800 |
commit | 6c8b5cabdc9e3f48d95e945d093a480c2ab5032e (patch) | |
tree | c7c9112c205b5dc5c1c29e998e132e5f14182d2b | |
parent | 54676604f535df0bc104684dc46818964b3e5728 (diff) | |
parent | ab9dec320a034a0b9aacd5f8944b48de609d2fe8 (diff) | |
download | dexon-solidity-6c8b5cabdc9e3f48d95e945d093a480c2ab5032e.tar dexon-solidity-6c8b5cabdc9e3f48d95e945d093a480c2ab5032e.tar.gz dexon-solidity-6c8b5cabdc9e3f48d95e945d093a480c2ab5032e.tar.bz2 dexon-solidity-6c8b5cabdc9e3f48d95e945d093a480c2ab5032e.tar.lz dexon-solidity-6c8b5cabdc9e3f48d95e945d093a480c2ab5032e.tar.xz dexon-solidity-6c8b5cabdc9e3f48d95e945d093a480c2ab5032e.tar.zst dexon-solidity-6c8b5cabdc9e3f48d95e945d093a480c2ab5032e.zip |
Merge pull request #908 from chriseth/sol_fix_eventsWithoutParameters
Fix: No parameters for event.
-rw-r--r-- | Parser.cpp | 23 | ||||
-rw-r--r-- | Parser.h | 3 |
2 files changed, 14 insertions, 12 deletions
@@ -222,12 +222,7 @@ ASTPointer<FunctionDefinition> 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<ParameterList>(vector<ASTPointer<VariableDeclaration>>()); - } + returnParameters = createEmptyParameterList(); ASTPointer<Block> block = parseBlock(); nodeFactory.setEndPositionFromNode(block); bool const c_isConstructor = (_contractName && *name == *_contractName); @@ -285,12 +280,7 @@ ASTPointer<ModifierDefinition> 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<ParameterList>(vector<ASTPointer<VariableDeclaration>>()); - } + parameters = createEmptyParameterList(); ASTPointer<Block> block = parseBlock(); nodeFactory.setEndPositionFromNode(block); return nodeFactory.createNode<ModifierDefinition>(name, docstring, parameters, block); @@ -308,6 +298,8 @@ ASTPointer<EventDefinition> Parser::parseEventDefinition() ASTPointer<ParameterList> parameters; if (m_scanner->getCurrentToken() == Token::LPAREN) parameters = parseParameterList(true, true); + else + parameters = createEmptyParameterList(); nodeFactory.markEndPosition(); expectToken(Token::SEMICOLON); return nodeFactory.createNode<EventDefinition>(name, docstring, parameters); @@ -771,6 +763,13 @@ ASTPointer<ASTString> Parser::getLiteralAndAdvance() return identifier; } +ASTPointer<ParameterList> Parser::createEmptyParameterList() +{ + ASTNodeFactory nodeFactory(*this); + nodeFactory.setLocationEmpty(); + return nodeFactory.createNode<ParameterList>(vector<ASTPointer<VariableDeclaration>>()); +} + ParserError Parser::createParserError(string const& _description) const { return ParserError() << errinfo_sourceLocation(Location(getPosition(), getPosition(), getSourceName())) @@ -97,6 +97,9 @@ private: ASTPointer<ASTString> getLiteralAndAdvance(); ///@} + /// Creates an empty ParameterList at the current location (used if parameters can be omitted). + ASTPointer<ParameterList> 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; |