@@ -3719,7 +3719,7 @@ impl<'a> Parser<'a> {
37193719 )
37203720 }
37213721
3722- /// Report that the current token was found instead of `expected`.
3722+ /// Report that the token at `index` was found instead of `expected`.
37233723 pub fn expected_at<T>(&self, expected: &str, index: usize) -> Result<T, ParserError> {
37243724 let found = self.tokens.get(index).unwrap_or(&EOF_TOKEN);
37253725 parser_err!(
@@ -3740,27 +3740,6 @@ impl<'a> Parser<'a> {
37403740 }
37413741 }
37423742
3743- /// If the current token is the `expected` keyword, consume it and returns
3744- ///
3745- /// See [`Self::parse_keyword_token_ref`] to avoid the copy.
3746- #[must_use]
3747- pub fn parse_keyword_token(&mut self, expected: Keyword) -> Option<TokenWithSpan> {
3748- self.parse_keyword_token_ref(expected).cloned()
3749- }
3750-
3751- /// If the current token is the `expected` keyword, consume it and returns a reference to the next token.
3752- ///
3753- #[must_use]
3754- pub fn parse_keyword_token_ref(&mut self, expected: Keyword) -> Option<&TokenWithSpan> {
3755- match &self.peek_token_ref().token {
3756- Token::Word(w) if expected == w.keyword => {
3757- self.advance_token();
3758- Some(self.get_current_token())
3759- }
3760- _ => None,
3761- }
3762- }
3763-
37643743 #[must_use]
37653744 pub fn peek_keyword(&self, expected: Keyword) -> bool {
37663745 matches!(&self.peek_token_ref().token, Token::Word(w) if expected == w.keyword)
@@ -3843,9 +3822,11 @@ impl<'a> Parser<'a> {
38433822
38443823 /// If the current token is the `expected` keyword, consume the token.
38453824 /// Otherwise, return an error.
3825+ ///
3826+ // todo deprecate infavor of expected_keyword_is
38463827 pub fn expect_keyword(&mut self, expected: Keyword) -> Result<TokenWithSpan, ParserError> {
3847- if let Some(token) = self.parse_keyword_token_ref (expected) {
3848- Ok(token .clone())
3828+ if self.parse_keyword (expected) {
3829+ Ok(self.get_current_token() .clone())
38493830 } else {
38503831 self.expected_ref(format!("{:?}", &expected).as_str(), self.peek_token_ref())
38513832 }
@@ -3857,7 +3838,7 @@ impl<'a> Parser<'a> {
38573838 /// This differs from expect_keyword only in that the matched keyword
38583839 /// token is not returned.
38593840 pub fn expect_keyword_is(&mut self, expected: Keyword) -> Result<(), ParserError> {
3860- if self.parse_keyword_token_ref (expected).is_some( ) {
3841+ if self.parse_keyword (expected) {
38613842 Ok(())
38623843 } else {
38633844 self.expected_ref(format!("{:?}", &expected).as_str(), self.peek_token_ref())
@@ -9498,7 +9479,8 @@ impl<'a> Parser<'a> {
94989479 /// expect the initial keyword to be already consumed
94999480 pub fn parse_query(&mut self) -> Result<Box<Query>, ParserError> {
95009481 let _guard = self.recursion_counter.try_decrease()?;
9501- let with = if let Some(with_token) = self.parse_keyword_token_ref(Keyword::WITH) {
9482+ let with = if self.parse_keyword(Keyword::WITH) {
9483+ let with_token = self.get_current_token();
95029484 Some(With {
95039485 with_token: with_token.clone().into(),
95049486 recursive: self.parse_keyword(Keyword::RECURSIVE),
0 commit comments