aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-05-25 07:13:51 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-05-27 03:44:34 +0800
commit9337003d5e623cd52c55001222b629543c859cd7 (patch)
tree46a528b75514a9de5fdc9470b4fafd50ad86ac18 /libsolidity
parent3459052ae83ac08082855d41e21c297ac5f852b5 (diff)
downloaddexon-solidity-9337003d5e623cd52c55001222b629543c859cd7.tar.gz
dexon-solidity-9337003d5e623cd52c55001222b629543c859cd7.tar.zst
dexon-solidity-9337003d5e623cd52c55001222b629543c859cd7.zip
Use the new ParserBase API in AsmParser
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/inlineasm/AsmParser.cpp66
1 files changed, 33 insertions, 33 deletions
diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp
index 605d27be..80409c63 100644
--- a/libsolidity/inlineasm/AsmParser.cpp
+++ b/libsolidity/inlineasm/AsmParser.cpp
@@ -50,16 +50,16 @@ assembly::Block Parser::parseBlock()
{
assembly::Block block = createWithLocation<Block>();
expectToken(Token::LBrace);
- while (m_scanner->currentToken() != Token::RBrace)
+ while (currentToken() != Token::RBrace)
block.statements.emplace_back(parseStatement());
block.location.end = endPosition();
- m_scanner->next();
+ advance();
return block;
}
assembly::Statement Parser::parseStatement()
{
- switch (m_scanner->currentToken())
+ switch (currentToken())
{
case Token::Let:
return parseVariableDeclaration();
@@ -92,10 +92,10 @@ assembly::Statement Parser::parseStatement()
if (m_julia)
break;
assembly::StackAssignment assignment = createWithLocation<assembly::StackAssignment>();
- m_scanner->next();
+ advance();
expectToken(Token::Colon);
assignment.variableName.location = location();
- assignment.variableName.name = m_scanner->currentLiteral();
+ assignment.variableName.name = currentLiteral();
if (!m_julia && instructions().count(assignment.variableName.name))
fatalParserError("Identifier expected, got instruction name.");
assignment.location.end = endPosition();
@@ -110,7 +110,7 @@ assembly::Statement Parser::parseStatement()
// literal,
// identifier (might turn into label or functional assignment)
Statement statement(parseElementaryOperation(false));
- switch (m_scanner->currentToken())
+ switch (currentToken())
{
case Token::LParen:
return parseCall(std::move(statement));
@@ -119,15 +119,15 @@ assembly::Statement Parser::parseStatement()
if (statement.type() != typeid(assembly::Identifier))
fatalParserError("Label name / variable name must precede \":\".");
assembly::Identifier const& identifier = boost::get<assembly::Identifier>(statement);
- m_scanner->next();
+ advance();
// identifier:=: should be parsed as identifier: =: (i.e. a label),
// while identifier:= (being followed by a non-colon) as identifier := (assignment).
- if (m_scanner->currentToken() == Token::Assign && m_scanner->peekNextToken() != Token::Colon)
+ if (currentToken() == Token::Assign && peekNextToken() != Token::Colon)
{
assembly::Assignment assignment = createWithLocation<assembly::Assignment>(identifier.location);
if (!m_julia && instructions().count(identifier.name))
fatalParserError("Cannot use instruction names for identifier names.");
- m_scanner->next();
+ advance();
assignment.variableName = identifier;
assignment.value.reset(new Statement(parseExpression()));
assignment.location.end = locationOf(*assignment.value).end;
@@ -174,7 +174,7 @@ assembly::Case Parser::parseCase()
assembly::Statement Parser::parseExpression()
{
Statement operation = parseElementaryOperation(true);
- if (m_scanner->currentToken() == Token::LParen)
+ if (currentToken() == Token::LParen)
return parseCall(std::move(operation));
else
return operation;
@@ -207,7 +207,7 @@ std::map<string, dev::solidity::Instruction> const& Parser::instructions()
assembly::Statement Parser::parseElementaryOperation(bool _onlySinglePusher)
{
Statement ret;
- switch (m_scanner->currentToken())
+ switch (currentToken())
{
case Token::Identifier:
case Token::Return:
@@ -215,14 +215,14 @@ assembly::Statement Parser::parseElementaryOperation(bool _onlySinglePusher)
case Token::Address:
{
string literal;
- if (m_scanner->currentToken() == Token::Return)
+ if (currentToken() == Token::Return)
literal = "return";
- else if (m_scanner->currentToken() == Token::Byte)
+ else if (currentToken() == Token::Byte)
literal = "byte";
- else if (m_scanner->currentToken() == Token::Address)
+ else if (currentToken() == Token::Address)
literal = "address";
else
- literal = m_scanner->currentLiteral();
+ literal = currentLiteral();
// first search the set of instructions.
if (!m_julia && instructions().count(literal))
{
@@ -237,7 +237,7 @@ assembly::Statement Parser::parseElementaryOperation(bool _onlySinglePusher)
}
else
ret = Identifier{location(), literal};
- m_scanner->next();
+ advance();
break;
}
case Token::StringLiteral:
@@ -246,7 +246,7 @@ assembly::Statement Parser::parseElementaryOperation(bool _onlySinglePusher)
case Token::FalseLiteral:
{
LiteralKind kind = LiteralKind::Number;
- switch (m_scanner->currentToken())
+ switch (currentToken())
{
case Token::StringLiteral:
kind = LiteralKind::String;
@@ -265,10 +265,10 @@ assembly::Statement Parser::parseElementaryOperation(bool _onlySinglePusher)
Literal literal{
location(),
kind,
- m_scanner->currentLiteral(),
+ currentLiteral(),
""
};
- m_scanner->next();
+ advance();
if (m_julia)
{
expectToken(Token::Colon);
@@ -297,7 +297,7 @@ assembly::VariableDeclaration Parser::parseVariableDeclaration()
while (true)
{
varDecl.variables.emplace_back(parseTypedName());
- if (m_scanner->currentToken() == Token::Comma)
+ if (currentToken() == Token::Comma)
expectToken(Token::Comma);
else
break;
@@ -315,22 +315,22 @@ assembly::FunctionDefinition Parser::parseFunctionDefinition()
expectToken(Token::Function);
funDef.name = expectAsmIdentifier();
expectToken(Token::LParen);
- while (m_scanner->currentToken() != Token::RParen)
+ while (currentToken() != Token::RParen)
{
funDef.arguments.emplace_back(parseTypedName());
- if (m_scanner->currentToken() == Token::RParen)
+ if (currentToken() == Token::RParen)
break;
expectToken(Token::Comma);
}
expectToken(Token::RParen);
- if (m_scanner->currentToken() == Token::Sub)
+ if (currentToken() == Token::Sub)
{
expectToken(Token::Sub);
expectToken(Token::GreaterThan);
while (true)
{
funDef.returns.emplace_back(parseTypedName());
- if (m_scanner->currentToken() == Token::LBrace)
+ if (currentToken() == Token::LBrace)
break;
expectToken(Token::Comma);
}
@@ -359,7 +359,7 @@ assembly::Statement Parser::parseCall(assembly::Statement&& _instruction)
for (unsigned i = 0; i < args; ++i)
{
/// check for premature closing parentheses
- if (m_scanner->currentToken() == Token::RParen)
+ if (currentToken() == Token::RParen)
fatalParserError(string(
"Expected expression (" +
instrInfo.name +
@@ -371,7 +371,7 @@ assembly::Statement Parser::parseCall(assembly::Statement&& _instruction)
ret.arguments.emplace_back(parseExpression());
if (i != args - 1)
{
- if (m_scanner->currentToken() != Token::Comma)
+ if (currentToken() != Token::Comma)
fatalParserError(string(
"Expected comma (" +
instrInfo.name +
@@ -380,11 +380,11 @@ assembly::Statement Parser::parseCall(assembly::Statement&& _instruction)
" arguments)"
));
else
- m_scanner->next();
+ advance();
}
}
ret.location.end = endPosition();
- if (m_scanner->currentToken() == Token::Comma)
+ if (currentToken() == Token::Comma)
fatalParserError(
string("Expected ')' (" + instrInfo.name + " expects " + boost::lexical_cast<string>(args) + " arguments)")
);
@@ -397,10 +397,10 @@ assembly::Statement Parser::parseCall(assembly::Statement&& _instruction)
ret.functionName = std::move(boost::get<Identifier>(_instruction));
ret.location = ret.functionName.location;
expectToken(Token::LParen);
- while (m_scanner->currentToken() != Token::RParen)
+ while (currentToken() != Token::RParen)
{
ret.arguments.emplace_back(parseExpression());
- if (m_scanner->currentToken() == Token::RParen)
+ if (currentToken() == Token::RParen)
break;
expectToken(Token::Comma);
}
@@ -433,12 +433,12 @@ TypedName Parser::parseTypedName()
string Parser::expectAsmIdentifier()
{
- string name = m_scanner->currentLiteral();
+ string name = currentLiteral();
if (m_julia)
{
- if (m_scanner->currentToken() == Token::Bool)
+ if (currentToken() == Token::Bool)
{
- m_scanner->next();
+ advance();
return name;
}
}