From e3a5f923eb71f221cd26c5881b0c330159b86177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Thu, 2 Sep 2021 15:08:47 +0200 Subject: [PATCH] AsmParser: Refactor the @src regex --- libyul/AsmParser.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp index d1465c737..9d1395585 100644 --- a/libyul/AsmParser.cpp +++ b/libyul/AsmParser.cpp @@ -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 ); @@ -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();