From d71cd3aa2b235f877b7928b57c94159e2c16865c Mon Sep 17 00:00:00 2001 From: chriseth Date: Sun, 22 Nov 2015 20:39:10 +0100 Subject: Added the `using x for y` directive. --- libsolidity/parsing/Parser.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libsolidity/parsing/Parser.cpp') 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 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 Parser::parseEventDefinition() return nodeFactory.createNode(name, docstring, parameters, anonymous); } +ASTPointer Parser::parseUsingDirective() +{ + ASTNodeFactory nodeFactory(*this); + + expectToken(Token::Using); + //@todo this should actually parse a full path. + ASTPointer library(parseIdentifier()); + ASTPointer 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(library, typeName); +} + ASTPointer Parser::parseModifierInvocation() { ASTNodeFactory nodeFactory(*this); -- cgit