-
Notifications
You must be signed in to change notification settings - Fork 59
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
Fix #405: Named entities not lexed correctly #420
Conversation
d167c0f to
cb5b19f
Compare
src/dparse/lexer.d
Outdated
| { | ||
| 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) ]); |
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.
Not sure if this one is acceptable...
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 second commit adds a potential workaround.
|
Ping |
| error("Error: invalid named character entity"); | ||
| return false; | ||
| } | ||
| range.popFront(); |
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 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] != ';')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.
Fixed. Also added a test case for "\&0
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.
that test case wouldn't match anyway because it already fails on the identifier, make the test case use an identifier instead
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.
Done
10e364d to
a941472
Compare
That will close dlang-community#405. Co-authored-by: MoonlightSentinel <moonlightsentinel@disroot.org> (Rebased and extended from PR dlang-community#412)
a941472 to
225a26b
Compare
Rebase of #412 with the requested changes.