-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Lexer] Tweaks for string literal lexing #19356
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
Conversation
@swift-ci Please smoke test |
@swift-ci Please Test Source Compatibility |
@swift-ci Please test compiler performance |
include/swift/Parse/Token.h
Outdated
/// \brief Set characteristics of string literal token. | ||
void setStringLiteral(bool IsMultilineString, unsigned CustomDelimiterLen) { | ||
assert(Kind == tok::string_literal && | ||
"only identifiers can be escaped identifiers"); |
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.
assertion comment
514fa02
to
713edce
Compare
@swift-ci Please smoke test |
@swift-ci Please ASAN test |
Small cosmetic changes |
038f47b
to
7b744ce
Compare
@swift-ci Please smoke test |
We should not emit diagnostics in skipToEndOfInterpolatedExpression()
Removed Diags parameter from it. Skipped bytes are revisited by main lexer function anyway. So emitting diagnostics in it causes duplicated errors.
CurPtr[-1] must be '#' when called.
This simplifies main lexStringLiteral loop
EOF and newline (in non-multiline string literal) must be handled by call site. lexCharacter doesn't need to handle them. Added assertion instead.
NFC. Reorder code to improve readability.
Ignore the contents of interpolation.
For readability.
Fix-it to remove extra '#'s at once.
7b744ce
to
50497ff
Compare
@swift-ci Please smoke test |
👍👍, I like the new tidied up skipToEndOfInterpolatedExpression() |
I’m seeing an assertion firing on this code:
This is a step forward as it used to compile with no error and an incorrect string. It's difficult to think of a solution. |
Confirmed. Thank you! I'll look into it. |
formStringLiteralToken()
dedicated for forming string literal