MCPcopy Create free account
hub / github.com/argotorg/solidity / parseASTIDComment

Method parseASTIDComment

libyul/AsmParser.cpp:300–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300std::optional<std::pair<std::string_view, std::optional<int>>> Parser::parseASTIDComment(
301 std::string_view _arguments,
302 langutil::SourceLocation const& _commentLocation
303)
304{
305 static std::regex const argRegex = std::regex(
306 R"~~(^(\d+)(?:\s|$))~~",
307 std::regex_constants::ECMAScript | std::regex_constants::optimize
308 );
309 std::match_results<std::string_view::const_iterator> match;
310 std::optional<int> astID;
311 bool matched = regex_search(_arguments.cbegin(), _arguments.cend(), match, argRegex);
312 std::string_view tail = _arguments;
313 if (matched)
314 {
315 solAssert(match.size() == 2, "");
316 tail = _arguments.substr(static_cast<size_t>(match.position() + match.length()));
317
318 astID = toInt(match[1].str());
319 }
320
321 if (!matched || !astID || *astID < 0 || static_cast<int64_t>(*astID) != *astID)
322 {
323 m_errorReporter.syntaxError(1749_error, _commentLocation, "Invalid argument for @ast-id.");
324 astID = std::nullopt;
325 }
326 if (matched)
327 return {{_arguments, astID}};
328 else
329 return std::nullopt;
330}
331
332Block Parser::parseBlock()
333{

Callers

nothing calls this directly

Calls 6

toIntFunction · 0.85
strMethod · 0.80
sizeMethod · 0.45
positionMethod · 0.45
lengthMethod · 0.45
syntaxErrorMethod · 0.45

Tested by

no test coverage detected