AsmParser: Refactor the @src regex

This commit is contained in:
Kamil Śliwak 2021-09-02 15:08:47 +02:00
parent 33ac5478de
commit e3a5f923eb

View File

@ -131,7 +131,8 @@ void Parser::fetchSourceLocationFromComment()
return; return;
static regex const lineRE = std::regex( static regex const lineRE = std::regex(
R"~~~((^|\s*)@src\s+(-1|\d+):(-1|\d+):(-1|\d+)(\s+|$))~~~", R"~~(\s*@src\s+)~~" // tag: @src
R"~~((-1|\d+):(-1|\d+):(-1|\d+)(?:\s+|$))~~", // index and location, e.g.: 1:234:-1
std::regex_constants::ECMAScript | std::regex_constants::optimize std::regex_constants::ECMAScript | std::regex_constants::optimize
); );
@ -141,11 +142,11 @@ void Parser::fetchSourceLocationFromComment()
for (auto const& matchResult: ranges::make_subrange(from, to)) for (auto const& matchResult: ranges::make_subrange(from, to))
{ {
solAssert(matchResult.size() == 6, ""); solAssert(matchResult.size() == 4, "");
auto const sourceIndex = toInt(matchResult[2].str()); auto const sourceIndex = toInt(matchResult[1].str());
auto const start = toInt(matchResult[3].str()); auto const start = toInt(matchResult[2].str());
auto const end = toInt(matchResult[4].str()); auto const end = toInt(matchResult[3].str());
auto const commentLocation = m_scanner->currentCommentLocation(); auto const commentLocation = m_scanner->currentCommentLocation();
m_debugDataOverride = DebugData::create(); m_debugDataOverride = DebugData::create();