diff options
-rw-r--r-- | ASTPrinter.cpp | 12 | ||||
-rw-r--r-- | ASTPrinter.h | 2 | ||||
-rw-r--r-- | ASTVisitor.h | 4 | ||||
-rw-r--r-- | Parser.cpp | 15 | ||||
-rw-r--r-- | Parser.h | 1 |
5 files changed, 30 insertions, 4 deletions
diff --git a/ASTPrinter.cpp b/ASTPrinter.cpp index 85bc8825..05b24c63 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 7f267bdf..77025b2d 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 ecab00c3..53fbd191 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&) { } @@ -167,7 +167,7 @@ ASTPointer<ContractDefinition> Parser::parseContractDefinition() ASTPointer<InheritanceSpecifier> Parser::parseInheritanceSpecifier() { ASTNodeFactory nodeFactory(*this); - ASTPointer<Identifier> name = ASTNodeFactory(*this).createNode<Identifier>(expectIdentifierToken()); + ASTPointer<Identifier> name(parseIdentifier()); vector<ASTPointer<Expression>> arguments; if (m_scanner->getCurrentToken() == Token::LPAREN) { @@ -283,7 +283,7 @@ ASTPointer<ModifierDefinition> Parser::parseModifierDefinition() ASTPointer<ModifierInvocation> Parser::parseModifierInvocation() { ASTNodeFactory nodeFactory(*this); - ASTPointer<Identifier> name = ASTNodeFactory(*this).createNode<Identifier>(expectIdentifierToken()); + ASTPointer<Identifier> name(parseIdentifier()); vector<ASTPointer<Expression>> arguments; if (m_scanner->getCurrentToken() == Token::LPAREN) { @@ -297,6 +297,13 @@ ASTPointer<ModifierInvocation> Parser::parseModifierInvocation() return nodeFactory.createNode<ModifierInvocation>(name, arguments); } +ASTPointer<Identifier> Parser::parseIdentifier() +{ + ASTNodeFactory nodeFactory(*this); + nodeFactory.markEndPosition(); + return nodeFactory.createNode<Identifier>(expectIdentifierToken()); +} + ASTPointer<TypeName> Parser::parseTypeName(bool _allowVar) { ASTPointer<TypeName> type; @@ -584,8 +591,8 @@ ASTPointer<Expression> Parser::parseLeftHandSideExpression() if (m_scanner->getCurrentToken() == Token::NEW) { expectToken(Token::NEW); - ASTPointer<Identifier> contractName = ASTNodeFactory(*this).createNode<Identifier>(expectIdentifierToken()); - nodeFactory.markEndPosition(); + ASTPointer<Identifier> contractName(parseIdentifier()); + nodeFactory.setEndPositionFromNode(contractName); expression = nodeFactory.createNode<NewExpression>(contractName); } else @@ -55,6 +55,7 @@ private: ASTPointer<VariableDeclaration> parseVariableDeclaration(bool _allowVar); ASTPointer<ModifierDefinition> parseModifierDefinition(); ASTPointer<ModifierInvocation> parseModifierInvocation(); + ASTPointer<Identifier> parseIdentifier(); ASTPointer<TypeName> parseTypeName(bool _allowVar); ASTPointer<Mapping> parseMapping(); ASTPointer<ParameterList> parseParameterList(bool _allowEmpty = true); |