diff options
author | chriseth <chris@ethereum.org> | 2017-07-03 20:52:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-03 20:52:29 +0800 |
commit | 76d3b7c5a160e1f550c710e6850ee6f116142ca1 (patch) | |
tree | 93c96f7073617b4f56c8c355cdc30701aec4818b /libsolidity/parsing/ParserBase.cpp | |
parent | 78969364608ba60d1654f4d1738886d13112b6cd (diff) | |
parent | 2222ddecf49b5b901f63b9e7449ee76c9f51c47a (diff) | |
download | dexon-solidity-76d3b7c5a160e1f550c710e6850ee6f116142ca1.tar dexon-solidity-76d3b7c5a160e1f550c710e6850ee6f116142ca1.tar.gz dexon-solidity-76d3b7c5a160e1f550c710e6850ee6f116142ca1.tar.bz2 dexon-solidity-76d3b7c5a160e1f550c710e6850ee6f116142ca1.tar.lz dexon-solidity-76d3b7c5a160e1f550c710e6850ee6f116142ca1.tar.xz dexon-solidity-76d3b7c5a160e1f550c710e6850ee6f116142ca1.tar.zst dexon-solidity-76d3b7c5a160e1f550c710e6850ee6f116142ca1.zip |
Merge pull request #2510 from ethereum/develop
Version 0.4.12
Diffstat (limited to 'libsolidity/parsing/ParserBase.cpp')
-rw-r--r-- | libsolidity/parsing/ParserBase.cpp | 87 |
1 files changed, 23 insertions, 64 deletions
diff --git a/libsolidity/parsing/ParserBase.cpp b/libsolidity/parsing/ParserBase.cpp index 87d47f4b..5657c2c0 100644 --- a/libsolidity/parsing/ParserBase.cpp +++ b/libsolidity/parsing/ParserBase.cpp @@ -22,6 +22,7 @@ #include <libsolidity/parsing/ParserBase.h> #include <libsolidity/parsing/Scanner.h> +#include <libsolidity/interface/ErrorReporter.h> using namespace std; using namespace dev; @@ -42,6 +43,26 @@ int ParserBase::endPosition() const return m_scanner->currentLocation().end; } +Token::Value ParserBase::currentToken() const +{ + return m_scanner->currentToken(); +} + +Token::Value ParserBase::peekNextToken() const +{ + return m_scanner->peekNextToken(); +} + +std::string ParserBase::currentLiteral() const +{ + return m_scanner->currentLiteral(); +} + +Token::Value ParserBase::advance() +{ + return m_scanner->next(); +} + void ParserBase::expectToken(Token::Value _value) { Token::Value tok = m_scanner->currentToken(); @@ -80,74 +101,12 @@ void ParserBase::expectToken(Token::Value _value) m_scanner->next(); } -Token::Value ParserBase::expectAssignmentOperator() -{ - Token::Value op = m_scanner->currentToken(); - if (!Token::isAssignmentOp(op)) - { - if (Token::isElementaryTypeName(op)) //for the sake of accuracy in reporting - { - ElementaryTypeNameToken elemTypeName = m_scanner->currentElementaryTypeNameToken(); - fatalParserError( - string("Expected assignment operator, got '") + - elemTypeName.toString() + - string("'") - ); - } - else - fatalParserError( - string("Expected assignment operator, got '") + - string(Token::name(m_scanner->currentToken())) + - string("'") - ); - } - m_scanner->next(); - return op; -} - -ASTPointer<ASTString> ParserBase::expectIdentifierToken() -{ - Token::Value id = m_scanner->currentToken(); - if (id != Token::Identifier) - { - if (Token::isElementaryTypeName(id)) //for the sake of accuracy in reporting - { - ElementaryTypeNameToken elemTypeName = m_scanner->currentElementaryTypeNameToken(); - fatalParserError( - string("Expected identifier, got '") + - elemTypeName.toString() + - string("'") - ); - } - else - fatalParserError( - string("Expected identifier, got '") + - string(Token::name(id)) + - string("'") - ); - } - return getLiteralAndAdvance(); -} - -ASTPointer<ASTString> ParserBase::getLiteralAndAdvance() -{ - ASTPointer<ASTString> identifier = make_shared<ASTString>(m_scanner->currentLiteral()); - m_scanner->next(); - return identifier; -} - void ParserBase::parserError(string const& _description) { - auto err = make_shared<Error>(Error::Type::ParserError); - *err << - errinfo_sourceLocation(SourceLocation(position(), position(), sourceName())) << - errinfo_comment(_description); - - m_errors.push_back(err); + m_errorReporter.parserError(SourceLocation(position(), position(), sourceName()), _description); } void ParserBase::fatalParserError(string const& _description) { - parserError(_description); - BOOST_THROW_EXCEPTION(FatalError()); + m_errorReporter.fatalParserError(SourceLocation(position(), position(), sourceName()), _description); } |