Skip to content
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

Fix #405: Named entities not lexed correctly #420

Merged
merged 1 commit into from
Jul 22, 2020

Conversation

MoonlightSentinel
Copy link
Contributor

@MoonlightSentinel MoonlightSentinel commented Jun 28, 2020

Rebase of #412 with the requested changes.

@Geod24 Geod24 changed the title Fix, Named entities not lexed correctly Fix #405: Named entities not lexed correctly Jun 29, 2020
@Geod24
Copy link
Member

Geod24 commented Jun 29, 2020

You mean rebase of #412 to fix #405 I assume.

{
auto l = DLexer(`"\&"`, cf, &ca);
assert(l.front().type == tok!"");
assert(l.messages == [ Msg(1, 4, "Invalid identifier", true), Msg(1, 6, "Error: unterminated string literal", true) ]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this one is acceptable...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second commit adds a potential workaround.

@MoonlightSentinel
Copy link
Contributor Author

Ping

error("Error: invalid named character entity");
return false;
}
range.popFront();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this can RangeError if the tokens end with & identifier, because we consumed the ampersand and the identifier, but the if invalid check didn't trigger because range.empty was true

For the same effect but a more sturdy check I would rewrite the if to

if (t.type != tok!"identifier" || range.empty || range.bytes[range.index] != ';')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Also added a test case for "\&0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that test case wouldn't match anyway because it already fails on the identifier, make the test case use an identifier instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

That will close dlang-community#405.

Co-authored-by: MoonlightSentinel <moonlightsentinel@disroot.org>
(Rebased and extended from PR dlang-community#412)
@dlang-bot dlang-bot merged commit ddafc62 into dlang-community:master Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants