alexander-beedie commented on code in PR #1655: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1655#discussion_r1919735863
########## src/parser/mod.rs: ########## @@ -8452,6 +8458,42 @@ impl<'a> Parser<'a> { } } + /// Parse a literal unicode normalization clause + pub fn parse_unicode_is_normalized( + &mut self, + ) -> Result<(Option<NormalizationForm>, bool), ParserError> { + let neg = self.parse_keyword(Keyword::NOT); + if self.parse_keyword(Keyword::NORMALIZED) { + return Ok((None, neg)); + } + let index = self.index; + let next_token = self.next_token(); + let normalized_form = if let Token::Word(Word { + value: ref s, + quote_style: None, + keyword: Keyword::NoKeyword, + }) = next_token.token + { + match s.to_uppercase().as_str() { + "NFC" => Some(NormalizationForm::NFC), + "NFD" => Some(NormalizationForm::NFD), + "NFKC" => Some(NormalizationForm::NFKC), + "NFKD" => Some(NormalizationForm::NFKD), + _ => { + self.index = index; + return self.expected("unicode normalization", next_token); + } + } + } else { + None + }; + if self.parse_keyword(Keyword::NORMALIZED) { + return Ok((normalized_form, neg)); + } + self.index = index; Review Comment: Nice. I hadn't previously spotted `maybe_parse` and wasn't sure if making the normalization forms keywords would be seen as "noisy", but the end result definitely seems cleaner - have updated the code accordingly ✌️ -- 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