aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/parsing
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-12-22 01:44:21 +0800
committerchriseth <c@ethdev.com>2015-12-22 01:44:21 +0800
commit0e2fa39fadb9ccf45408e047c2b85d62847eb9f2 (patch)
treeb83ec2abf96e42c4729e42e512230f7028541828 /libsolidity/parsing
parent8fe89455b378acae43898185f6c9c0f67dba967e (diff)
downloaddexon-solidity-0e2fa39fadb9ccf45408e047c2b85d62847eb9f2.tar.gz
dexon-solidity-0e2fa39fadb9ccf45408e047c2b85d62847eb9f2.tar.zst
dexon-solidity-0e2fa39fadb9ccf45408e047c2b85d62847eb9f2.zip
Use paths instead of simple identifiers wherever possible.
Diffstat (limited to 'libsolidity/parsing')
-rw-r--r--libsolidity/parsing/Parser.cpp32
-rw-r--r--libsolidity/parsing/Parser.h1
2 files changed, 18 insertions, 15 deletions
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp
index d53f825f..7dd3564d 100644
--- a/libsolidity/parsing/Parser.cpp
+++ b/libsolidity/parsing/Parser.cpp
@@ -238,7 +238,7 @@ ASTPointer<ContractDefinition> Parser::parseContractDefinition(bool _isLibrary)
ASTPointer<InheritanceSpecifier> Parser::parseInheritanceSpecifier()
{
ASTNodeFactory nodeFactory(*this);
- ASTPointer<Identifier> name(parseIdentifier());
+ ASTPointer<UserDefinedTypeName> name(parseUserDefinedTypeName());
vector<ASTPointer<Expression>> arguments;
if (m_scanner->currentToken() == Token::LParen)
{
@@ -533,8 +533,7 @@ ASTPointer<UsingForDirective> Parser::parseUsingDirective()
ASTNodeFactory nodeFactory(*this);
expectToken(Token::Using);
- //@todo this should actually parse a full path.
- ASTPointer<Identifier> library(parseIdentifier());
+ ASTPointer<UserDefinedTypeName> library(parseUserDefinedTypeName());
ASTPointer<TypeName> typeName;
expectToken(Token::For);
if (m_scanner->currentToken() == Token::Mul)
@@ -570,6 +569,20 @@ ASTPointer<Identifier> Parser::parseIdentifier()
return nodeFactory.createNode<Identifier>(expectIdentifierToken());
}
+ASTPointer<UserDefinedTypeName> Parser::parseUserDefinedTypeName()
+{
+ ASTNodeFactory nodeFactory(*this);
+ nodeFactory.markEndPosition();
+ vector<ASTString> identifierPath{*expectIdentifierToken()};
+ while (m_scanner->currentToken() == Token::Period)
+ {
+ m_scanner->next();
+ nodeFactory.markEndPosition();
+ identifierPath.push_back(*expectIdentifierToken());
+ }
+ return nodeFactory.createNode<UserDefinedTypeName>(identifierPath);
+}
+
ASTPointer<TypeName> Parser::parseTypeName(bool _allowVar)
{
ASTNodeFactory nodeFactory(*this);
@@ -589,18 +602,7 @@ ASTPointer<TypeName> Parser::parseTypeName(bool _allowVar)
else if (token == Token::Mapping)
type = parseMapping();
else if (token == Token::Identifier)
- {
- ASTNodeFactory nodeFactory(*this);
- nodeFactory.markEndPosition();
- vector<ASTString> identifierPath{*expectIdentifierToken()};
- while (m_scanner->currentToken() == Token::Period)
- {
- m_scanner->next();
- nodeFactory.markEndPosition();
- identifierPath.push_back(*expectIdentifierToken());
- }
- type = nodeFactory.createNode<UserDefinedTypeName>(identifierPath);
- }
+ type = parseUserDefinedTypeName();
else
fatalParserError(string("Expected type name"));
diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h
index 5ff46242..eb1aa587 100644
--- a/libsolidity/parsing/Parser.h
+++ b/libsolidity/parsing/Parser.h
@@ -77,6 +77,7 @@ private:
ASTPointer<UsingForDirective> parseUsingDirective();
ASTPointer<ModifierInvocation> parseModifierInvocation();
ASTPointer<Identifier> parseIdentifier();
+ ASTPointer<UserDefinedTypeName> parseUserDefinedTypeName();
ASTPointer<TypeName> parseTypeName(bool _allowVar);
ASTPointer<Mapping> parseMapping();
ASTPointer<ParameterList> parseParameterList(