-
Notifications
You must be signed in to change notification settings - Fork 6.1k
More generic source location parsing + more errors #11913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More generic source location parsing + more errors #11913
Conversation
solAssert(sourceName, ""); | ||
m_debugDataOverride = DebugData::create(SourceLocation{*start, *end, move(sourceName)}); | ||
smatch srcTagArgsMatch; | ||
if (!regex_search(position, commentLiteral.end(), srcTagArgsMatch, srcTagArgsRegex)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing stopping us from using Scanner
for parsing tag args is that there's no way to check where the scanner has stopped and use that to update position
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think I merged this too early: Shouldn't this be regex_match
instead? Otherwise it would match @src something 1:1:1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But maybe the ^
already does it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, both would work (regex_match()
with .*
added at the end). It starts with ^
exactly for this purpose.
BOOST_REQUIRE(errorList.size() == 1); | ||
BOOST_TEST(errorList[0]->type() == Error::Type::SyntaxError); | ||
BOOST_TEST(errorList[0]->errorId() == 8387_error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// @src 0:420:680foo
used to result in the tag being ignored. Now it's a syntax error.
BOOST_TEST_DONT_PRINT_LOG_VALUE(ErrorId) | ||
BOOST_TEST_DONT_PRINT_LOG_VALUE(Error::Type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have <<
for these defined. I can either define it or tell boost not to try to print it. For now I did the latter.
a9d56a3
to
dc44dc7
Compare
dc44dc7
to
eeb1946
Compare
Rebased on top of #11915. |
…ing, wrapping, etc.)
…dd support for more tags
eeb1946
to
14396c2
Compare
libyul/AsmParser.cpp
Outdated
static regex const lineRE = std::regex( | ||
R"~~~((^|\s*)@src\s+(-1|\d+):(-1|\d+):(-1|\d+)(\s+|$))~~~", | ||
std::regex_constants::ECMAScript | std::regex_constants::optimize | ||
static regex const tagRegex = regex( | ||
R"~~(\s*(@[a-zA-Z0-9\-_]+)(?:\s+|$))~~", // tag, e.g: @src | ||
regex_constants::ECMAScript | regex_constants::optimize | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added one more change to the regex here. \s+
after the tag was replaced with (?:\s+|$)
. This way in the example below @tag2
will not be ignored:
/// @src 1:3:4 some text, more text @tag1 @tag2
It does not matter all that match currently because there are no tags without args but it might become an unpleasant surprise if someone wanted to add them at some point.
Depends on #11915.Merged.This is the refactor requested in #11867 (comment) and a bunch of other small tweaks that apply generally to
@src
tags even without code snippets.Parser
tests were not checking for errors reported during parsing.