From 4631e54e08184df7b6788f37b0ad2f808d1d73cc Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 15 Jan 2015 16:15:01 +0100 Subject: Inheritance parser. --- AST.h | 3 +++ Parser.cpp | 13 +++++++++++-- Token.h | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/AST.h b/AST.h index 409aed44..e4761536 100755 --- a/AST.h +++ b/AST.h @@ -158,10 +158,12 @@ public: ContractDefinition(Location const& _location, ASTPointer const& _name, ASTPointer const& _documentation, + std::vector> const& _baseContracts, std::vector> const& _definedStructs, std::vector> const& _stateVariables, std::vector> const& _definedFunctions): Declaration(_location, _name), + m_baseContracts(_baseContracts), m_definedStructs(_definedStructs), m_stateVariables(_stateVariables), m_definedFunctions(_definedFunctions), @@ -193,6 +195,7 @@ public: private: std::vector, FunctionDefinition const*>> getInterfaceFunctionList() const; + std::vector> m_baseContracts; std::vector> m_definedStructs; std::vector> m_stateVariables; std::vector> m_definedFunctions; diff --git a/Parser.cpp b/Parser.cpp index ebff3ba4..26fc2018 100644 --- a/Parser.cpp +++ b/Parser.cpp @@ -117,10 +117,18 @@ ASTPointer Parser::parseContractDefinition() docstring = make_shared(m_scanner->getCurrentCommentLiteral()); expectToken(Token::CONTRACT); ASTPointer name = expectIdentifierToken(); - expectToken(Token::LBRACE); + vector> baseContracts; vector> structs; vector> stateVariables; vector> functions; + if (m_scanner->getCurrentToken() == Token::IS) + do + { + m_scanner->next(); + baseContracts.push_back(ASTNodeFactory(*this).createNode(expectIdentifierToken())); + } + while (m_scanner->getCurrentToken() == Token::COMMA); + expectToken(Token::LBRACE); bool visibilityIsPublic = true; while (true) { @@ -149,7 +157,8 @@ ASTPointer Parser::parseContractDefinition() } nodeFactory.markEndPosition(); expectToken(Token::RBRACE); - return nodeFactory.createNode(name, docstring, structs, stateVariables, functions); + return nodeFactory.createNode(name, docstring, baseContracts, structs, + stateVariables, functions); } ASTPointer Parser::parseFunctionDefinition(bool _isPublic) diff --git a/Token.h b/Token.h index 9fb86e7f..552e9a75 100644 --- a/Token.h +++ b/Token.h @@ -153,7 +153,7 @@ namespace solidity K(DEFAULT, "default", 0) \ K(DO, "do", 0) \ K(ELSE, "else", 0) \ - K(EXTENDS, "extends", 0) \ + K(IS, "is", 0) \ K(FOR, "for", 0) \ K(FUNCTION, "function", 0) \ K(IF, "if", 0) \ -- cgit v1.2.3