mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
AsmParser: Accept optional code snippets after the @src tags
This commit is contained in:
+16
-2
@@ -135,7 +135,8 @@ void Parser::fetchSourceLocationFromComment()
|
||||
regex_constants::ECMAScript | regex_constants::optimize
|
||||
);
|
||||
static regex const srcTagArgsRegex = regex(
|
||||
R"~~(^(-1|\d+):(-1|\d+):(-1|\d+)(?:\s+|$))~~", // index and location, e.g.: 1:234:-1
|
||||
R"~~(^(-1|\d+):(-1|\d+):(-1|\d+)(?:\s+|$))~~" // index and location, e.g.: 1:234:-1
|
||||
R"~~(("(?:[^"\\]|\\.)*"?)?)~~", // optional code snippet, e.g.: "string memory s = \"abc\";..."
|
||||
regex_constants::ECMAScript | regex_constants::optimize
|
||||
);
|
||||
|
||||
@@ -164,9 +165,22 @@ void Parser::fetchSourceLocationFromComment()
|
||||
return;
|
||||
}
|
||||
|
||||
solAssert(srcTagArgsMatch.size() == 4, "");
|
||||
solAssert(srcTagArgsMatch.size() == 5, "");
|
||||
position += srcTagArgsMatch.position() + srcTagArgsMatch.length();
|
||||
|
||||
if (srcTagArgsMatch[4].matched && (
|
||||
!boost::algorithm::ends_with(srcTagArgsMatch[4].str(), "\"") ||
|
||||
boost::algorithm::ends_with(srcTagArgsMatch[4].str(), "\\\"")
|
||||
))
|
||||
{
|
||||
m_errorReporter.syntaxError(
|
||||
1544_error,
|
||||
commentLocation,
|
||||
"Invalid code snippet in source location mapping. Quote is not terminated."
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
optional<int> const sourceIndex = toInt(srcTagArgsMatch[1].str());
|
||||
optional<int> const start = toInt(srcTagArgsMatch[2].str());
|
||||
optional<int> const end = toInt(srcTagArgsMatch[3].str());
|
||||
|
||||
Reference in New Issue
Block a user