aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/parsing/Parser.cpp
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-05-25 05:55:29 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-05-27 03:44:34 +0800
commit2fefe3b5497172a16094014b66e148b707bc7492 (patch)
treec59e2979a0e8809e22eebf5f85e991d214ac8222 /libsolidity/parsing/Parser.cpp
parent788b64ea6181af6e7e364e86d64508c4809ca9b7 (diff)
downloaddexon-solidity-2fefe3b5497172a16094014b66e148b707bc7492.tar.gz
dexon-solidity-2fefe3b5497172a16094014b66e148b707bc7492.tar.zst
dexon-solidity-2fefe3b5497172a16094014b66e148b707bc7492.zip
Move Solidity specific methods from ParserBase to the Solidity Parser
Diffstat (limited to 'libsolidity/parsing/Parser.cpp')
-rw-r--r--libsolidity/parsing/Parser.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp
index 72150a3e..470586cf 100644
--- a/libsolidity/parsing/Parser.cpp
+++ b/libsolidity/parsing/Parser.cpp
@@ -1437,5 +1437,61 @@ ASTPointer<ParameterList> Parser::createEmptyParameterList()
return nodeFactory.createNode<ParameterList>(vector<ASTPointer<VariableDeclaration>>());
}
+Token::Value Parser::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> Parser::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> Parser::getLiteralAndAdvance()
+{
+ ASTPointer<ASTString> identifier = make_shared<ASTString>(m_scanner->currentLiteral());
+ m_scanner->next();
+ return identifier;
+}
+
}
}