Skip to content

Commit

Permalink
AsmParser: Refactor the @src regex
Browse files Browse the repository at this point in the history
  • Loading branch information
cameel committed Sep 9, 2021
1 parent 33ac547 commit e3a5f92
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions libyul/AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ void Parser::fetchSourceLocationFromComment()
return;

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
);

Expand All @@ -141,11 +142,11 @@ void Parser::fetchSourceLocationFromComment()

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 start = toInt(matchResult[3].str());
auto const end = toInt(matchResult[4].str());
auto const sourceIndex = toInt(matchResult[1].str());
auto const start = toInt(matchResult[2].str());
auto const end = toInt(matchResult[3].str());

auto const commentLocation = m_scanner->currentCommentLocation();
m_debugDataOverride = DebugData::create();
Expand Down

0 comments on commit e3a5f92

Please sign in to comment.