mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Remove scanner from compiler stack.
This commit is contained in:
committed by
Christian Parpart
parent
af18b8afc2
commit
ffc5cfd9a5
@@ -26,7 +26,8 @@
|
||||
#include <liblangutil/SourceLocation.h>
|
||||
#include <libevmasm/Assembly.h>
|
||||
|
||||
#include <liblangutil/Scanner.h>
|
||||
#include <liblangutil/CharStream.h>
|
||||
|
||||
#include <libsolidity/parsing/Parser.h>
|
||||
#include <libsolidity/analysis/DeclarationTypeChecker.h>
|
||||
#include <libsolidity/analysis/NameAndTypeResolver.h>
|
||||
@@ -58,7 +59,7 @@ evmasm::AssemblyItems compileContract(std::shared_ptr<CharStream> _sourceCode)
|
||||
ErrorReporter errorReporter(errors);
|
||||
Parser parser(errorReporter, solidity::test::CommonOptions::get().evmVersion());
|
||||
ASTPointer<SourceUnit> sourceUnit;
|
||||
BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared<Scanner>(_sourceCode)));
|
||||
BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(*_sourceCode));
|
||||
BOOST_CHECK(!!sourceUnit);
|
||||
|
||||
Scoper::assignScopes(*sourceUnit);
|
||||
|
||||
@@ -43,7 +43,8 @@ namespace
|
||||
|
||||
SemVerMatchExpression parseExpression(string const& _input)
|
||||
{
|
||||
Scanner scanner{CharStream(_input, "")};
|
||||
CharStream stream(_input, "");
|
||||
Scanner scanner{stream};
|
||||
vector<string> literals;
|
||||
vector<Token> tokens;
|
||||
while (scanner.currentToken() != Token::EOS)
|
||||
|
||||
@@ -101,15 +101,14 @@ bytes compileFirstExpression(
|
||||
)
|
||||
{
|
||||
string sourceCode = "pragma solidity >=0.0; // SPDX-License-Identifier: GPL-3\n" + _sourceCode;
|
||||
CharStream stream(sourceCode, "");
|
||||
|
||||
ASTPointer<SourceUnit> sourceUnit;
|
||||
try
|
||||
{
|
||||
ErrorList errors;
|
||||
ErrorReporter errorReporter(errors);
|
||||
sourceUnit = Parser(errorReporter, solidity::test::CommonOptions::get().evmVersion()).parse(
|
||||
make_shared<Scanner>(CharStream(sourceCode, ""))
|
||||
);
|
||||
sourceUnit = Parser(errorReporter, solidity::test::CommonOptions::get().evmVersion()).parse(stream);
|
||||
if (!sourceUnit)
|
||||
return bytes();
|
||||
}
|
||||
|
||||
@@ -42,11 +42,12 @@ namespace
|
||||
ASTPointer<ContractDefinition> parseText(std::string const& _source, ErrorList& _errors, bool errorRecovery = false)
|
||||
{
|
||||
ErrorReporter errorReporter(_errors);
|
||||
auto charStream = CharStream(_source, "");
|
||||
ASTPointer<SourceUnit> sourceUnit = Parser(
|
||||
errorReporter,
|
||||
solidity::test::CommonOptions::get().evmVersion(),
|
||||
errorRecovery
|
||||
).parse(std::make_shared<Scanner>(CharStream(_source, "")));
|
||||
).parse(charStream);
|
||||
if (!sourceUnit)
|
||||
return ASTPointer<ContractDefinition>();
|
||||
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
|
||||
|
||||
Reference in New Issue
Block a user