diff options
-rw-r--r-- | Parser.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
@@ -26,12 +26,14 @@ #include <libsolidity/Scanner.h> #include <libsolidity/Exceptions.h> +using namespace std; + namespace dev { namespace solidity { -ASTPointer<ContractDefinition> Parser::parse(std::shared_ptr<Scanner> const& _scanner) +ASTPointer<ContractDefinition> Parser::parse(shared_ptr<Scanner> const& _scanner) { m_scanner = _scanner; return parseContractDefinition(); @@ -55,7 +57,7 @@ public: { if (m_location.end < 0) markEndPosition(); - return std::make_shared<NodeType>(m_location, std::forward<Args>(_args)...); + return make_shared<NodeType>(m_location, forward<Args>(_args)...); } private: @@ -79,9 +81,9 @@ ASTPointer<ContractDefinition> Parser::parseContractDefinition() expectToken(Token::CONTRACT); ASTPointer<ASTString> name = expectIdentifierToken(); expectToken(Token::LBRACE); - std::vector<ASTPointer<StructDefinition>> structs; - std::vector<ASTPointer<VariableDeclaration>> stateVariables; - std::vector<ASTPointer<FunctionDefinition>> functions; + vector<ASTPointer<StructDefinition>> structs; + vector<ASTPointer<VariableDeclaration>> stateVariables; + vector<ASTPointer<FunctionDefinition>> functions; bool visibilityIsPublic = true; while (true) { @@ -119,7 +121,7 @@ ASTPointer<FunctionDefinition> Parser::parseFunctionDefinition(bool _isPublic) ASTNodeFactory nodeFactory(*this); ASTPointer<ASTString> docstring; if (m_scanner->getCurrentCommentLiteral() != "") - docstring = std::make_shared<ASTString>(m_scanner->getCurrentCommentLiteral()); + docstring = make_shared<ASTString>(m_scanner->getCurrentCommentLiteral()); expectToken(Token::FUNCTION); ASTPointer<ASTString> name(expectIdentifierToken()); @@ -142,7 +144,7 @@ ASTPointer<FunctionDefinition> Parser::parseFunctionDefinition(bool _isPublic) // create an empty parameter list at a zero-length location ASTNodeFactory nodeFactory(*this); nodeFactory.setLocationEmpty(); - returnParameters = nodeFactory.createNode<ParameterList>(std::vector<ASTPointer<VariableDeclaration>>()); + returnParameters = nodeFactory.createNode<ParameterList>(vector<ASTPointer<VariableDeclaration>>()); } ASTPointer<Block> block = parseBlock(); nodeFactory.setEndPositionFromNode(block); @@ -156,7 +158,7 @@ ASTPointer<StructDefinition> Parser::parseStructDefinition() ASTNodeFactory nodeFactory(*this); expectToken(Token::STRUCT); ASTPointer<ASTString> name = expectIdentifierToken(); - std::vector<ASTPointer<VariableDeclaration>> members; + vector<ASTPointer<VariableDeclaration>> members; expectToken(Token::LBRACE); while (m_scanner->getCurrentToken() != Token::RBRACE) { @@ -228,7 +230,7 @@ ASTPointer<Mapping> Parser::parseMapping() ASTPointer<ParameterList> Parser::parseParameterList(bool _allowEmpty) { ASTNodeFactory nodeFactory(*this); - std::vector<ASTPointer<VariableDeclaration>> parameters; + vector<ASTPointer<VariableDeclaration>> parameters; expectToken(Token::LPAREN); if (!_allowEmpty || m_scanner->getCurrentToken() != Token::RPAREN) { @@ -249,7 +251,7 @@ ASTPointer<Block> Parser::parseBlock() { ASTNodeFactory nodeFactory(*this); expectToken(Token::LBRACE); - std::vector<ASTPointer<Statement>> statements; + vector<ASTPointer<Statement>> statements; while (m_scanner->getCurrentToken() != Token::RBRACE) statements.push_back(parseStatement()); nodeFactory.markEndPosition(); @@ -447,7 +449,7 @@ ASTPointer<Expression> Parser::parseLeftHandSideExpression() case Token::LPAREN: { m_scanner->next(); - std::vector<ASTPointer<Expression>> arguments = parseFunctionCallArguments(); + vector<ASTPointer<Expression>> arguments = parseFunctionCallArguments(); nodeFactory.markEndPosition(); expectToken(Token::RPAREN); expression = nodeFactory.createNode<FunctionCall>(expression, arguments); @@ -503,9 +505,9 @@ ASTPointer<Expression> Parser::parsePrimaryExpression() return expression; } -std::vector<ASTPointer<Expression>> Parser::parseFunctionCallArguments() +vector<ASTPointer<Expression>> Parser::parseFunctionCallArguments() { - std::vector<ASTPointer<Expression>> arguments; + vector<ASTPointer<Expression>> arguments; if (m_scanner->getCurrentToken() != Token::RPAREN) { arguments.push_back(parseExpression()); @@ -521,7 +523,7 @@ std::vector<ASTPointer<Expression>> Parser::parseFunctionCallArguments() void Parser::expectToken(Token::Value _value) { if (m_scanner->getCurrentToken() != _value) - BOOST_THROW_EXCEPTION(createParserError(std::string("Expected token ") + std::string(Token::getName(_value)))); + BOOST_THROW_EXCEPTION(createParserError(string("Expected token ") + string(Token::getName(_value)))); m_scanner->next(); } @@ -543,12 +545,12 @@ ASTPointer<ASTString> Parser::expectIdentifierToken() ASTPointer<ASTString> Parser::getLiteralAndAdvance() { - ASTPointer<ASTString> identifier = std::make_shared<ASTString>(m_scanner->getCurrentLiteral()); + ASTPointer<ASTString> identifier = make_shared<ASTString>(m_scanner->getCurrentLiteral()); m_scanner->next(); return identifier; } -ParserError Parser::createParserError(std::string const& _description) const +ParserError Parser::createParserError(string const& _description) const { return ParserError() << errinfo_sourcePosition(getPosition()) << errinfo_comment(_description); } |