diff options
author | chriseth <c@ethdev.com> | 2015-11-30 23:06:44 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-11-30 23:06:44 +0800 |
commit | e9c7837c154482a72c8519fbdc9376693ce9a1d5 (patch) | |
tree | 1985b57b4e221fe4e4b5cc14a5049b8c0c46ce6c /libsolidity/parsing/Parser.cpp | |
parent | a8736b7b271dac117f15164cf4d2dfabcdd2c6fd (diff) | |
parent | f9e52c9db1ef23000f5721a462aba3fa8d681749 (diff) | |
download | dexon-solidity-e9c7837c154482a72c8519fbdc9376693ce9a1d5.tar.gz dexon-solidity-e9c7837c154482a72c8519fbdc9376693ce9a1d5.tar.zst dexon-solidity-e9c7837c154482a72c8519fbdc9376693ce9a1d5.zip |
Merge pull request #251 from chriseth/bind2
Bind library functions to types.
Diffstat (limited to 'libsolidity/parsing/Parser.cpp')
-rw-r--r-- | libsolidity/parsing/Parser.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 9272eb4b..2b886121 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -168,6 +168,8 @@ ASTPointer<ContractDefinition> Parser::parseContractDefinition(bool _isLibrary) subNodes.push_back(parseModifierDefinition()); else if (currentTokenValue == Token::Event) subNodes.push_back(parseEventDefinition()); + else if (currentTokenValue == Token::Using) + subNodes.push_back(parseUsingDirective()); else fatalParserError(std::string("Function, variable, struct or modifier declaration expected.")); } @@ -475,6 +477,24 @@ ASTPointer<EventDefinition> Parser::parseEventDefinition() return nodeFactory.createNode<EventDefinition>(name, docstring, parameters, anonymous); } +ASTPointer<UsingForDirective> Parser::parseUsingDirective() +{ + ASTNodeFactory nodeFactory(*this); + + expectToken(Token::Using); + //@todo this should actually parse a full path. + ASTPointer<Identifier> library(parseIdentifier()); + ASTPointer<TypeName> typeName; + expectToken(Token::For); + if (m_scanner->currentToken() == Token::Mul) + m_scanner->next(); + else + typeName = parseTypeName(false); + nodeFactory.markEndPosition(); + expectToken(Token::Semicolon); + return nodeFactory.createNode<UsingForDirective>(library, typeName); +} + ASTPointer<ModifierInvocation> Parser::parseModifierInvocation() { ASTNodeFactory nodeFactory(*this); |