-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix lexer to properly handle single quote strings #258
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
Please add tests for the fixits. The file typealias FixIt1 = Int[][] // expected-error{{array types are now written with the brackets around the element type}}{{20-20=[}}{{25-26=}} |
Updated the test in expressions.swift to expect escaped double quotes! |
Just tested compilation, tests are passing. |
@gribozavr Can this be merged? |
@Jumhyn Would you mind squashing everything into one commit and doing a |
replacement += orig.slice(1, orig.size() - 1); | ||
std::string str = orig.slice(1, orig.size() - 1).str(); | ||
std::string quot = "\""; | ||
for (size_t pos = str.find(quot); pos != std::string::npos; pos = str.find(quot, pos)) { |
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.
Please reflow to 80-column limit.
There's one case where I think this will fail: it will suggest converting |
I think it will be sufficient to step through the string, skipping all escaped sequences and replacing unescaped |
You're right. This approach also makes it easier to address un-escaping escaped single quotes. Will push a new patch shortly. |
This should work now -- added new tests for the cases noted above as well. |
pos += 2; | ||
} | ||
} | ||
else if (str.at(pos) == '"') { |
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.
Put on same line as preceding '}'.
Lexer now suggests escaping unescaped double quotes and unescaping escaped single quotes in single quote strings..
Done. Are the style rules available on Swift.org (or otherwise)? I haven't seen an explicit style guide mentioned anywhere. |
All of the C++ code in the swift compiler should follow the LLVM coding standards: http://llvm.org/docs/CodingStandards.html |
Sweet, thanks for putting this together! |
Fix lexer to properly handle single quote strings
No problem, and thanks @lattner for the link to the coding standards! Those should be mentioned somewhere in reference to Swift in the contributing guide on Swift.org. Currently, the only line mentioning these is in the LLVM and Swift section, which says, "Contributions to Swift’s LLVM or Clang clones are governed by the LLVM Developer Policy and should follow the appropriate licensing and coding standards," but makes no mention of contributions to the Swift code itself. Probably worth a reference earlier on the page under the Contributing Code heading. |
Export objc_retainAutoreleasedReturnValue()
Export objc_retainAutoreleasedReturnValue() Signed-off-by: Daniel A. Steffen <[email protected]>
Fix parameter validation for functions with labeled arguments; add su…
Update swiftlang version to check against Xcode 10.0's
In response to a FIXME comment, the lexer now suggests
replacing double quotes inside single quote strings
with a backslash followed by a single quote.