diff options
author | chriseth <c@ethdev.com> | 2015-09-08 22:48:33 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-09-11 21:21:37 +0800 |
commit | 337fde9d11adac85800b405a3fdb4bcd09039ebf (patch) | |
tree | a0b63ce5ebcb77f26c724a88ef8ce13fbe852879 /libsolidity/Parser.cpp | |
parent | c5b6d9d2a9fb379e35435726046ce6c551d25c17 (diff) | |
download | dexon-solidity-337fde9d11adac85800b405a3fdb4bcd09039ebf.tar.gz dexon-solidity-337fde9d11adac85800b405a3fdb4bcd09039ebf.tar.zst dexon-solidity-337fde9d11adac85800b405a3fdb4bcd09039ebf.zip |
Parsing and type checking of libraries without inheritance.
Diffstat (limited to 'libsolidity/Parser.cpp')
-rw-r--r-- | libsolidity/Parser.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libsolidity/Parser.cpp b/libsolidity/Parser.cpp index 7f779ed0..24f7734c 100644 --- a/libsolidity/Parser.cpp +++ b/libsolidity/Parser.cpp @@ -71,13 +71,14 @@ ASTPointer<SourceUnit> Parser::parse(shared_ptr<Scanner> const& _scanner) vector<ASTPointer<ASTNode>> nodes; while (m_scanner->currentToken() != Token::EOS) { - switch (m_scanner->currentToken()) + switch (auto token = m_scanner->currentToken()) { case Token::Import: nodes.push_back(parseImportDirective()); break; case Token::Contract: - nodes.push_back(parseContractDefinition()); + case Token::Library: + nodes.push_back(parseContractDefinition(token == Token::Library)); break; default: BOOST_THROW_EXCEPTION(createParserError(std::string("Expected import directive or contract definition."))); @@ -113,13 +114,13 @@ ASTPointer<ImportDirective> Parser::parseImportDirective() return nodeFactory.createNode<ImportDirective>(url); } -ASTPointer<ContractDefinition> Parser::parseContractDefinition() +ASTPointer<ContractDefinition> Parser::parseContractDefinition(bool _isLibrary) { ASTNodeFactory nodeFactory(*this); ASTPointer<ASTString> docString; if (m_scanner->currentCommentLiteral() != "") docString = make_shared<ASTString>(m_scanner->currentCommentLiteral()); - expectToken(Token::Contract); + expectToken(_isLibrary ? Token::Library : Token::Contract); ASTPointer<ASTString> name = expectIdentifierToken(); vector<ASTPointer<InheritanceSpecifier>> baseContracts; vector<ASTPointer<StructDefinition>> structs; @@ -177,7 +178,8 @@ ASTPointer<ContractDefinition> Parser::parseContractDefinition() stateVariables, functions, modifiers, - events + events, + _isLibrary ); } |