mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Some fixes in parser.
This commit is contained in:
parent
5d3e21fd93
commit
34d07fc583
@ -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--;
|
||||
|
@ -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;
|
||||
|
@ -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&) { }
|
||||
|
15
Parser.cpp
15
Parser.cpp
@ -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
|
||||
|
1
Parser.h
1
Parser.h
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user