diff --git a/ASTPrinter.cpp b/ASTPrinter.cpp index 85bc88254..05b24c63a 100644 --- a/ASTPrinter.cpp +++ b/ASTPrinter.cpp @@ -57,6 +57,13 @@ bool ASTPrinter::visit(ContractDefinition const& _node) return goDeeper(); } +bool ASTPrinter::visit(InheritanceSpecifier const& _node) +{ + writeLine("InheritanceSpecifier \"" + _node.getName()->getName() + "\""); + printSourcePart(_node); + return goDeeper(); +} + bool ASTPrinter::visit(StructDefinition const& _node) { writeLine("StructDefinition \"" + _node.getName() + "\""); @@ -323,6 +330,11 @@ void ASTPrinter::endVisit(ContractDefinition const&) m_indentation--; } +void ASTPrinter::endVisit(InheritanceSpecifier const&) +{ + m_indentation--; +} + void ASTPrinter::endVisit(StructDefinition const&) { m_indentation--; diff --git a/ASTPrinter.h b/ASTPrinter.h index 7f267bdf0..77025b2d0 100644 --- a/ASTPrinter.h +++ b/ASTPrinter.h @@ -44,6 +44,7 @@ public: bool visit(ImportDirective const& _node) override; bool visit(ContractDefinition const& _node) override; + bool visit(InheritanceSpecifier const& _node) override; bool visit(StructDefinition const& _node) override; bool visit(ParameterList const& _node) override; bool visit(FunctionDefinition const& _node) override; @@ -81,6 +82,7 @@ public: void endVisit(ImportDirective const&) override; void endVisit(ContractDefinition const&) override; + void endVisit(InheritanceSpecifier const&) override; void endVisit(StructDefinition const&) override; void endVisit(ParameterList const&) override; void endVisit(FunctionDefinition const&) override; diff --git a/ASTVisitor.h b/ASTVisitor.h index ecab00c31..53fbd1918 100644 --- a/ASTVisitor.h +++ b/ASTVisitor.h @@ -45,6 +45,7 @@ public: virtual bool visit(SourceUnit&) { return true; } virtual bool visit(ImportDirective&) { return true; } virtual bool visit(ContractDefinition&) { return true; } + virtual bool visit(InheritanceSpecifier&) { return true; } virtual bool visit(StructDefinition&) { return true; } virtual bool visit(ParameterList&) { return true; } virtual bool visit(FunctionDefinition&) { return true; } @@ -84,6 +85,7 @@ public: virtual void endVisit(SourceUnit&) { } virtual void endVisit(ImportDirective&) { } virtual void endVisit(ContractDefinition&) { } + virtual void endVisit(InheritanceSpecifier&) { } virtual void endVisit(StructDefinition&) { } virtual void endVisit(ParameterList&) { } virtual void endVisit(FunctionDefinition&) { } @@ -127,6 +129,7 @@ public: virtual bool visit(SourceUnit const&) { return true; } virtual bool visit(ImportDirective const&) { return true; } virtual bool visit(ContractDefinition const&) { return true; } + virtual bool visit(InheritanceSpecifier const&) { return true; } virtual bool visit(StructDefinition const&) { return true; } virtual bool visit(ParameterList const&) { return true; } virtual bool visit(FunctionDefinition const&) { return true; } @@ -166,6 +169,7 @@ public: virtual void endVisit(SourceUnit const&) { } virtual void endVisit(ImportDirective const&) { } virtual void endVisit(ContractDefinition const&) { } + virtual void endVisit(InheritanceSpecifier const&) { } virtual void endVisit(StructDefinition const&) { } virtual void endVisit(ParameterList const&) { } virtual void endVisit(FunctionDefinition const&) { } diff --git a/Parser.cpp b/Parser.cpp index baddbad86..d99d33acc 100644 --- a/Parser.cpp +++ b/Parser.cpp @@ -167,7 +167,7 @@ ASTPointer Parser::parseContractDefinition() ASTPointer Parser::parseInheritanceSpecifier() { ASTNodeFactory nodeFactory(*this); - ASTPointer name = ASTNodeFactory(*this).createNode(expectIdentifierToken()); + ASTPointer name(parseIdentifier()); vector> arguments; if (m_scanner->getCurrentToken() == Token::LPAREN) { @@ -283,7 +283,7 @@ ASTPointer Parser::parseModifierDefinition() ASTPointer Parser::parseModifierInvocation() { ASTNodeFactory nodeFactory(*this); - ASTPointer name = ASTNodeFactory(*this).createNode(expectIdentifierToken()); + ASTPointer name(parseIdentifier()); vector> arguments; if (m_scanner->getCurrentToken() == Token::LPAREN) { @@ -297,6 +297,13 @@ ASTPointer Parser::parseModifierInvocation() return nodeFactory.createNode(name, arguments); } +ASTPointer Parser::parseIdentifier() +{ + ASTNodeFactory nodeFactory(*this); + nodeFactory.markEndPosition(); + return nodeFactory.createNode(expectIdentifierToken()); +} + ASTPointer Parser::parseTypeName(bool _allowVar) { ASTPointer type; @@ -584,8 +591,8 @@ ASTPointer Parser::parseLeftHandSideExpression() if (m_scanner->getCurrentToken() == Token::NEW) { expectToken(Token::NEW); - ASTPointer contractName = ASTNodeFactory(*this).createNode(expectIdentifierToken()); - nodeFactory.markEndPosition(); + ASTPointer contractName(parseIdentifier()); + nodeFactory.setEndPositionFromNode(contractName); expression = nodeFactory.createNode(contractName); } else diff --git a/Parser.h b/Parser.h index f85c3186d..211e952d3 100644 --- a/Parser.h +++ b/Parser.h @@ -55,6 +55,7 @@ private: ASTPointer parseVariableDeclaration(bool _allowVar); ASTPointer parseModifierDefinition(); ASTPointer parseModifierInvocation(); + ASTPointer parseIdentifier(); ASTPointer parseTypeName(bool _allowVar); ASTPointer parseMapping(); ASTPointer parseParameterList(bool _allowEmpty = true);