From 093ec110cffd6139a2b822f2730f0d247606a606 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Tue, 13 Jun 2023 20:42:59 +0200 Subject: [PATCH] Scanner hack. --- liblangutil/Token.h | 8 ++++++++ libsolidity/interface/CompilerStack.h | 9 +-------- libsolidity/parsing/Parser.cpp | 3 +++ libsolidity/parsing/Parser.h | 2 ++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/liblangutil/Token.h b/liblangutil/Token.h index d79c7f193..1673e407f 100644 --- a/liblangutil/Token.h +++ b/liblangutil/Token.h @@ -324,6 +324,14 @@ namespace TokenTraits 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; } + 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) { diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index c203d5f49..ae0dbb631 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -418,14 +418,6 @@ private: /// @returns true if the contract is requested to be compiled. 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. /// This function should only be internally called by compileContract and generateEVMFromIR. void assembleYul( @@ -511,6 +503,7 @@ private: std::map m_libraries; ImportRemapper m_importRemapper; std::map m_sources; + std::optional m_maxAstId; std::vector m_unhandledSMTLib2Queries; std::map m_smtlib2Responses; std::shared_ptr m_globalContext; diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 1f5611a2f..e7d46892a 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -100,6 +100,9 @@ ASTPointer Parser::parse(CharStream& _charStream) while (m_scanner->currentToken() == Token::Pragma) nodes.push_back(parsePragmaDirective(false)); + if (m_experimentalSolidityEnabledInCurrentSourceUnit) + m_scanner->setScannerMode(ScannerKind::ExperimentalSolidity); + while (m_scanner->currentToken() != Token::EOS) { switch (m_scanner->currentToken()) diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h index 5f2a1213d..df282cb99 100644 --- a/libsolidity/parsing/Parser.h +++ b/libsolidity/parsing/Parser.h @@ -197,6 +197,8 @@ private: /// Returns the next AST node ID int64_t nextID() { return ++m_currentNodeID; } + /// Returns the maximal AST node ID assigned so far + int64_t maxID() const { return m_currentNodeID; } std::pair tryParseIndexAccessedPath(); /// Performs limited look-ahead to distinguish between variable declaration and expression statement.