-
Notifications
You must be signed in to change notification settings - Fork 165
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
Handle newlines during string parsing while lexing #2684
Handle newlines during string parsing while lexing #2684
Conversation
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 am not sure if we still this. When we encounter a string spanning multiple lines, do we still want to add length of string to current_column?
I'm not well versed in this part of the code but it seems like |
It appears that if we continue to add string length to its beginning locus, then it will give wrong location when showing errors involving multi-line strings. This is because the length of the multiple line string will be longer than the length of any particular line. I am incrementing Without removing
After removing
|
42cc5e7
to
7328844
Compare
7328844
to
5f7c65f
Compare
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 think this is good. I'd like to see maybe one more test to make sure we parse the newlines properly, so maybe something that calls printf
and checks the output with dg-output
?
If newline strings are encountered while lexing, the lexer now handles newline characters by incrementing current line number. This provides correct line number when displaying errors. If the lexer encounters end of file before string end, then it will use the start of the string as the location to an report error. gcc/rust/ChangeLog: * lex/rust-lex.cc (Lexer::parse_byte_string): Handle newline while parsing byte strings (Lexer::parse_string): Handle newline while parsing strings Signed-off-by: Nirmal Patel <[email protected]>
5f7c65f
to
c1c43f6
Compare
Apologies for the delay. How does it look now? |
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.
It looks good 🙂
If newline strings are encountered while lexing, the lexer now handles newline characters by incrementing current line number. This provides correct line number when displaying errors. If the lexer encounters end of file before string end, then it will use the start of the string as the location to an report error.
Fixes #2187