mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Parsing for inline assembly.
This commit is contained in:
@@ -20,11 +20,13 @@
|
||||
* Solidity parser.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <vector>
|
||||
#include <libdevcore/Log.h>
|
||||
#include <libevmasm/SourceLocation.h>
|
||||
#include <libsolidity/parsing/Parser.h>
|
||||
#include <libsolidity/parsing/Scanner.h>
|
||||
#include <libsolidity/inlineasm/AsmParser.h>
|
||||
#include <libsolidity/interface/Exceptions.h>
|
||||
#include <libsolidity/interface/InterfaceHandler.h>
|
||||
|
||||
@@ -712,6 +714,8 @@ ASTPointer<Statement> Parser::parseStatement()
|
||||
m_scanner->next();
|
||||
break;
|
||||
}
|
||||
case Token::Assembly:
|
||||
return parseInlineAssembly(docString);
|
||||
case Token::Identifier:
|
||||
if (m_insideModifier && m_scanner->currentLiteral() == "_")
|
||||
{
|
||||
@@ -727,6 +731,22 @@ ASTPointer<Statement> Parser::parseStatement()
|
||||
return statement;
|
||||
}
|
||||
|
||||
ASTPointer<InlineAssembly> Parser::parseInlineAssembly(ASTPointer<ASTString> const& _docString)
|
||||
{
|
||||
ASTNodeFactory nodeFactory(*this);
|
||||
expectToken(Token::Assembly);
|
||||
if (m_scanner->currentToken() != Token::StringLiteral)
|
||||
fatalParserError("Expected assembly name.");
|
||||
if (m_scanner->currentLiteral() != "evmasm")
|
||||
fatalParserError("Only \"evmasm\" supported.");
|
||||
m_scanner->next();
|
||||
|
||||
InlineAssemblyParser parser(m_errors);
|
||||
shared_ptr<InlineAssemblyBlock> operations = parser.parse(m_scanner);
|
||||
nodeFactory.markEndPosition();
|
||||
return nodeFactory.createNode<InlineAssembly>(_docString, operations);
|
||||
}
|
||||
|
||||
ASTPointer<IfStatement> Parser::parseIfStatement(ASTPointer<ASTString> const& _docString)
|
||||
{
|
||||
ASTNodeFactory nodeFactory(*this);
|
||||
|
||||
Reference in New Issue
Block a user