@@ -3709,7 +3709,7 @@ impl<'a> Parser<'a> {
37093709 )
37103710 }
37113711
3712- /// Report that the current token was found instead of `expected`.
3712+ /// Report that the token at `index` was found instead of `expected`.
37133713 pub fn expected_at<T>(&self, expected: &str, index: usize) -> Result<T, ParserError> {
37143714 let found = self.tokens.get(index).unwrap_or(&EOF_TOKEN);
37153715 parser_err!(
@@ -3730,27 +3730,6 @@ impl<'a> Parser<'a> {
37303730 }
37313731 }
37323732
3733- /// If the current token is the `expected` keyword, consume it and returns
3734- ///
3735- /// See [`Self::parse_keyword_token_ref`] to avoid the copy.
3736- #[must_use]
3737- pub fn parse_keyword_token(&mut self, expected: Keyword) -> Option<TokenWithSpan> {
3738- self.parse_keyword_token_ref(expected).cloned()
3739- }
3740-
3741- /// If the current token is the `expected` keyword, consume it and returns a reference to the next token.
3742- ///
3743- #[must_use]
3744- pub fn parse_keyword_token_ref(&mut self, expected: Keyword) -> Option<&TokenWithSpan> {
3745- match &self.peek_token_ref().token {
3746- Token::Word(w) if expected == w.keyword => {
3747- self.advance_token();
3748- Some(self.get_current_token())
3749- }
3750- _ => None,
3751- }
3752- }
3753-
37543733 #[must_use]
37553734 pub fn peek_keyword(&self, expected: Keyword) -> bool {
37563735 matches!(&self.peek_token_ref().token, Token::Word(w) if expected == w.keyword)
@@ -3833,9 +3812,11 @@ impl<'a> Parser<'a> {
38333812
38343813 /// If the current token is the `expected` keyword, consume the token.
38353814 /// Otherwise, return an error.
3815+ ///
3816+ // todo deprecate infavor of expected_keyword_is
38363817 pub fn expect_keyword(&mut self, expected: Keyword) -> Result<TokenWithSpan, ParserError> {
3837- if let Some(token) = self.parse_keyword_token_ref (expected) {
3838- Ok(token .clone())
3818+ if self.parse_keyword (expected) {
3819+ Ok(self.get_current_token() .clone())
38393820 } else {
38403821 self.expected_ref(format!("{:?}", &expected).as_str(), self.peek_token_ref())
38413822 }
@@ -3847,7 +3828,7 @@ impl<'a> Parser<'a> {
38473828 /// This differs from expect_keyword only in that the matched keyword
38483829 /// token is not returned.
38493830 pub fn expect_keyword_is(&mut self, expected: Keyword) -> Result<(), ParserError> {
3850- if self.parse_keyword_token_ref (expected).is_some( ) {
3831+ if self.parse_keyword (expected) {
38513832 Ok(())
38523833 } else {
38533834 self.expected_ref(format!("{:?}", &expected).as_str(), self.peek_token_ref())
@@ -9488,7 +9469,8 @@ impl<'a> Parser<'a> {
94889469 /// expect the initial keyword to be already consumed
94899470 pub fn parse_query(&mut self) -> Result<Box<Query>, ParserError> {
94909471 let _guard = self.recursion_counter.try_decrease()?;
9491- let with = if let Some(with_token) = self.parse_keyword_token_ref(Keyword::WITH) {
9472+ let with = if self.parse_keyword(Keyword::WITH) {
9473+ let with_token = self.get_current_token();
94929474 Some(With {
94939475 with_token: with_token.clone().into(),
94949476 recursive: self.parse_keyword(Keyword::RECURSIVE),
0 commit comments