aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/parsing
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/parsing')
-rw-r--r--libsolidity/parsing/Parser.cpp20
-rw-r--r--libsolidity/parsing/Parser.h1
2 files changed, 21 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);
diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h
index 663c0f92..5ff46242 100644
--- a/libsolidity/parsing/Parser.h
+++ b/libsolidity/parsing/Parser.h
@@ -74,6 +74,7 @@ private:
);
ASTPointer<ModifierDefinition> parseModifierDefinition();
ASTPointer<EventDefinition> parseEventDefinition();
+ ASTPointer<UsingForDirective> parseUsingDirective();
ASTPointer<ModifierInvocation> parseModifierInvocation();
ASTPointer<Identifier> parseIdentifier();
ASTPointer<TypeName> parseTypeName(bool _allowVar);