Scanner hack.

This commit is contained in:
Daniel Kirchner 2023-06-13 20:42:59 +02:00 committed by Nikola Matic
parent fa815764dd
commit 093ec110cf
4 changed files with 14 additions and 8 deletions

View File

@ -324,6 +324,14 @@ namespace TokenTraits
tok == Token::Default || tok == Token::For || tok == Token::Break || tok == Token::Continue || tok == Token::Leave || tok == Token::Default || tok == Token::For || tok == Token::Break || tok == Token::Continue || tok == Token::Leave ||
tok == Token::TrueLiteral || tok == Token::FalseLiteral || tok == Token::HexStringLiteral || tok == Token::Hex; tok == Token::TrueLiteral || tok == Token::FalseLiteral || tok == Token::HexStringLiteral || tok == Token::Hex;
} }
constexpr bool isExperimentalSolidityKeyword(Token tok)
{
return tok == Token::Assembly || tok == Token::Contract || tok == Token::External || tok == Token::Fallback;
}
constexpr bool isExperimentalSolidityOnlyKeyword(Token)
{
return false;
}
constexpr bool isExperimentalSolidityKeyword(Token token) constexpr bool isExperimentalSolidityKeyword(Token token)
{ {

View File

@ -418,14 +418,6 @@ private:
/// @returns true if the contract is requested to be compiled. /// @returns true if the contract is requested to be compiled.
bool isRequestedContract(ContractDefinition const& _contract) const; bool isRequestedContract(ContractDefinition const& _contract) const;
/// Perform the analysis steps of legacy language mode.
/// @returns false on error.
bool analyzeLegacy(bool _noErrorsSoFar);
/// Perform the analysis steps of experimental language mode.
/// @returns false on error.
bool analyzeExperimental();
/// Assembles the contract. /// Assembles the contract.
/// This function should only be internally called by compileContract and generateEVMFromIR. /// This function should only be internally called by compileContract and generateEVMFromIR.
void assembleYul( void assembleYul(
@ -511,6 +503,7 @@ private:
std::map<std::string, util::h160> m_libraries; std::map<std::string, util::h160> m_libraries;
ImportRemapper m_importRemapper; ImportRemapper m_importRemapper;
std::map<std::string const, Source> m_sources; std::map<std::string const, Source> m_sources;
std::optional<int64_t> m_maxAstId;
std::vector<std::string> m_unhandledSMTLib2Queries; std::vector<std::string> m_unhandledSMTLib2Queries;
std::map<util::h256, std::string> m_smtlib2Responses; std::map<util::h256, std::string> m_smtlib2Responses;
std::shared_ptr<GlobalContext> m_globalContext; std::shared_ptr<GlobalContext> m_globalContext;

View File

@ -100,6 +100,9 @@ ASTPointer<SourceUnit> Parser::parse(CharStream& _charStream)
while (m_scanner->currentToken() == Token::Pragma) while (m_scanner->currentToken() == Token::Pragma)
nodes.push_back(parsePragmaDirective(false)); nodes.push_back(parsePragmaDirective(false));
if (m_experimentalSolidityEnabledInCurrentSourceUnit)
m_scanner->setScannerMode(ScannerKind::ExperimentalSolidity);
while (m_scanner->currentToken() != Token::EOS) while (m_scanner->currentToken() != Token::EOS)
{ {
switch (m_scanner->currentToken()) switch (m_scanner->currentToken())

View File

@ -197,6 +197,8 @@ private:
/// Returns the next AST node ID /// Returns the next AST node ID
int64_t nextID() { return ++m_currentNodeID; } int64_t nextID() { return ++m_currentNodeID; }
/// Returns the maximal AST node ID assigned so far
int64_t maxID() const { return m_currentNodeID; }
std::pair<LookAheadInfo, IndexAccessedPath> tryParseIndexAccessedPath(); std::pair<LookAheadInfo, IndexAccessedPath> tryParseIndexAccessedPath();
/// Performs limited look-ahead to distinguish between variable declaration and expression statement. /// Performs limited look-ahead to distinguish between variable declaration and expression statement.