aharpervc commented on code in PR #1809: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1809#discussion_r2056903407
########## src/parser/mod.rs: ########## @@ -4055,6 +4090,38 @@ impl<'a> Parser<'a> { ) } + /// Look backwards in the token stream and expect that there was only whitespace tokens until the previous newline or beginning of string + pub(crate) fn expect_previously_only_whitespace_until_newline( + &mut self, + ) -> Result<(), ParserError> { + let mut look_back_count = 1; + loop { + let prev_token = self.peek_prev_nth_token_no_skip(look_back_count); + match prev_token.token { + Token::EOF => break, + Token::Whitespace(ref w) => match w { + Whitespace::Newline => break, + // special consideration required for single line comments since that string includes the newline + Whitespace::SingleLineComment { comment, prefix: _ } => { + if comment.ends_with('\n') { Review Comment: > double checking: is there a scenario where a single line comment doesn't end with a new line? spontaneously sounds like that should always hold true so that the manual newline check would not be required I actually don't know, I was surprised to find that the newline is actually part of the comment text in this library. It seemed prudent to be defensive in this new code, since that comment parsing behavior maybe isn't particularly intentional. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org