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
@@ -81,13 +81,14 @@ private:
|
||||
SourceLocation m_location;
|
||||
};
|
||||
|
||||
ASTPointer<SourceUnit> Parser::parse(shared_ptr<Scanner> const& _scanner)
|
||||
ASTPointer<SourceUnit> Parser::parse(CharStream& _charStream)
|
||||
{
|
||||
solAssert(!m_insideModifier, "");
|
||||
try
|
||||
{
|
||||
m_recursionDepth = 0;
|
||||
m_scanner = _scanner;
|
||||
m_source = &_charStream;
|
||||
m_scanner = make_shared<Scanner>(_charStream);
|
||||
ASTNodeFactory nodeFactory(*this);
|
||||
|
||||
vector<ASTPointer<ASTNode>> nodes;
|
||||
@@ -2056,14 +2057,16 @@ bool Parser::variableDeclarationStart()
|
||||
|
||||
optional<string> Parser::findLicenseString(std::vector<ASTPointer<ASTNode>> const& _nodes)
|
||||
{
|
||||
solAssert(!!m_source, "");
|
||||
|
||||
// We circumvent the scanner here, because it skips non-docstring comments.
|
||||
static regex const licenseRegex("SPDX-License-Identifier:\\s*([a-zA-Z0-9 ()+.-]+)");
|
||||
|
||||
// Search inside all parts of the source not covered by parsed nodes.
|
||||
// This will leave e.g. "global comments".
|
||||
string const& source = m_scanner->source();
|
||||
using iter = decltype(source.begin());
|
||||
using iter = std::string::const_iterator;
|
||||
vector<pair<iter, iter>> sequencesToSearch;
|
||||
string const& source = m_source->source();
|
||||
sequencesToSearch.emplace_back(source.begin(), source.end());
|
||||
for (ASTPointer<ASTNode> const& node: _nodes)
|
||||
if (node->location().hasText())
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace solidity::langutil
|
||||
{
|
||||
class Scanner;
|
||||
class CharStream;
|
||||
}
|
||||
|
||||
namespace solidity::frontend
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
m_evmVersion(_evmVersion)
|
||||
{}
|
||||
|
||||
ASTPointer<SourceUnit> parse(std::shared_ptr<langutil::Scanner> const& _scanner);
|
||||
ASTPointer<SourceUnit> parse(langutil::CharStream& _charStream);
|
||||
|
||||
private:
|
||||
class ASTNodeFactory;
|
||||
@@ -211,6 +211,7 @@ private:
|
||||
/// Creates an empty ParameterList at the current location (used if parameters can be omitted).
|
||||
ASTPointer<ParameterList> createEmptyParameterList();
|
||||
|
||||
langutil::CharStream* m_source = nullptr;
|
||||
/// Flag that signifies whether '_' is parsed as a PlaceholderStatement or a regular identifier.
|
||||
bool m_insideModifier = false;
|
||||
langutil::EVMVersion m_evmVersion;
|
||||
|
||||
Reference in New Issue
Block a user